Skip to content

Commit

Permalink
Issue P4sca1#289 Generate CJS & MJS targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmas committed Apr 5, 2023
1 parent ee187c2 commit 4a2cf81
Show file tree
Hide file tree
Showing 6 changed files with 4,970 additions and 7,012 deletions.
11 changes: 11 additions & 0 deletions fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/mjs/index.d.ts",
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
},
"./schedulers/interval-based.js": {
"types": "./dist/schedulers/interval-based.d.ts",
"default": "./dist/schedulers/interval-based.js"
"types": "./dist/mjs/schedulers/interval-based.d.ts",
"import": "./dist/mjs/schedulers/interval-based.js",
"require": "./dist/cjs/schedulers/interval-based.js"
},
"./schedulers/timer-based.js": {
"types": "./dist/schedulers/timer-based.d.ts",
"default": "./dist/schedulers/timer-based.js"
"types": "./dist/mjs/schedulers/timer-based.d.ts",
"import": "./dist/mjs/schedulers/timer-based.js",
"require": "./dist/cjs/schedulers/timer-based.js"
}
},
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -79,7 +82,7 @@
]
},
"scripts": {
"build": "rimraf ./dist && tsc -p ./tsconfig.json",
"build": "rimraf ./dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup",
"tsc:check": "tsc --project ./tsconfig.json --noEmit",
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down
27 changes: 27 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"esModuleInterop": true,
"inlineSourceMap": false,
"lib": ["esnext"],
"listEmittedFiles": false,
"listFiles": false,
"moduleResolution": "nodenext",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"pretty": true,
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"strict": true,
"sourceMap": true,
"traceResolution": false,
"types": ["node"]
},
"compileOnSave": false,
"exclude": ["node_modules", "dist"],
"include": ["src/**/*.ts"]
}
8 changes: 8 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
}
}
21 changes: 6 additions & 15 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"sourceMap": true,
"declaration": true,

"target": "es6",
"module": "es2022",
"moduleResolution": "nodenext",

"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
},
"include": ["src/**/*.ts"]
}
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
}
}
Loading

0 comments on commit 4a2cf81

Please sign in to comment.