Skip to content

Commit

Permalink
manage crypto with crypto browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
tokdaniel committed Oct 16, 2024
1 parent 811c266 commit 533a508
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"crypto-browserify": "^3.12.0"
}
}
28 changes: 22 additions & 6 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import { defineConfig } from 'tsup';
import { defineConfig } from "tsup";

export default defineConfig({
entry: ['./src/index.ts'],
tsconfig: './tsconfig.json',
entry: ["./src/index.ts"],
tsconfig: "./tsconfig.json",
splitting: false,
format: ['cjs', 'esm'],
format: ["cjs", "esm"],
minify: true,
clean: true,
sourcemap: true,
dts: true,
publicDir: './dist',
external: ['node:crypto'],
publicDir: "./dist",
external: ["node:crypto"],
esbuildOptions(options) {
options.plugins = [
{
name: "replace-node-crypto",
setup(build) {
build.onResolve({ filter: /^node:crypto$/ }, (args) => {
if (build.initialOptions.platform === "browser") {
return { path: require.resolve("crypto-browserify") };
} else {
return { path: "crypto" };
}
});
},
},
];
},
});

0 comments on commit 533a508

Please sign in to comment.