Skip to content

Commit

Permalink
refactor: use tsconfig-to-dual-package (#12)
Browse files Browse the repository at this point in the history
* refactor: use tsconfig-to-dual-package

* CI: update node versions

* chore: add clean

* remove unused

* chore: update lock
  • Loading branch information
azu authored Jan 15, 2023
1 parent ed29dff commit 1d2f1cd
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 2,877 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14, 16, 18]
node-version: [ 16, 18 ]
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ crashlytics-build.properties
/esm
/cjs
/dts
/module/
/lib/
8 changes: 6 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"loader": "ts-node/esm"
}
"$schema": "https://json.schemastore.org/mocharc",
"loader": "ts-node/esm",
"spec": [
"test/**/*.ts"
]
}
63 changes: 18 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,42 @@
"type": "module",
"exports": {
"./package.json": "./package.json",
"./*": {
"node": {
"import": "./mjs/*.mjs",
"require": "./cjs/*.cjs"
}
},
".": {
"types": "./dts/index.d.ts",
"browser": {
"module": "./esm/index.js",
"import": "./esm/index.js",
"default": "./lib/index.js"
},
"node": {
"import": "./cjs/index-wrapper.mjs",
"require": "./cjs/index.cjs"
},
"types": "./module/index.d.ts",
"import": "./module/index.js",
"require": "./lib/index.js",
"default": "./lib/index.js"
}
},
"main": "./cjs/index.cjs",
"module": "./esm/index.js",
"types": "./dts/index.d.ts",
"main": "./lib/index.js",
"module": "./module/index.js",
"types": "./module/index.d.ts",
"directories": {
"test": "test"
},
"files": [
"bin/",
"cjs/**/*.{cjs,mjs,map}",
"dts/**/*.d.ts",
"esm/**/*.{js,map}",
"lib/",
"lib/**/*.{js,map}",
"mjs/**/*.{mjs,map}",
"module/",
"src/",
"src/**/*.{ts,tsx,json}"
"src/"
],
"scripts": {
"build": "packemon build --addExports --declaration",
"build": "tsc -p . && tsc -p ./tsconfig.cjs.json && tsconfig-to-dual-package",
"watch": "tsc -p . --watch",
"prepublishOnly": "npm run build",
"test": "mocha \"test/**/*.{js,ts}\"",
"watch": "tsc -p . --watch"
"test": "mocha",
"clean": "git clean -fx module/ lib/"
},
"dependencies": {
"emoji-regex": "^10.1.0"
},
"devDependencies": {
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.42",
"mocha": "^10.0.0",
"packemon": "^2.4.0",
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.18",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"tsconfig-to-dual-package": "^1.0.7",
"typescript": "^4.9.4"
},
"packemon": [
{
"format": "esm",
"platform": "browser"
},
{
"format": "cjs",
"platform": "node"
}
]
"packageManager": "[email protected]"
}
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.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "./lib/",
}
}
11 changes: 3 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@
"esModuleInterop": true,
"newLine": "LF",
"outDir": "./module/",
"target": "ES2015",
"target": "ES2018",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"jsx": "preserve",
"lib": [
"esnext",
"dom"
],
/* Strict Type-Checking Options */
"strict": true,
/* Additional Checks */
/* Report errors on unused locals. */
"noUnusedLocals": true,
/* Report errors on unused parameters. */
"noUnusedParameters": true,
/* Report error when not all code paths in function return a value. */
"noImplicitReturns": true,
/* Report errors for fallthrough cases in switch statement. */
"noFallthroughCasesInSwitch": true
},
"include": [
Expand All @@ -33,4 +28,4 @@
".git",
"node_modules"
]
}
}
Loading

0 comments on commit 1d2f1cd

Please sign in to comment.