Skip to content

Commit c0ad153

Browse files
committed
also probably don't work in the weekends
1 parent 0e136e5 commit c0ad153

File tree

2 files changed

+92
-71
lines changed

2 files changed

+92
-71
lines changed

build.js

Lines changed: 91 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,109 @@
11
import { build } from 'esbuild';
22
import { writeFile } from 'node:fs/promises';
33

4+
const builds = [];
5+
46
// Bundled CJS
5-
build({
6-
entryPoints: ['./src/index.js'],
7-
logLevel: 'info',
8-
bundle: true,
9-
format: 'cjs',
10-
outfile: 'bundled/culori.cjs'
11-
});
7+
builds.push(
8+
build({
9+
entryPoints: ['./src/index.js'],
10+
logLevel: 'info',
11+
bundle: true,
12+
format: 'cjs',
13+
outfile: 'bundled/culori.cjs'
14+
})
15+
);
1216

1317
// Bundled CJS, minified
14-
build({
15-
entryPoints: ['./src/index.js'],
16-
logLevel: 'info',
17-
bundle: true,
18-
minify: true,
19-
format: 'cjs',
20-
outfile: 'bundled/culori.min.cjs'
21-
});
18+
builds.push(
19+
build({
20+
entryPoints: ['./src/index.js'],
21+
logLevel: 'info',
22+
bundle: true,
23+
minify: true,
24+
format: 'cjs',
25+
outfile: 'bundled/culori.min.cjs'
26+
})
27+
);
2228

2329
// Bundled ESM
24-
build({
25-
entryPoints: ['./src/index.js'],
26-
logLevel: 'info',
27-
bundle: true,
28-
format: 'esm',
29-
metafile: true,
30-
outfile: 'bundled/culori.mjs'
31-
}).then(result => {
32-
writeFile('bundled/meta.json', JSON.stringify(result.metafile, null, 2));
33-
});
30+
builds.push(
31+
build({
32+
entryPoints: ['./src/index.js'],
33+
logLevel: 'info',
34+
bundle: true,
35+
format: 'esm',
36+
metafile: true,
37+
outfile: 'bundled/culori.mjs'
38+
}).then(result => {
39+
writeFile(
40+
'bundled/meta.json',
41+
JSON.stringify(result.metafile, null, 2)
42+
);
43+
})
44+
);
3445

3546
// Bundled ESM, minified
36-
build({
37-
entryPoints: ['./src/index.js'],
38-
logLevel: 'info',
39-
bundle: true,
40-
minify: true,
41-
format: 'esm',
42-
outfile: 'bundled/culori.min.mjs'
43-
});
47+
builds.push(
48+
build({
49+
entryPoints: ['./src/index.js'],
50+
logLevel: 'info',
51+
bundle: true,
52+
minify: true,
53+
format: 'esm',
54+
outfile: 'bundled/culori.min.mjs'
55+
})
56+
);
4457

4558
// Bundled IIFE
46-
build({
47-
entryPoints: ['./src/index.js'],
48-
logLevel: 'info',
49-
bundle: true,
50-
format: 'iife',
51-
globalName: 'culori',
52-
outfile: 'bundled/culori.js'
53-
});
59+
builds.push(
60+
build({
61+
entryPoints: ['./src/index.js'],
62+
logLevel: 'info',
63+
bundle: true,
64+
format: 'iife',
65+
globalName: 'culori',
66+
outfile: 'bundled/culori.js'
67+
})
68+
);
5469

5570
// Bundled IIFE, minified
56-
build({
57-
entryPoints: ['./src/index.js'],
58-
logLevel: 'info',
59-
bundle: true,
60-
minify: true,
61-
format: 'iife',
62-
globalName: 'culori',
63-
outfile: 'bundled/culori.min.js'
64-
});
71+
builds.push(
72+
build({
73+
entryPoints: ['./src/index.js'],
74+
logLevel: 'info',
75+
bundle: true,
76+
minify: true,
77+
format: 'iife',
78+
globalName: 'culori',
79+
outfile: 'bundled/culori.min.js'
80+
})
81+
);
6582

6683
// Bundled UMD
6784
// Adapted from: https://github.com/umdjs/umd/blob/master/templates/returnExports.js
68-
build({
69-
entryPoints: ['./src/index.js'],
70-
logLevel: 'info',
71-
bundle: true,
72-
format: 'iife',
73-
globalName: 'culori',
74-
banner: {
75-
js: `(function(root, factory) {
76-
if (typeof define === 'function' && define.amd) {
77-
define([], factory);
78-
} else if (typeof module === 'object' && module.exports) {
79-
module.exports = factory();
80-
} else {
81-
root.culori = factory();
85+
builds.push(
86+
build({
87+
entryPoints: ['./src/index.js'],
88+
logLevel: 'info',
89+
bundle: true,
90+
format: 'iife',
91+
globalName: 'culori',
92+
banner: {
93+
js: `(function(root, factory) {
94+
if (typeof define === 'function' && define.amd) {
95+
define([], factory);
96+
} else if (typeof module === 'object' && module.exports) {
97+
module.exports = factory();
98+
} else {
99+
root.culori = factory();
100+
}
82101
}
83-
}
84-
(typeof self !== 'undefined' ? self : this, function() {`
85-
},
86-
footer: { js: `return culori; }));` },
87-
outfile: 'bundled/culori.umd.js'
88-
});
102+
(typeof self !== 'undefined' ? self : this, function() {`
103+
},
104+
footer: { js: `return culori; }));` },
105+
outfile: 'bundled/culori.umd.js'
106+
})
107+
);
108+
109+
await Promise.all(builds);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"benchmark": "node benchmark/index.js",
6363
"prepublishOnly": "npm run lint && npm run build && npm run test",
6464
"docs:start": "eleventy --config=eleventy.config.cjs --serve",
65-
"docs:build": "npm run build && cp bundled/culori.min.mjs www/ && rm -rf www && eleventy --config=eleventy.config.cjs",
65+
"docs:build": "npm run build && rm -rf www && eleventy --config=eleventy.config.cjs && cp bundled/culori.min.mjs www/",
6666
"docs:deploy": "npm run docs:build && gh-pages -d www --dotfiles",
6767
"lint": "eslint '{src,test}/**/*.js'"
6868
},

0 commit comments

Comments
 (0)