quickbundle 0.0.0-next-750bdbd → 0.0.0-next-d9c46be
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/dist/index.mjs +52 -32
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { writeFileSync } from 'node:fs';
|
|
|
16
16
|
import { gzipSize } from 'gzip-size';
|
|
17
17
|
|
|
18
18
|
var name = "quickbundle";
|
|
19
|
-
var version = "0.0.0-next-
|
|
19
|
+
var version = "0.0.0-next-d9c46be";
|
|
20
20
|
|
|
21
21
|
const CWD = process.cwd();
|
|
22
22
|
|
|
@@ -42,10 +42,10 @@ const isRecord = (value)=>{
|
|
|
42
42
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const watch = (
|
|
45
|
+
const watch = (input)=>{
|
|
46
46
|
process.env.NODE_ENV ??= "development";
|
|
47
|
-
const watcher = watch$1(
|
|
48
|
-
...
|
|
47
|
+
const watcher = watch$1(input.data.map((configItem)=>({
|
|
48
|
+
...configItem,
|
|
49
49
|
onLog
|
|
50
50
|
})));
|
|
51
51
|
let startDuration;
|
|
@@ -90,39 +90,52 @@ const clearLog = (...input)=>{
|
|
|
90
90
|
|
|
91
91
|
const require = createRequire(import.meta.url);
|
|
92
92
|
const PKG = require(join(CWD, "./package.json"));
|
|
93
|
-
const
|
|
93
|
+
const createConfiguration = (options = {
|
|
94
94
|
minification: false,
|
|
95
95
|
sourceMaps: false,
|
|
96
96
|
standalone: false
|
|
97
97
|
})=>{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
const buildableExports = getBuildableExports(options);
|
|
99
|
+
return {
|
|
100
|
+
data: buildableExports.flatMap((buildableExport)=>{
|
|
101
|
+
return [
|
|
102
|
+
buildableExport.source && createMainConfig({
|
|
103
|
+
...buildableExport,
|
|
104
|
+
source: buildableExport.source
|
|
105
|
+
}, options),
|
|
106
|
+
buildableExport.source && buildableExport.types && createTypesConfig({
|
|
107
|
+
source: buildableExport.source,
|
|
108
|
+
types: buildableExport.types
|
|
109
|
+
}, options)
|
|
110
|
+
].filter(Boolean);
|
|
111
|
+
}),
|
|
112
|
+
metadata: buildableExports
|
|
113
|
+
};
|
|
110
114
|
};
|
|
115
|
+
// eslint-disable-next-line sonarjs/cyclomatic-complexity
|
|
111
116
|
const getBuildableExports = ({ standalone })=>{
|
|
112
117
|
if (standalone) {
|
|
113
118
|
/**
|
|
114
119
|
* Entry-point resolution invariants for standalone target (mostly binaries).
|
|
115
|
-
*/ if (!PKG.source || !PKG.bin) {
|
|
116
|
-
throw new Error("Invalid package entry points contract. Standalone compilation is enabled but required fields
|
|
120
|
+
*/ if (!PKG.source || !PKG.bin || !PKG.name) {
|
|
121
|
+
throw new Error("Invalid package entry points contract. Standalone compilation is enabled but required fields are missing. Make sure to set `name`, `source`, and `bin` fields.");
|
|
117
122
|
}
|
|
118
123
|
const bin = PKG.bin;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
const name = PKG.name;
|
|
125
|
+
const source = PKG.source;
|
|
126
|
+
if (isRecord(bin)) {
|
|
127
|
+
return Object.entries(bin).map((data)=>({
|
|
128
|
+
bin: data[0],
|
|
129
|
+
require: data[1],
|
|
130
|
+
source
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
return [
|
|
123
134
|
{
|
|
135
|
+
// For scoped packages and if the `bin` is defined with a string value, the [scope name is discarded](the scope name is discarded when creating a binary) when creating a binary.
|
|
136
|
+
bin: name.replace(/^(@.*?\/)/, ""),
|
|
124
137
|
require: bin,
|
|
125
|
-
source
|
|
138
|
+
source
|
|
126
139
|
}
|
|
127
140
|
];
|
|
128
141
|
}
|
|
@@ -131,7 +144,7 @@ const getBuildableExports = ({ standalone })=>{
|
|
|
131
144
|
* Following the [package entry-point specification](https://nodejs.org/api/packages.html#package-entry-points),
|
|
132
145
|
* whenever an export object is defined, it take precedence over other classical entry-point fields
|
|
133
146
|
* (such as main, module, and types defined at the root package.json level).
|
|
134
|
-
*/ if (PKG.main
|
|
147
|
+
*/ if ((PKG.main || PKG.module) ?? PKG.types ?? !PKG.exports) {
|
|
135
148
|
throw new Error("Invalid package entry points contract. Use the recommended [`exports` field](https://nodejs.org/api/packages.html#package-entry-points) instead and, for TypeScript-based projects, update the `tsconfig.json` file to resolve it properly (`moduleResolution` must be set to `Bundler` (or `NodeNext`)).");
|
|
136
149
|
}
|
|
137
150
|
const buildableExportFields = [
|
|
@@ -263,7 +276,7 @@ const createWatchCommand = (program)=>{
|
|
|
263
276
|
description: "Watch and rebuild on any code change (development mode)"
|
|
264
277
|
}).task({
|
|
265
278
|
handler (context) {
|
|
266
|
-
watch(
|
|
279
|
+
watch(createConfiguration({
|
|
267
280
|
minification: context.minification,
|
|
268
281
|
sourceMaps: context.sourceMaps,
|
|
269
282
|
standalone: false
|
|
@@ -272,8 +285,9 @@ const createWatchCommand = (program)=>{
|
|
|
272
285
|
});
|
|
273
286
|
};
|
|
274
287
|
|
|
275
|
-
const build = async (
|
|
288
|
+
const build = async (input)=>{
|
|
276
289
|
process.env.NODE_ENV ??= "production";
|
|
290
|
+
const { data: configurations } = input;
|
|
277
291
|
const output = [];
|
|
278
292
|
for (const config of configurations){
|
|
279
293
|
const initialTime = Date.now();
|
|
@@ -317,16 +331,22 @@ const createCompileCommand = (program)=>{
|
|
|
317
331
|
const osType = os.type();
|
|
318
332
|
const isWindowsOS = osType === "Windows_NT";
|
|
319
333
|
const isMacOS = osType === "Darwin";
|
|
320
|
-
const
|
|
334
|
+
const configuration = createConfiguration({
|
|
321
335
|
minification: true,
|
|
322
336
|
sourceMaps: false,
|
|
323
337
|
standalone: true
|
|
324
|
-
})
|
|
325
|
-
|
|
338
|
+
});
|
|
339
|
+
await build(configuration);
|
|
340
|
+
for (const { bin, require: filePath } of configuration.metadata){
|
|
341
|
+
if (!filePath || !bin) {
|
|
342
|
+
throw new Error("Invalid configuration output. Missing `filePath` or `bin` field definition.");
|
|
343
|
+
}
|
|
326
344
|
chdir(dirname(filePath));
|
|
327
345
|
const fileName = basename(filePath);
|
|
328
346
|
const blobFileName = `${fileName}.blob`;
|
|
329
|
-
|
|
347
|
+
/*
|
|
348
|
+
* TODO: split with several tasks
|
|
349
|
+
*/ const executableFileName = `${bin}${isWindowsOS ? ".exe" : ""}`;
|
|
330
350
|
const seaConfigFileName = `${fileName}.sea-config.json`;
|
|
331
351
|
writeFileSync(seaConfigFileName, JSON.stringify({
|
|
332
352
|
disableExperimentalSEAWarning: true,
|
|
@@ -357,7 +377,7 @@ const createBuildCommand = (program)=>{
|
|
|
357
377
|
key: "buildOutput",
|
|
358
378
|
label: "Bundle assets 📦",
|
|
359
379
|
async handler (context) {
|
|
360
|
-
return build(
|
|
380
|
+
return build(createConfiguration({
|
|
361
381
|
minification: context.minification,
|
|
362
382
|
sourceMaps: context.sourceMaps,
|
|
363
383
|
standalone: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickbundle",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-d9c46be",
|
|
4
4
|
"description": "The zero-configuration transpiler and bundler for the web",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ayoub Adib",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"rollup-plugin-dts": "^6.1.1",
|
|
59
59
|
"rollup-plugin-node-externals": "^7.1.3",
|
|
60
60
|
"rollup-plugin-swc3": "^0.12.1",
|
|
61
|
-
"termost": "^
|
|
61
|
+
"termost": "^1.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/node": "22.9.0"
|