Skip to content

Commit

Permalink
bundle ed25519-keygen for cjs (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen authored Mar 29, 2024
1 parent c11b5ff commit 4417c0c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/agent/build/cjs-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import esbuild from 'esbuild';
import packageJson from '../package.json' assert { type: 'json' };

// list of dependencies that _dont_ ship cjs
const includeList = new Set(['ed25519-keygen']);

// create list of dependencies that we _do not_ want to include in our bundle
const excludeList = [];
for (const dependency in packageJson.dependencies) {
if (includeList.has(dependency)) {
continue;
} else {
excludeList.push(dependency);
}
}

esbuild.build({
entryPoints : [ './src/index.ts' ],
bundle : true,
external : excludeList,
format : 'cjs',
sourcemap : true,
platform : 'node',
outfile : 'dist/cjs/index.js',
allowOverwrite : true
});
2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"clean": "rimraf dist coverage tests/compiled",
"build:esm": "rimraf dist/esm dist/types && pnpm tsc -p tsconfig.json",
"build:cjs": "rimraf dist/cjs && pnpm tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
"build:cjs": "rimraf dist/cjs && node build/cjs-bundle.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && pnpm tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
Expand Down

0 comments on commit 4417c0c

Please sign in to comment.