Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use tsconfig-to-dual-package #12

Merged
merged 5 commits into from Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
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
Expand Up @@ -88,3 +88,5 @@ crashlytics-build.properties
/esm
/cjs
/dts
/module/
/lib/
8 changes: 6 additions & 2 deletions .mocharc.json
@@ -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
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": "yarn@1.22.19"
}
8 changes: 8 additions & 0 deletions tsconfig.cjs.json
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "./lib/",
}
}
11 changes: 3 additions & 8 deletions tsconfig.json
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"
]
}
}