-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.bundle.mjs
More file actions
36 lines (32 loc) · 922 Bytes
/
esbuild.bundle.mjs
File metadata and controls
36 lines (32 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { build } from "esbuild";
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
const umdWrapperOptions = {
libraryName: "TransportTemplate",
external: "inherit",
amdLoaderName: "define"
};
const makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external',
setup(build) {
let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/
build.onResolve({ filter }, args => ({ path: args.path, external: true }))
},
};
build({
bundle: true,
format: "esm",
entryPoints: [`./src/index.ts`],
outfile: `./dist/index.mjs`,
plugins: [makeAllPackagesExternalPlugin],
external: ["fs", "path", "ws"],
logLevel: "info",
}).catch(() => process.exit(1));
build({
bundle: true,
format: "cjs",
entryPoints: [`./src/index.ts`],
outfile: `./dist/index.js`,
plugins: [makeAllPackagesExternalPlugin, umdWrapper(umdWrapperOptions)],
external: ["fs", "path", "ws"],
logLevel: "info",
}).catch(() => process.exit(1));