makepack 1.7.24 → 1.7.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/actions/build/bundler.js +27 -39
- package/src/actions/build/index.js +2 -2
- package/src/index.js +2 -2
package/package.json
CHANGED
|
@@ -141,48 +141,36 @@ async function bundler(args, spinner, child = false) {
|
|
|
141
141
|
|
|
142
142
|
const bundle = await rollup(config);
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
144
|
// --------------------- Output formats ---------------------
|
|
147
|
-
const outputs = []
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
} else if (args.format === "iife" || args.format === "umd") {
|
|
175
|
-
outputs.push({
|
|
176
|
-
dir: outdir,
|
|
177
|
-
format: args.format,
|
|
178
|
-
name: args.name || "Bundle",
|
|
179
|
-
sourcemap: args.sourcemap,
|
|
180
|
-
entryFileNames: "[name].js",
|
|
181
|
-
});
|
|
145
|
+
const outputs = []
|
|
146
|
+
const isModern = args.format === "modern";
|
|
147
|
+
const formats = isModern ? ["esm", "cjs"] : [args.format];
|
|
148
|
+
|
|
149
|
+
for (let f of formats) {
|
|
150
|
+
const isFirst = formats[0] === f;
|
|
151
|
+
const dir = isFirst ? outdir : path.join(outdir, f);
|
|
152
|
+
|
|
153
|
+
if (f === "esm" || f === "cjs") {
|
|
154
|
+
let ext = isModern ? f === "esm" ? "js" : "cjs" : "js"
|
|
155
|
+
outputs.push({
|
|
156
|
+
dir,
|
|
157
|
+
format: f,
|
|
158
|
+
sourcemap: args.sourcemap,
|
|
159
|
+
preserveModules: true,
|
|
160
|
+
preserveModulesRoot: rootdir,
|
|
161
|
+
entryFileNames: `[name].${ext}`,
|
|
162
|
+
});
|
|
163
|
+
} else if (f === "iife" || f === "umd") {
|
|
164
|
+
outputs.push({
|
|
165
|
+
dir,
|
|
166
|
+
format: f,
|
|
167
|
+
name: args.name || "Bundle",
|
|
168
|
+
sourcemap: args.sourcemap,
|
|
169
|
+
entryFileNames: "[name].js",
|
|
170
|
+
});
|
|
171
|
+
}
|
|
182
172
|
}
|
|
183
173
|
|
|
184
|
-
|
|
185
|
-
|
|
186
174
|
for (const output of outputs) {
|
|
187
175
|
await bundle.write(output);
|
|
188
176
|
}
|
|
@@ -7,7 +7,7 @@ import bundler from './bundler.js';
|
|
|
7
7
|
const build = async (args) => {
|
|
8
8
|
/*
|
|
9
9
|
args options:
|
|
10
|
-
--format=both
|
|
10
|
+
--format=both or esm,cjs,iife,umd
|
|
11
11
|
--bundle=true
|
|
12
12
|
--minify=false
|
|
13
13
|
--sourcemap=true
|
|
@@ -39,7 +39,7 @@ const build = async (args) => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
args = {
|
|
42
|
-
format: args.format
|
|
42
|
+
format: args.format ??= "modern",
|
|
43
43
|
bundle: beBool('bundle'),
|
|
44
44
|
minify: beBool('minify'),
|
|
45
45
|
sourcemap: beBool('sourcemap'),
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import start from "./actions/start/index.js";
|
|
@@ -24,7 +24,7 @@ program
|
|
|
24
24
|
program
|
|
25
25
|
.command("build")
|
|
26
26
|
.description("Build the project")
|
|
27
|
-
.option("-f, --format <format>", "Output format (cjs, esm,
|
|
27
|
+
.option("-f, --format <format>", "Output format (modern, cjs, esm, umd, iife)", "modern")
|
|
28
28
|
.option("-b, --bundle <bundle>", "Bundle the project", false)
|
|
29
29
|
.option("-m, --minify <minify>", "Minify the output", false)
|
|
30
30
|
.option("-s, --sourcemap <sourcemap>", "Generate sourcemaps", true)
|