Skip to content

Commit

Permalink
feat: bundle package
Browse files Browse the repository at this point in the history
  • Loading branch information
ext committed Mar 19, 2024
1 parent 34fb6d2 commit 18c3f0e
Show file tree
Hide file tree
Showing 35 changed files with 726 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trim_trailing_whitespace = true
indent_style = tab
charset = utf-8

[*.js]
[*.js,*.mjs]
indent_style = space
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Build
run: |
npm run --if-present build
node index.js
node dist/index.js
npm pack
npm exec npm-pkg-lint
- run: npm test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run semantic-release
run: npm exec semantic-release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.gitignore.io/api/macos,windows,linux,node

dist/
23 changes: 23 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import fs from "node:fs/promises";
import { build } from "esbuild";

const pkg = JSON.parse(await fs.readFile("package.json", "utf-8"));
const { externalDependencies } = pkg;

build({
entryPoints: ["src/index.js"],
bundle: true,
outdir: "dist",
platform: "node",
target: "node18",
format: "esm",
logLevel: "info",
external: externalDependencies,
banner: {
js: `
import { createRequire as _createRequire_ } from "node:module";
const require = _createRequire_(import.meta.url);
`,
},
});
Loading

0 comments on commit 18c3f0e

Please sign in to comment.