Skip to content

Commit

Permalink
fix(build): adapt for ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Feb 25, 2024
1 parent 4e98d8d commit 1509917
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function main() {
bundle: false,
platform: "neutral",
format: "esm",
target: "es2022",
...sharedOptions,
sourcemap: false,
});
Expand All @@ -37,30 +38,6 @@ async function main() {
await rm(typeFile);
}

const entryPoints = ["./pkg/dist-src/index.js"];

await Promise.all([
// Build the a CJS Node.js bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node18",
format: "cjs",
...sharedOptions,
}),
// Build an ESM browser bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-web",
bundle: true,
platform: "browser",
format: "esm",
...sharedOptions,
}),
]);

// Copy the README, LICENSE to the pkg folder
await copyFile("LICENSE", "pkg/LICENSE");
await copyFile("README.md", "pkg/README.md");
Expand All @@ -78,10 +55,12 @@ async function main() {
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
module: "dist-web/index.js",
types: "dist-types/index.d.ts",
source: "dist-src/index.js",
exports: {
".": {
types: "./dist-types/index.d.ts",
import: "./dist-bundle/index.js",
},
},
sideEffects: false,
},
null,
Expand Down

0 comments on commit 1509917

Please sign in to comment.