Kevin W - Itty
04/03/2021, 8:19 PMKevin W - Itty
04/03/2021, 8:19 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:19 PMKevin W - Itty
04/03/2021, 8:19 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:19 PMKevin W - Itty
04/03/2021, 8:21 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:23 PMservice-worker
type: esbuild src/index.ts --format=esm --bundle --outfile=dist/index.js
. I think it'll pretty much just work with modules type as well.Greg Brimble | Cloudflare Pages
04/03/2021, 8:25 PM--minify
and its variants), but the docs are pretty great: https://esbuild.github.io/api/#minify.
And if you are using any plugins, it's pretty easy to create a small build script file à la:
js
const esbuild = require("esbuild");
const alias = require("esbuild-plugin-alias");
esbuild.build({
entryPoints: ["src/index.ts"],
bundle: true,
format: "esm",
define: { "process.env.NODE_ENV": '"production"' },
outfile: "dist/index.js",
plugins: [
alias({
fs: require.resolve("./null.js"),
crypto: require.resolve("./null.js"),
path: require.resolve("./null.js"),
}),
],
});
Kevin W - Itty
04/03/2021, 8:28 PM--new-class
flag...Kevin W - Itty
04/03/2021, 8:28 PMKevin W - Itty
04/03/2021, 8:31 PMKevin W - Itty
04/03/2021, 8:31 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:31 PM--outfile=dist/index.mjs
, and make sure that's what you've also got as "module": "./dist/index.mjs"
in package.json
.Greg Brimble | Cloudflare Pages
04/03/2021, 8:31 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:31 PMKevin W - Itty
04/03/2021, 8:33 PMKevin W - Itty
04/03/2021, 8:47 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:47 PMKevin W - Itty
04/03/2021, 8:48 PMKevin W - Itty
04/03/2021, 8:48 PMKevin W - Itty
04/03/2021, 8:49 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:49 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:49 PMKevin W - Itty
04/03/2021, 8:49 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:50 PMKevin W - Itty
04/03/2021, 8:50 PMKevin W - Itty
04/03/2021, 8:50 PMGreg Brimble | Cloudflare Pages
04/03/2021, 8:50 PMmatt
04/03/2021, 8:58 PMWebjocke
04/03/2021, 9:05 PM