Skip to content

Commit

Permalink
refactor: update build scripts to use "cjs" build name
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunnamius committed Jan 3, 2022
1 parent ae91614 commit 417064f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"scripts": {
"build": "npm run build-dist --",
"build-changelog": "conventional-changelog --outfile CHANGELOG.md --config conventional.config.js --release-count 0 --skip-unstable && (if [ \"$CHANGELOG_SKIP_TITLE\" != 'true' ]; then { node -e 'console.log(require(\"./conventional.config.js\").changelogTitle)'; cat CHANGELOG.md; } > CHANGELOG.md.ignore && mv CHANGELOG.md.ignore CHANGELOG.md; fi) && remark -o --use reference-links --use gfm --use frontmatter CHANGELOG.md && prettier --write CHANGELOG.md",
"build-dist": "if [ -r ./next.config.js ]; then next build; else NODE_ENV=production tsc --project tsconfig.types.json && NODE_ENV=production webpack --config-name lib && if [ -r ./src/cli.ts ]; then NODE_ENV=production webpack --config-name cli && chmod +x ./dist/cli.js; fi && NODE_ENV=esm webpack --config-name esm && NODE_ENV=bundle babel src --extensions .ts --out-dir dist/bundle --out-file-extension .mjs; fi",
"build-dist": "if [ -r ./next.config.js ]; then next build; else NODE_ENV=production tsc --project tsconfig.types.json && NODE_ENV=production webpack --config-name cjs && if [ -r ./src/cli.ts ]; then NODE_ENV=production webpack --config-name cli && chmod +x ./dist/cli.js; fi && NODE_ENV=esm webpack --config-name esm && NODE_ENV=bundle babel src --extensions .ts --out-dir dist/bundle --out-file-extension .mjs; fi",
"build-docs": "if [ -r ./next.config.js ]; then typedoc --plugin typedoc-plugin-markdown --out docs --readme none lib src test types external-scripts --exclude '**/*.test.*' --exclude external-scripts/bin; else ENTRY=`node -e 'console.log((x => typeof x==\"string\"?x:x.default)(require(\"./package.json\").exports[\".\"]).replace(/\\.\\/dist\\/(.+)\\.[a-zA-Z0-9]+$/, \"./src/$1.ts\"))'` && echo 'Entry file:' \"$ENTRY\" && typedoc --plugin typedoc-plugin-markdown --out docs --readme none $ENTRY && find docs -name '*.md' -exec sed -i -e 's/Project: //g' {} + && sed -i -e 1,4d docs/README.md; fi && find docs -name '*.md' -exec sed -i -e 's/`__namedParameters`/`\\(destructured\\)`/g' {} + && find docs -name '*.md' -exec sed -i -E 's/`__namedParameters\\.([^`]+)`/`\\({ \\1 }\\)`/g' {} +",
"build-stats": "NODE_ENV=production webpack --json > bundle-stats.ignore.json",
"clean": "rm -rf dist coverage external-scripts/bin bundle-stats.ignore.json && git ls-files --exclude-standard --ignored --others --directory dist | xargs rm -rf {} +",
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const externals = ({ esm /*: boolean */ }) => [
];

const libCjsConfig = {
name: 'lib',
name: 'cjs',
mode: 'production',
target: 'node',
node: false,
Expand Down Expand Up @@ -184,7 +184,7 @@ const libEsmConfig = {
path: `${__dirname}/external-scripts/bin`
},
externals,
externals: externals({ esm: false }),
externalsPresets: { node: true },
stats: {
Expand All @@ -211,7 +211,7 @@ const libEsmConfig = {
},
optimization: { usedExports: true },
plugins: [
...envPlugins,
...envPlugins({ esm: false }),
// * ▼ For non-bundled externals, make entry file executable w/ shebang
new BannerPlugin({ banner: '#!/usr/bin/env node', raw: true, entryOnly: true })
]
Expand Down

0 comments on commit 417064f

Please sign in to comment.