rolldown 0.15.1 → 1.0.0-beta.1
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/cjs/cli.cjs +43 -32
- package/dist/cjs/experimental-index.cjs +3 -3
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +3 -3
- package/dist/esm/cli.mjs +50 -39
- package/dist/esm/experimental-index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{chunk-BFvIen8E.cjs → chunk-qZFfknuJ.cjs} +2 -1
- package/dist/shared/{consola_36c0034f-B7L-radJ.cjs → consola_36c0034f-C_-uQ5ge.cjs} +8 -5
- package/dist/shared/{prompt-BiXtYIJ2.cjs → prompt-BNaEjAIz.cjs} +2 -2
- package/dist/shared/{src-BQ98i9JJ.mjs → src-Bb3zZkPW.mjs} +31 -19
- package/dist/shared/{src-CkH9jtTi.cjs → src-PS2X1Won.cjs} +89 -46
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/api/build.d.ts +4 -2
- package/dist/types/binding.d.ts +7 -2
- package/dist/types/index.d.ts +3 -4
- package/dist/types/log/logHandler.d.ts +1 -1
- package/dist/types/log/logger.d.ts +1 -1
- package/dist/types/log/logs.d.ts +2 -1
- package/dist/types/options/input-options.d.ts +10 -2
- package/dist/types/options/normalized-input-options.d.ts +1 -1
- package/dist/types/options/normalized-output-options.d.ts +1 -1
- package/dist/types/options/output-options.d.ts +3 -3
- package/dist/types/options/watch-options.d.ts +1 -1
- package/dist/types/plugin/bindingify-plugin.d.ts +1 -1
- package/dist/types/plugin/index.d.ts +6 -6
- package/dist/types/plugin/minimal-plugin-context.d.ts +1 -1
- package/dist/types/plugin/plugin-context.d.ts +1 -1
- package/dist/types/plugin/transform-plugin-context.d.ts +1 -1
- package/dist/types/types/misc.d.ts +40 -0
- package/dist/types/types/output-bundle.d.ts +2 -2
- package/dist/types/types/rolldown-options.d.ts +1 -1
- package/dist/types/types/rolldown-output.d.ts +8 -11
- package/dist/types/utils/bindingify-input-options.d.ts +1 -1
- package/dist/types/utils/create-bundler-option.d.ts +1 -1
- package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
- package/dist/types/utils/transform-rendered-chunk.d.ts +4 -4
- package/dist/types/utils/transform-rendered-module.d.ts +2 -2
- package/package.json +15 -15
- package/dist/types/rollup-types.d.ts +0 -1
- package/dist/types/rollup.d.ts +0 -1118
package/dist/cjs/cli.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
4
|
-
const require_consola_36c0034f = require('../shared/consola_36c0034f-
|
|
2
|
+
const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
|
|
3
|
+
const require_src = require('../shared/src-PS2X1Won.cjs');
|
|
4
|
+
const require_consola_36c0034f = require('../shared/consola_36c0034f-C_-uQ5ge.cjs');
|
|
5
5
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
6
6
|
const zod = require_chunk.__toESM(require("zod"));
|
|
7
7
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
@@ -364,12 +364,11 @@ async function bundleWithConfig(configPath, cliOptions) {
|
|
|
364
364
|
logger.error(`No configuration found at ${config}`);
|
|
365
365
|
process.exit(1);
|
|
366
366
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
367
|
+
if (cliOptions.watch) await watchInner(config, cliOptions);
|
|
368
|
+
else await bundleInner(config, cliOptions);
|
|
370
369
|
}
|
|
371
370
|
async function bundleWithCliOptions(cliOptions) {
|
|
372
|
-
if (cliOptions.output.dir) {
|
|
371
|
+
if (cliOptions.output.dir || cliOptions.output.file) {
|
|
373
372
|
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
374
373
|
await operation({}, cliOptions);
|
|
375
374
|
return;
|
|
@@ -393,15 +392,20 @@ async function bundleWithCliOptions(cliOptions) {
|
|
|
393
392
|
await build.close();
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
|
-
async function watchInner(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
395
|
+
async function watchInner(config, cliOptions) {
|
|
396
|
+
let normalizedConfig = require_src.arraify(config).map((option) => {
|
|
397
|
+
return {
|
|
398
|
+
...option,
|
|
399
|
+
...cliOptions.input,
|
|
400
|
+
output: require_src.arraify(option.output || {}).map((output) => {
|
|
401
|
+
return {
|
|
402
|
+
...output,
|
|
403
|
+
...cliOptions.output
|
|
404
|
+
};
|
|
405
|
+
})
|
|
406
|
+
};
|
|
404
407
|
});
|
|
408
|
+
const watcher = await require_src.watch(normalizedConfig);
|
|
405
409
|
onExit((code) => {
|
|
406
410
|
Promise.resolve(watcher.close()).finally(() => {
|
|
407
411
|
process.exit(typeof code === "number" ? code : 0);
|
|
@@ -429,25 +433,32 @@ async function watchInner(options$1, cliOptions) {
|
|
|
429
433
|
});
|
|
430
434
|
logger.log(`Waiting for changes...`);
|
|
431
435
|
}
|
|
432
|
-
async function bundleInner(
|
|
436
|
+
async function bundleInner(config, cliOptions) {
|
|
433
437
|
const startTime = node_perf_hooks.performance.now();
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
438
|
+
const result = [];
|
|
439
|
+
const configList = require_src.arraify(config);
|
|
440
|
+
for (const config$1 of configList) {
|
|
441
|
+
const outputList = require_src.arraify(config$1.output || {});
|
|
442
|
+
for (const output of outputList) {
|
|
443
|
+
const build = await require_src.rolldown({
|
|
444
|
+
...config$1,
|
|
445
|
+
...cliOptions.input
|
|
446
|
+
});
|
|
447
|
+
try {
|
|
448
|
+
result.push(await build.write({
|
|
449
|
+
...output,
|
|
450
|
+
...cliOptions.output
|
|
451
|
+
}));
|
|
452
|
+
} finally {
|
|
453
|
+
await build.close();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
450
456
|
}
|
|
457
|
+
result.forEach(printBundleOutputPretty);
|
|
458
|
+
logger.log(``);
|
|
459
|
+
const endTime = node_perf_hooks.performance.now();
|
|
460
|
+
const duration = endTime - startTime;
|
|
461
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
451
462
|
}
|
|
452
463
|
function printBundleOutputPretty(output) {
|
|
453
464
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
2
|
+
const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
|
|
3
|
+
const require_src = require('../shared/src-PS2X1Won.cjs');
|
|
4
4
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
5
|
|
|
6
6
|
//#region src/plugin/parallel-plugin.ts
|
|
@@ -54,7 +54,7 @@ function aliasPlugin(config) {
|
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/experimental-index.ts
|
|
57
|
-
var import_binding = require_chunk.__toESM(require_binding());
|
|
57
|
+
var import_binding = require_chunk.__toESM(require_src.require_binding());
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
60
|
exports.aliasPlugin = aliasPlugin
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('../shared/chunk-
|
|
3
|
-
const require_src = require('../shared/src-
|
|
2
|
+
const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
|
|
3
|
+
const require_src = require('../shared/src-PS2X1Won.cjs');
|
|
4
4
|
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
|
|
5
5
|
|
|
6
6
|
//#region src/parallel-plugin-worker.ts
|
|
7
|
-
var import_binding = require_chunk.__toESM(require_binding());
|
|
7
|
+
var import_binding = require_chunk.__toESM(require_src.require_binding());
|
|
8
8
|
const { registryId, pluginInfos, threadNumber } = node_worker_threads.workerData;
|
|
9
9
|
(async () => {
|
|
10
10
|
try {
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-
|
|
1
|
+
import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-Bb3zZkPW.mjs";
|
|
2
2
|
import { createConsola } from "../shared/consola_36c0034f-D9ce-831.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { ZodFirstPartyTypeKind, z } from "zod";
|
|
5
|
-
import path
|
|
5
|
+
import path from "node:path";
|
|
6
6
|
import process$1, { env } from "node:process";
|
|
7
7
|
import { performance } from "node:perf_hooks";
|
|
8
8
|
import * as tty from "tty";
|
|
@@ -314,7 +314,7 @@ async function bundleTsConfig(configFile) {
|
|
|
314
314
|
transform: {
|
|
315
315
|
filter: { id: /\.[cm]?[jt]s$/ },
|
|
316
316
|
async handler(code, id) {
|
|
317
|
-
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path
|
|
317
|
+
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};` + `const ${filenameVarName} = ${JSON.stringify(id)};` + `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
|
|
318
318
|
return {
|
|
319
319
|
code: injectValues + code,
|
|
320
320
|
map: null
|
|
@@ -324,7 +324,7 @@ async function bundleTsConfig(configFile) {
|
|
|
324
324
|
}]
|
|
325
325
|
});
|
|
326
326
|
const result = await bundle.write({
|
|
327
|
-
dir: path
|
|
327
|
+
dir: path.dirname(configFile),
|
|
328
328
|
format: "esm",
|
|
329
329
|
sourcemap: "inline",
|
|
330
330
|
entryFileNames: "rolldown.config.[hash].js"
|
|
@@ -343,7 +343,7 @@ const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
|
343
343
|
];
|
|
344
344
|
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
345
345
|
async function loadConfig(configPath) {
|
|
346
|
-
const ext = path
|
|
346
|
+
const ext = path.extname(configPath);
|
|
347
347
|
try {
|
|
348
348
|
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
|
|
349
349
|
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(configPath);
|
|
@@ -361,12 +361,11 @@ async function bundleWithConfig(configPath, cliOptions) {
|
|
|
361
361
|
logger.error(`No configuration found at ${config}`);
|
|
362
362
|
process.exit(1);
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
for (const config$1 of configList) await operation(config$1, cliOptions);
|
|
364
|
+
if (cliOptions.watch) await watchInner(config, cliOptions);
|
|
365
|
+
else await bundleInner(config, cliOptions);
|
|
367
366
|
}
|
|
368
367
|
async function bundleWithCliOptions(cliOptions) {
|
|
369
|
-
if (cliOptions.output.dir) {
|
|
368
|
+
if (cliOptions.output.dir || cliOptions.output.file) {
|
|
370
369
|
const operation = cliOptions.watch ? watchInner : bundleInner;
|
|
371
370
|
await operation({}, cliOptions);
|
|
372
371
|
return;
|
|
@@ -390,15 +389,20 @@ async function bundleWithCliOptions(cliOptions) {
|
|
|
390
389
|
await build.close();
|
|
391
390
|
}
|
|
392
391
|
}
|
|
393
|
-
async function watchInner(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
392
|
+
async function watchInner(config, cliOptions) {
|
|
393
|
+
let normalizedConfig = arraify(config).map((option) => {
|
|
394
|
+
return {
|
|
395
|
+
...option,
|
|
396
|
+
...cliOptions.input,
|
|
397
|
+
output: arraify(option.output || {}).map((output) => {
|
|
398
|
+
return {
|
|
399
|
+
...output,
|
|
400
|
+
...cliOptions.output
|
|
401
|
+
};
|
|
402
|
+
})
|
|
403
|
+
};
|
|
401
404
|
});
|
|
405
|
+
const watcher = await watch(normalizedConfig);
|
|
402
406
|
onExit((code) => {
|
|
403
407
|
Promise.resolve(watcher.close()).finally(() => {
|
|
404
408
|
process.exit(typeof code === "number" ? code : 0);
|
|
@@ -426,25 +430,32 @@ async function watchInner(options$1, cliOptions) {
|
|
|
426
430
|
});
|
|
427
431
|
logger.log(`Waiting for changes...`);
|
|
428
432
|
}
|
|
429
|
-
async function bundleInner(
|
|
433
|
+
async function bundleInner(config, cliOptions) {
|
|
430
434
|
const startTime = performance.now();
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
435
|
+
const result = [];
|
|
436
|
+
const configList = arraify(config);
|
|
437
|
+
for (const config$1 of configList) {
|
|
438
|
+
const outputList = arraify(config$1.output || {});
|
|
439
|
+
for (const output of outputList) {
|
|
440
|
+
const build = await rolldown({
|
|
441
|
+
...config$1,
|
|
442
|
+
...cliOptions.input
|
|
443
|
+
});
|
|
444
|
+
try {
|
|
445
|
+
result.push(await build.write({
|
|
446
|
+
...output,
|
|
447
|
+
...cliOptions.output
|
|
448
|
+
}));
|
|
449
|
+
} finally {
|
|
450
|
+
await build.close();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
447
453
|
}
|
|
454
|
+
result.forEach(printBundleOutputPretty);
|
|
455
|
+
logger.log(``);
|
|
456
|
+
const endTime = performance.now();
|
|
457
|
+
const duration = endTime - startTime;
|
|
458
|
+
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
448
459
|
}
|
|
449
460
|
function printBundleOutputPretty(output) {
|
|
450
461
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -499,9 +510,9 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
499
510
|
}
|
|
500
511
|
}
|
|
501
512
|
}
|
|
502
|
-
function withTrailingSlash(path$
|
|
503
|
-
if (path$
|
|
504
|
-
return path$
|
|
513
|
+
function withTrailingSlash(path$1) {
|
|
514
|
+
if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
|
|
515
|
+
return path$1;
|
|
505
516
|
}
|
|
506
517
|
function ms(duration) {
|
|
507
518
|
return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
|
|
@@ -1767,8 +1778,8 @@ else base[key] = value;
|
|
|
1767
1778
|
}
|
|
1768
1779
|
return base;
|
|
1769
1780
|
}
|
|
1770
|
-
function setNestedProperty(obj, path$
|
|
1771
|
-
const keys = path$
|
|
1781
|
+
function setNestedProperty(obj, path$1, value) {
|
|
1782
|
+
const keys = path$1.split(".");
|
|
1772
1783
|
let current = obj;
|
|
1773
1784
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
1774
1785
|
if (!current[keys[i]]) current[keys[i]] = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-
|
|
1
|
+
import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-Bb3zZkPW.mjs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/parallel-plugin.ts
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-
|
|
1
|
+
import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-Bb3zZkPW.mjs";
|
|
2
2
|
import { parentPort, workerData } from "node:worker_threads";
|
|
3
3
|
|
|
4
4
|
//#region src/parallel-plugin-worker.ts
|
|
@@ -31,7 +31,8 @@ Object.defineProperty(exports, '__commonJS', {
|
|
|
31
31
|
get: function () {
|
|
32
32
|
return __commonJS;
|
|
33
33
|
}
|
|
34
|
-
});
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, '__toESM', {
|
|
35
36
|
enumerable: true,
|
|
36
37
|
get: function () {
|
|
37
38
|
return __toESM;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('./chunk-
|
|
2
|
+
const require_chunk = require('./chunk-qZFfknuJ.cjs');
|
|
3
3
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
4
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
5
5
|
const node_util = require_chunk.__toESM(require("node:util"));
|
|
@@ -818,7 +818,7 @@ function createConsola(options = {}) {
|
|
|
818
818
|
stdout: process.stdout,
|
|
819
819
|
stderr: process.stderr,
|
|
820
820
|
prompt: (...args) => Promise.resolve().then(function() {
|
|
821
|
-
return require("./prompt-
|
|
821
|
+
return require("./prompt-BNaEjAIz.cjs");
|
|
822
822
|
}).then((m) => m.prompt(...args)),
|
|
823
823
|
reporters: options.reporters || [options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()],
|
|
824
824
|
...options
|
|
@@ -838,17 +838,20 @@ Object.defineProperty(exports, 'colors', {
|
|
|
838
838
|
get: function () {
|
|
839
839
|
return colors;
|
|
840
840
|
}
|
|
841
|
-
});
|
|
841
|
+
});
|
|
842
|
+
Object.defineProperty(exports, 'createConsola', {
|
|
842
843
|
enumerable: true,
|
|
843
844
|
get: function () {
|
|
844
845
|
return createConsola;
|
|
845
846
|
}
|
|
846
|
-
});
|
|
847
|
+
});
|
|
848
|
+
Object.defineProperty(exports, 'getDefaultExportFromCjs', {
|
|
847
849
|
enumerable: true,
|
|
848
850
|
get: function () {
|
|
849
851
|
return getDefaultExportFromCjs;
|
|
850
852
|
}
|
|
851
|
-
});
|
|
853
|
+
});
|
|
854
|
+
Object.defineProperty(exports, 'isUnicodeSupported', {
|
|
852
855
|
enumerable: true,
|
|
853
856
|
get: function () {
|
|
854
857
|
return isUnicodeSupported;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_chunk = require('./chunk-
|
|
3
|
-
const require_consola_36c0034f = require('./consola_36c0034f-
|
|
2
|
+
const require_chunk = require('./chunk-qZFfknuJ.cjs');
|
|
3
|
+
const require_consola_36c0034f = require('./consola_36c0034f-C_-uQ5ge.cjs');
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
6
6
|
const tty = require_chunk.__toESM(require("tty"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
2
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import path
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { Worker } from "node:worker_threads";
|
|
6
6
|
import { availableParallelism } from "node:os";
|
|
7
7
|
|
|
@@ -721,7 +721,13 @@ function locate(source, search, options) {
|
|
|
721
721
|
|
|
722
722
|
//#endregion
|
|
723
723
|
//#region src/log/logs.ts
|
|
724
|
-
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION";
|
|
724
|
+
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", MINIFY_WARNING = "MINIFY_WARNING";
|
|
725
|
+
function logMinifyWarning() {
|
|
726
|
+
return {
|
|
727
|
+
code: MINIFY_WARNING,
|
|
728
|
+
message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
|
|
729
|
+
};
|
|
730
|
+
}
|
|
725
731
|
function logInvalidLogPosition(pluginName) {
|
|
726
732
|
return {
|
|
727
733
|
code: INVALID_LOG_POSITION,
|
|
@@ -896,8 +902,8 @@ const getExtendedLogMessage = (log) => {
|
|
|
896
902
|
return prefix + log.message;
|
|
897
903
|
};
|
|
898
904
|
function relativeId(id) {
|
|
899
|
-
if (!path
|
|
900
|
-
return path
|
|
905
|
+
if (!path.isAbsolute(id)) return id;
|
|
906
|
+
return path.relative(path.resolve(), id);
|
|
901
907
|
}
|
|
902
908
|
|
|
903
909
|
//#endregion
|
|
@@ -1229,7 +1235,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
1229
1235
|
}
|
|
1230
1236
|
async load(options) {
|
|
1231
1237
|
const id = options.id;
|
|
1232
|
-
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(
|
|
1238
|
+
if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
1233
1239
|
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
1234
1240
|
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
1235
1241
|
const rawOptions = {
|
|
@@ -1322,7 +1328,7 @@ var TransformPluginContext = class extends PluginContext {
|
|
|
1322
1328
|
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1323
1329
|
e.id = this.moduleId;
|
|
1324
1330
|
e.hook = "transform";
|
|
1325
|
-
return error(logPluginError(normalizeLog(e),
|
|
1331
|
+
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
1326
1332
|
}
|
|
1327
1333
|
getCombinedSourcemap() {
|
|
1328
1334
|
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
@@ -2112,15 +2118,20 @@ function bindingifyInput(input) {
|
|
|
2112
2118
|
});
|
|
2113
2119
|
}
|
|
2114
2120
|
function bindingifyJsx(input) {
|
|
2121
|
+
if (input === false) return { type: "Disable" };
|
|
2115
2122
|
if (input) {
|
|
2116
|
-
|
|
2123
|
+
if (input.mode === "preserve") return { type: "Preserve" };
|
|
2124
|
+
const mode = input.mode ?? "automatic";
|
|
2117
2125
|
return {
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2126
|
+
type: "Enable",
|
|
2127
|
+
field0: {
|
|
2128
|
+
runtime: mode,
|
|
2129
|
+
importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
|
|
2130
|
+
pragma: input.factory,
|
|
2131
|
+
pragmaFrag: input.fragment,
|
|
2132
|
+
development: input.development,
|
|
2133
|
+
refresh: input.refresh
|
|
2134
|
+
}
|
|
2124
2135
|
};
|
|
2125
2136
|
}
|
|
2126
2137
|
}
|
|
@@ -2626,9 +2637,10 @@ async function createBundlerOptions(inputOptions, outputOptions) {
|
|
|
2626
2637
|
if (inputOptions.treeshake !== undefined) TreeshakingOptionsSchema.parse(inputOptions.treeshake);
|
|
2627
2638
|
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
2628
2639
|
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
2629
|
-
outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
|
|
2630
2640
|
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2631
2641
|
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
2642
|
+
outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
|
|
2643
|
+
if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
|
|
2632
2644
|
let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
|
|
2633
2645
|
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
2634
2646
|
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
@@ -2761,8 +2773,8 @@ else this.listeners.set(event, [listener]);
|
|
|
2761
2773
|
break;
|
|
2762
2774
|
case "change":
|
|
2763
2775
|
for (const listener of listeners) {
|
|
2764
|
-
const { path: path$
|
|
2765
|
-
await listener(path$
|
|
2776
|
+
const { path: path$1, kind } = event.watchChangeData();
|
|
2777
|
+
await listener(path$1, { event: kind });
|
|
2766
2778
|
}
|
|
2767
2779
|
break;
|
|
2768
2780
|
default: throw new Error(`Unknown event: ${event}`);
|
|
@@ -2803,8 +2815,8 @@ var Watcher = class {
|
|
|
2803
2815
|
}
|
|
2804
2816
|
};
|
|
2805
2817
|
async function createWatcher(emitter, input) {
|
|
2806
|
-
const options =
|
|
2807
|
-
const bundlerOptions = await Promise.all(options.map((option) =>
|
|
2818
|
+
const options = arraify(input);
|
|
2819
|
+
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map((output) => createBundlerOptions(option, output))).flat());
|
|
2808
2820
|
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
2809
2821
|
const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
2810
2822
|
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
@@ -2831,7 +2843,7 @@ const watch = (input) => {
|
|
|
2831
2843
|
|
|
2832
2844
|
//#endregion
|
|
2833
2845
|
//#region package.json
|
|
2834
|
-
var version = "0.
|
|
2846
|
+
var version = "1.0.0-beta.1";
|
|
2835
2847
|
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
2836
2848
|
|
|
2837
2849
|
//#endregion
|