-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbundle.ts
More file actions
23 lines (20 loc) · 716 Bytes
/
bundle.ts
File metadata and controls
23 lines (20 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as esbuild from "npm:esbuild";
import inlineWorkerPlugin from "npm:esbuild-plugin-inline-worker";
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader";
// Polyfill for Node.js require() to handle built-in modules in Deno
// This is injected at the top of the bundle to handle dynamic requires from npm packages
const requirePolyfill = `
import { createRequire as __createRequire } from "node:module";
const require = __createRequire(import.meta.url);
`;
const result = await esbuild.build({
plugins: [inlineWorkerPlugin(), ...denoPlugins()],
entryPoints: ["./server.ts"],
outfile: "./bundled.js",
bundle: true,
format: "esm",
banner: {
js: requirePolyfill,
},
});
esbuild.stop();