Skip to content

Instantly share code, notes, and snippets.

View mobsense's full-sized avatar

Michael O'Brien mobsense

View GitHub Profile
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
}
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF
cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"esModuleInterop": true,
"inlineSourceMap": false,
"lib": ["esnext"],
"listEmittedFiles": false,
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
}
}
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
}
}
{
"scripts": {
"build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup"
}
}
import Shape from './Shape.js'
const shape = new Shape.default()
import Shape from './Shape.js'
export class MyShape {
constructor() {
this.shape = new Shape()
}
}
{
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js"
}
{
"exports": {
"import": {
"path": "./dist/mjs/index.js",
"type": "module"
},
"require": {
"path": "./dist/cjs/index.js",
"type": "commonjs"
}