Skip to content

Commit

Permalink
Revert "chore: only build to CJS"
Browse files Browse the repository at this point in the history
This reverts commit 3192ef9.
  • Loading branch information
blephy committed Jul 1, 2022
1 parent 13ed043 commit 7a3d023
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Check package.json library usage
run: yarn packagejson:check
- name: Spell checking with Cspell
run: yarn cspell:ci
- name: Lint codebase with Eslint
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
"package.json": ['yarn packagejson:format'],
"package.json": ['yarn packagejson:format', 'yarn packagejson:check'],
"**/*.ts": () => ["tsc -p tsconfig.json --noEmit"],
"**/*.{ts,mts,cts,js,mjs,cjs}": (filenames) => `eslint -c .eslintrc.cjs ${filenames.join(" ")} --fix --cache`,
};
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
"access": "public",
"registry": " https://registry.npmjs.org"
},
"main": "./lib/cjs/index.cjs",
"type": "module",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"require": "./lib/cjs/index.cjs",
"default": "./lib/cjs/index.cjs"
"import": "./lib/esm/index.js"
}
},
"files": [
"/lib/**/*"
],
"types": "./lib/types/index.d.ts",
"scripts": {
"build": "yarn clean && yarn build:cjs",
"build:cjs": "tsc -b tsconfig.build.cjs.json",
"build": "yarn clean && yarn build:cjs && yarn build:esm",
"build:cjs": "tsc -b tsconfig.build.cjs.json && ./scripts/convert-to-cjs.sh",
"build:esm": "tsc -b tsconfig.build.esm.json",
"clean": "rm -rfv reports coverage build dist lib .eslintcache",
"commit": "cz",
Expand All @@ -43,6 +43,7 @@
"postinstall": "husky install",
"prepack": "pinst --disable",
"postpack": "pinst --enable",
"packagejson:check": "package-check",
"packagejson:format": "prettier-package-json --write ./package.json",
"test": "yarn test:unit",
"test:mutation": "stryker run",
Expand All @@ -56,6 +57,7 @@
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@commitlint/cz-commitlint": "^17.0.0",
"@skypack/package-check": "^0.2.2",
"@stryker-mutator/core": "^6.0.2",
"@stryker-mutator/mocha-runner": "^6.0.2",
"@stryker-mutator/typescript-checker": "^6.0.2",
Expand Down
11 changes: 11 additions & 0 deletions scripts/convert-to-cjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo "Converting .js files to .cjs"

FILES=$(find "./lib" -name "*.js")

for path in $FILES
do
echo "Editing $path"
sed -r -i "" "s/(require ?[^\"]+\"([^\"]+))\.js/\1.cjs/" "$path"
mv "$path" "${path/%.js/.cjs}"
done
echo "Done converting files to .cjs"
4 changes: 2 additions & 2 deletions tsconfig.build.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"outDir": "./lib/cjs",
"target": "ES2015",
"module": "CommonJS",
"declarationDir": "./lib/types",
"esModuleInterop": true
"declaration": false,
"declarationMap": false
},
"include": ["./src/**/*"]
}
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"declarationMap": false,
"declarationMap": true,
"removeComments": false,
"sourceMap": false,
"noEmit": false,
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,18 @@ __metadata:
languageName: node
linkType: hard

"@skypack/package-check@npm:^0.2.2":
version: 0.2.2
resolution: "@skypack/package-check@npm:0.2.2"
dependencies:
kleur: ^4.1.3
yargs-parser: ^20.2.3
bin:
package-check: index.bin.js
checksum: 7b35c331609b743815ba9d2a7d789e8157d5119ea167fe684cd9d95978892d01aac0e36db5ea8d54fc565e5f57f3732a9793c5c711d454ce9bf1581f34829e9f
languageName: node
linkType: hard

"@stryker-mutator/api@npm:6.0.2":
version: 6.0.2
resolution: "@stryker-mutator/api@npm:6.0.2"
Expand Down Expand Up @@ -5453,6 +5465,13 @@ __metadata:
languageName: node
linkType: hard

"kleur@npm:^4.1.3":
version: 4.1.4
resolution: "kleur@npm:4.1.4"
checksum: 7f6db36e378045dec14acd3cbf0b1e59130c09e984ee8b8ce56dd2d2257cfff90389c1e8f8b19bd09dd5d241080566a814b4ccd99fdcef91f59ef93ec33c8a44
languageName: node
linkType: hard

"levn@npm:^0.4.1":
version: 0.4.1
resolution: "levn@npm:0.4.1"
Expand Down Expand Up @@ -8686,6 +8705,7 @@ __metadata:
"@commitlint/cli": ^17.0.2
"@commitlint/config-conventional": ^17.0.2
"@commitlint/cz-commitlint": ^17.0.0
"@skypack/package-check": ^0.2.2
"@stryker-mutator/core": ^6.0.2
"@stryker-mutator/mocha-runner": ^6.0.2
"@stryker-mutator/typescript-checker": ^6.0.2
Expand Down

0 comments on commit 7a3d023

Please sign in to comment.