feat: build for esm
This commit is contained in:
parent
07ef3b6771
commit
fd7bc89fe0
30
build.js
30
build.js
@ -1,19 +1,21 @@
|
|||||||
const { build } = require("esbuild"),
|
const { build } = require("esbuild"),
|
||||||
{ copyFile } = require("fs");
|
{ copyFile } = require("fs");
|
||||||
|
|
||||||
const production = process.env.NODE_ENV === "production";
|
const production = process.env.NODE_ENV === "production",
|
||||||
|
formats = ["cjs", "esm"];
|
||||||
|
|
||||||
build({
|
(async () => {
|
||||||
entryPoints: ["./src/index.ts"],
|
for (const format of formats) {
|
||||||
watch: !production,
|
await build({
|
||||||
format: "cjs",
|
entryPoints: ["./src/index.ts"],
|
||||||
outfile: `./dist/index.js`
|
watch: !production,
|
||||||
})
|
format,
|
||||||
.then(() => {
|
outfile: `./dist/index${format === "cjs" ? "" : "." + format}.js`
|
||||||
// copy module declarations
|
|
||||||
copyFile("./src/modules.d.ts", "./dist/modules.d.ts", (err) => {
|
|
||||||
if (err) throw err;
|
|
||||||
console.log("[modules.d.ts] copied");
|
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
.catch(() => process.exit(1));
|
|
||||||
|
copyFile("./src/modules.d.ts", "./dist/modules.d.ts", (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log("[modules.d.ts] copied");
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"module": "dist/index.esm.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autoprefixer": "^10.2.4",
|
"autoprefixer": "^10.2.4",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user