forked from thegreenwebfoundation/co2.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.esbuild.esm.js
More file actions
32 lines (30 loc) · 1.06 KB
/
Copy path.esbuild.esm.js
File metadata and controls
32 lines (30 loc) · 1.06 KB
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
const esbuild = require("esbuild");
// tiny glob is a dependency of `esbuild-plugin-glob`.
// For this build however we need to filter out some extra files
// that are used for nodejs, but not in browsers, so we use the
// library directly instead of using `esbuild-plugin-glob` as a plugin
const glob = require("tiny-glob");
const esbuildCommon = require("./.esbuild.common");
async function main() {
const results = await glob("src/**/!(*.test.js|test-constants.js|!(*.js))");
// we remove node specific files here, with the assumption that
// the common use case is bundling into browser based web apps
const justBrowserCompatibleFiles = results.filter(
(filepath) => !filepath.endsWith("node.js")
);
esbuild.build({
...esbuildCommon,
entryPoints: justBrowserCompatibleFiles,
bundle: false,
minify: false,
sourcemap: false,
target: ["chrome58", "firefox57", "safari11", "edge18", "esnext"],
outdir: "dist/esm",
outExtension: { ".js": ".js" },
format: "esm",
supported: {
destructuring: true,
},
});
}
main();