-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.js
More file actions
61 lines (53 loc) · 1.86 KB
/
build.js
File metadata and controls
61 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const esbuild = require("esbuild");
const { readFileSync } = require("fs");
const pkg = JSON.parse(readFileSync("./package.json", "utf8"));
const banner = `/**
* No.JS v${pkg.version} — The HTML-First Reactive Framework
* No more JavaScript. Just HTML attributes with superpowers.
* @author ${pkg.author}
* @homepage https://no-js.dev
* @license MIT
* @see https://github.com/ErickXavier/no-js
*/`;
const shared = {
bundle: true,
banner: { js: banner },
target: ["es2020"],
};
async function build() {
// ── CDN (IIFE) ────────────────────────────────────────────────────
await esbuild.build({
...shared,
entryPoints: ["src/cdn.js"],
outfile: "dist/iife/no.js",
format: "iife",
minify: true,
sourcemap: true,
});
// ── ESM ───────────────────────────────────────────────────────────
await esbuild.build({
...shared,
entryPoints: ["src/index.js"],
outfile: "dist/esm/no.js",
format: "esm",
minify: true,
sourcemap: true,
});
// ── CJS ───────────────────────────────────────────────────────────
await esbuild.build({
...shared,
entryPoints: ["src/index.js"],
outfile: "dist/cjs/no.js",
format: "cjs",
minify: true,
sourcemap: true,
});
console.log("✓ Build complete!");
console.log(" dist/iife/no.js — CDN / <script> tag");
console.log(" dist/esm/no.js — ES module (import)");
console.log(" dist/cjs/no.js — CommonJS (require)");
}
build().catch((err) => {
console.error("Build failed:", err);
process.exit(1);
});