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 Mar 4, 2024
1 parent f179b0b commit aad55f4
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ async function main() {
platform: "neutral",
format: "esm",
...sharedOptions,
sourcemap: false,
});

// Remove the types file from the dist-src folder
Expand All @@ -37,30 +36,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: "node14",
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 @@ -77,11 +52,15 @@ async function main() {
JSON.stringify(
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
module: "dist-web/index.js",
files: ["dist-*/**"],
main: "dist-src/index.js",
types: "dist-types/index.d.ts",
source: "dist-src/index.js",
exports: {
".": {
types: "./dist-types/index.d.ts",
import: "./dist-src/index.js",
}
},
sideEffects: false,
},
null,
Expand Down

0 comments on commit aad55f4

Please sign in to comment.