Skip to content

Commit aad55f4

Browse files
committed
fix(build): adapt for ESM
1 parent f179b0b commit aad55f4

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

scripts/build.mjs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ async function main() {
2525
platform: "neutral",
2626
format: "esm",
2727
...sharedOptions,
28-
sourcemap: false,
2928
});
3029

3130
// Remove the types file from the dist-src folder
@@ -37,30 +36,6 @@ async function main() {
3736
await rm(typeFile);
3837
}
3938

40-
const entryPoints = ["./pkg/dist-src/index.js"];
41-
42-
await Promise.all([
43-
// Build the a CJS Node.js bundle
44-
esbuild.build({
45-
entryPoints,
46-
outdir: "pkg/dist-node",
47-
bundle: true,
48-
platform: "node",
49-
target: "node14",
50-
format: "cjs",
51-
...sharedOptions,
52-
}),
53-
// Build an ESM browser bundle
54-
esbuild.build({
55-
entryPoints,
56-
outdir: "pkg/dist-web",
57-
bundle: true,
58-
platform: "browser",
59-
format: "esm",
60-
...sharedOptions,
61-
}),
62-
]);
63-
6439
// Copy the README, LICENSE to the pkg folder
6540
await copyFile("LICENSE", "pkg/LICENSE");
6641
await copyFile("README.md", "pkg/README.md");
@@ -77,11 +52,15 @@ async function main() {
7752
JSON.stringify(
7853
{
7954
...pkg,
80-
files: ["dist-*/**", "bin/**"],
81-
main: "dist-node/index.js",
82-
module: "dist-web/index.js",
55+
files: ["dist-*/**"],
56+
main: "dist-src/index.js",
8357
types: "dist-types/index.d.ts",
84-
source: "dist-src/index.js",
58+
exports: {
59+
".": {
60+
types: "./dist-types/index.d.ts",
61+
import: "./dist-src/index.js",
62+
}
63+
},
8564
sideEffects: false,
8665
},
8766
null,

0 commit comments

Comments
 (0)