rolldown 0.14.0-snapshot-ab438c3-20241121003459 → 0.14.0-snapshot-db4090b-20241123003628
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 +9 -5
- package/dist/cjs/experimental-index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +1 -1
- package/dist/esm/cli.mjs +9 -5
- 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/rolldown-binding.wasi.cjs +6 -8
- package/dist/shared/{src_index-Yt-qn7mE.cjs → src_index-WgTHG2Z9.cjs} +613 -649
- package/dist/shared/{src_index-k_6h6jvv.mjs → src_index-wJBYWP9G.mjs} +613 -649
- package/dist/types/binding.d.ts +10 -14
- package/dist/types/cli/arguments/schema.d.ts +60 -56
- package/dist/types/log/logger.d.ts +3 -3
- package/dist/types/options/bindingify-input-options.d.ts +3 -2
- package/dist/types/options/input-options.d.ts +128 -120
- package/dist/types/options/normalized-input-options.d.ts +1 -10
- package/dist/types/options/normalized-output-options.d.ts +1 -15
- package/dist/types/options/output-options.d.ts +12 -11
- package/dist/types/plugin/plugin-driver.d.ts +2 -3
- package/dist/types/treeshake/index.d.ts +0 -4
- package/dist/types/treeshake/module-side-effects.d.ts +23 -21
- package/dist/types/types/input-options.d.ts +8 -0
- package/dist/types/types/output-options.d.ts +12 -1
- package/dist/types/utils/error.d.ts +1 -0
- package/dist/types/utils/normalize-plugin-option.d.ts +2 -2
- package/dist/types/watcher.d.ts +2 -3
- package/package.json +15 -15
- package/dist/types/utils/normalize-input-options.d.ts +0 -3
- package/dist/types/utils/normalize-output-options.d.ts +0 -3
- package/dist/types/utils/normalize-tree-shake.d.ts +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { __commonJSMin, __toESM } = require("./chunk-JoMxl5V2.cjs");
|
|
2
|
-
const { default: path, default: path$1 } = __toESM(require("node:path"));
|
|
3
2
|
const { z, z: z$1 } = __toESM(require("zod"));
|
|
3
|
+
const { default: path, default: path$1 } = __toESM(require("node:path"));
|
|
4
4
|
const { Worker } = __toESM(require("node:worker_threads"));
|
|
5
5
|
const { availableParallelism } = __toESM(require("node:os"));
|
|
6
6
|
|
|
@@ -45,6 +45,60 @@ function transformToRenderedModule(bindingRenderedModule) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/utils/error.ts
|
|
50
|
+
function normalizeErrors(rawErrors) {
|
|
51
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), e, {stack: undefined}));
|
|
52
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
53
|
+
for (let i = 0; i < errors.length; i++) {
|
|
54
|
+
if (i >= 5) {
|
|
55
|
+
summary += "\n...";
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
summary += getErrorMessage(errors[i]) + "\n";
|
|
59
|
+
}
|
|
60
|
+
const wrapper = new Error(summary);
|
|
61
|
+
Object.defineProperty(wrapper, "errors", {
|
|
62
|
+
configurable: true,
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: () => errors,
|
|
65
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
value
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
return wrapper;
|
|
72
|
+
}
|
|
73
|
+
function getErrorMessage(e) {
|
|
74
|
+
let s = "";
|
|
75
|
+
if (e.plugin) {
|
|
76
|
+
s += `[plugin ${e.plugin}]`;
|
|
77
|
+
}
|
|
78
|
+
const id = e.id ?? e.loc?.file;
|
|
79
|
+
if (id) {
|
|
80
|
+
s += " " + id;
|
|
81
|
+
if (e.loc) {
|
|
82
|
+
s += `:${e.loc.line}:${e.loc.column}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (s) {
|
|
86
|
+
s += "\n";
|
|
87
|
+
}
|
|
88
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
89
|
+
s += message;
|
|
90
|
+
if (e.frame) {
|
|
91
|
+
s = joinNewLine(s, e.frame);
|
|
92
|
+
}
|
|
93
|
+
if (e.stack) {
|
|
94
|
+
s = joinNewLine(s, e.stack.replace(message, ""));
|
|
95
|
+
}
|
|
96
|
+
return s;
|
|
97
|
+
}
|
|
98
|
+
function joinNewLine(s1, s2) {
|
|
99
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
100
|
+
}
|
|
101
|
+
|
|
48
102
|
//#endregion
|
|
49
103
|
//#region src/utils/transform-to-rollup-output.ts
|
|
50
104
|
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
@@ -125,56 +179,8 @@ function transformToRollupOutput(output, changed) {
|
|
|
125
179
|
function handleOutputErrors(output) {
|
|
126
180
|
const rawErrors = output.errors;
|
|
127
181
|
if (rawErrors.length > 0) {
|
|
128
|
-
|
|
129
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
130
|
-
for (let i = 0; i < errors.length; i++) {
|
|
131
|
-
if (i >= 5) {
|
|
132
|
-
summary += "\n...";
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
summary += getErrorMessage(errors[i]) + "\n";
|
|
136
|
-
}
|
|
137
|
-
const wrapper = new Error(summary);
|
|
138
|
-
Object.defineProperty(wrapper, "errors", {
|
|
139
|
-
configurable: true,
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: () => errors,
|
|
142
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
143
|
-
configurable: true,
|
|
144
|
-
enumerable: true,
|
|
145
|
-
value
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
throw wrapper;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function getErrorMessage(e) {
|
|
152
|
-
let s = "";
|
|
153
|
-
if (e.plugin) {
|
|
154
|
-
s += `[plugin ${e.plugin}]`;
|
|
155
|
-
}
|
|
156
|
-
const id = e.id ?? e.loc?.file;
|
|
157
|
-
if (id) {
|
|
158
|
-
s += " " + id;
|
|
159
|
-
if (e.loc) {
|
|
160
|
-
s += `:${e.loc.line}:${e.loc.column}`;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (s) {
|
|
164
|
-
s += "\n";
|
|
165
|
-
}
|
|
166
|
-
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
167
|
-
s += message;
|
|
168
|
-
if (e.frame) {
|
|
169
|
-
s = joinNewLine(s, e.frame);
|
|
182
|
+
throw normalizeErrors(rawErrors);
|
|
170
183
|
}
|
|
171
|
-
if (e.stack) {
|
|
172
|
-
s = joinNewLine(s, e.stack.replace(message, ""));
|
|
173
|
-
}
|
|
174
|
-
return s;
|
|
175
|
-
}
|
|
176
|
-
function joinNewLine(s1, s2) {
|
|
177
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
178
184
|
}
|
|
179
185
|
function transformToOutputBundle(output, changed) {
|
|
180
186
|
const bundle = Object.fromEntries((transformToRollupOutput(output, changed)).output.map((item) => [item.fileName, item,]));
|
|
@@ -566,14 +572,13 @@ var require_binding = __commonJSMin((exports, module) => {
|
|
|
566
572
|
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
|
|
567
573
|
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
|
|
568
574
|
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
|
|
569
|
-
module.exports.
|
|
575
|
+
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
570
576
|
module.exports.Bundler = nativeBinding.Bundler;
|
|
571
577
|
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
|
|
572
578
|
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
573
579
|
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
574
580
|
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
575
581
|
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
576
|
-
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
577
582
|
module.exports.isCallableCompatibleBuiltinPlugin = nativeBinding.isCallableCompatibleBuiltinPlugin;
|
|
578
583
|
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
579
584
|
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
@@ -607,58 +612,6 @@ function unsupported(info) {
|
|
|
607
612
|
}
|
|
608
613
|
function noop(..._args) {}
|
|
609
614
|
|
|
610
|
-
//#endregion
|
|
611
|
-
//#region src/utils/normalize-hook.ts
|
|
612
|
-
function normalizeHook(hook) {
|
|
613
|
-
if (typeof hook === "function" || typeof hook === "string") {
|
|
614
|
-
return {
|
|
615
|
-
handler: hook,
|
|
616
|
-
options: {},
|
|
617
|
-
meta: {}
|
|
618
|
-
};
|
|
619
|
-
} else if (typeof hook === "object" && hook !== null) {
|
|
620
|
-
const { handler: handler, order: order,...options } = hook;
|
|
621
|
-
return {
|
|
622
|
-
handler,
|
|
623
|
-
options,
|
|
624
|
-
meta: {order}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
unreachable("Invalid hook type");
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region src/utils/transform-sourcemap.ts
|
|
632
|
-
function isEmptySourcemapFiled(array) {
|
|
633
|
-
if (!array) {
|
|
634
|
-
return true;
|
|
635
|
-
}
|
|
636
|
-
if (array.length === 0 || !array[0]) {
|
|
637
|
-
return true;
|
|
638
|
-
}
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region src/utils/transform-module-info.ts
|
|
644
|
-
function transformModuleInfo(info, option) {
|
|
645
|
-
return {
|
|
646
|
-
get ast() {
|
|
647
|
-
return unsupported("ModuleInfo#ast");
|
|
648
|
-
},
|
|
649
|
-
get code() {
|
|
650
|
-
return info.code;
|
|
651
|
-
},
|
|
652
|
-
id: info.id,
|
|
653
|
-
importers: info.importers,
|
|
654
|
-
dynamicImporters: info.dynamicImporters,
|
|
655
|
-
importedIds: info.importedIds,
|
|
656
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
657
|
-
isEntry: info.isEntry,
|
|
658
|
-
...option
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
|
|
662
615
|
//#endregion
|
|
663
616
|
//#region src/log/logging.ts
|
|
664
617
|
const LogLevelSchema = ((z$1.literal("info")).or(z$1.literal("debug"))).or(z$1.literal("warn"));
|
|
@@ -846,107 +799,248 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
|
846
799
|
}
|
|
847
800
|
|
|
848
801
|
//#endregion
|
|
849
|
-
//#region src/utils/normalize-
|
|
850
|
-
function
|
|
851
|
-
if (
|
|
852
|
-
return
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
return undefined;
|
|
802
|
+
//#region src/utils/normalize-hook.ts
|
|
803
|
+
function normalizeHook(hook) {
|
|
804
|
+
if (typeof hook === "function" || typeof hook === "string") {
|
|
805
|
+
return {
|
|
806
|
+
handler: hook,
|
|
807
|
+
options: {},
|
|
808
|
+
meta: {}
|
|
809
|
+
};
|
|
810
|
+
} else if (typeof hook === "object" && hook !== null) {
|
|
811
|
+
const { handler: handler, order: order,...options } = hook;
|
|
812
|
+
return {
|
|
813
|
+
handler,
|
|
814
|
+
options,
|
|
815
|
+
meta: {order}
|
|
816
|
+
};
|
|
865
817
|
}
|
|
866
|
-
|
|
867
|
-
jsxInject: config?.jsxInject,
|
|
868
|
-
exclude: normalizedStringOrRegex(config.exclude),
|
|
869
|
-
include: normalizedStringOrRegex(config.include),
|
|
870
|
-
targets: config.targets
|
|
871
|
-
};
|
|
872
|
-
return normalizedConfig;
|
|
818
|
+
unreachable("Invalid hook type");
|
|
873
819
|
}
|
|
874
820
|
|
|
875
821
|
//#endregion
|
|
876
|
-
//#region src/
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
822
|
+
//#region src/log/logger.ts
|
|
823
|
+
class MinimalPluginContext {
|
|
824
|
+
info;
|
|
825
|
+
warn;
|
|
826
|
+
debug;
|
|
827
|
+
meta;
|
|
828
|
+
error;
|
|
829
|
+
constructor(options, plugin) {
|
|
830
|
+
const onLog = options.onLog;
|
|
831
|
+
const pluginName = plugin.name || "unknown";
|
|
832
|
+
const logLevel = options.logLevel || LOG_LEVEL_INFO;
|
|
833
|
+
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
834
|
+
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
835
|
+
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
836
|
+
this.error = (e) => {
|
|
837
|
+
return error(logPluginError(normalizeLog(e), pluginName));
|
|
838
|
+
};
|
|
839
|
+
this.meta = {
|
|
840
|
+
rollupVersion: "4.23.0",
|
|
841
|
+
rolldownVersion: VERSION,
|
|
842
|
+
watchMode: false
|
|
843
|
+
};
|
|
884
844
|
}
|
|
885
845
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
846
|
+
function getLogger(plugins, onLog, logLevel) {
|
|
847
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
848
|
+
const logger = (level, log, skipped = new Set()) => {
|
|
849
|
+
const logPriority = logLevelPriority[level];
|
|
850
|
+
if (logPriority < minimalPriority) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
for (const plugin of getSortedPlugins("onLog", plugins)) {
|
|
854
|
+
if (skipped.has(plugin)) continue;
|
|
855
|
+
const { onLog: pluginOnLog } = plugin;
|
|
856
|
+
if (pluginOnLog) {
|
|
857
|
+
const getLogHandler$1 = (level$1) => {
|
|
858
|
+
if (logLevelPriority[level$1] < minimalPriority) {
|
|
859
|
+
return () => {};
|
|
860
|
+
}
|
|
861
|
+
return (log$1) => logger(level$1, normalizeLog(log$1), (new Set(skipped)).add(plugin));
|
|
862
|
+
};
|
|
863
|
+
const handler = "handler"in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
864
|
+
if (handler.call({
|
|
865
|
+
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
866
|
+
error: (log$1) => error(normalizeLog(log$1)),
|
|
867
|
+
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
868
|
+
meta: {
|
|
869
|
+
rollupVersion: "4.23.0",
|
|
870
|
+
rolldownVersion: VERSION,
|
|
871
|
+
watchMode: false
|
|
872
|
+
},
|
|
873
|
+
warn: getLogHandler$1(LOG_LEVEL_WARN)
|
|
874
|
+
}, level, log) === false) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
onLog(level, log);
|
|
880
|
+
};
|
|
881
|
+
return logger;
|
|
890
882
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
883
|
+
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
884
|
+
const { onwarn: onwarn, onLog: onLog } = config;
|
|
885
|
+
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
886
|
+
if (onLog) {
|
|
887
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
888
|
+
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
889
|
+
if (level$1 === LOG_LEVEL_ERROR) {
|
|
890
|
+
return error(normalizeLog(handledLog));
|
|
891
|
+
}
|
|
892
|
+
if (logLevelPriority[level$1] >= minimalPriority) {
|
|
893
|
+
defaultOnLog(level$1, normalizeLog(handledLog));
|
|
894
|
+
}
|
|
895
|
+
});
|
|
894
896
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
897
|
+
return defaultOnLog;
|
|
898
|
+
};
|
|
899
|
+
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
900
|
+
if (level === LOG_LEVEL_WARN) {
|
|
901
|
+
onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
902
|
+
} else {
|
|
903
|
+
printLog(level, log);
|
|
904
|
+
}
|
|
905
|
+
} : printLog;
|
|
906
|
+
const addLogToString = (log) => {
|
|
907
|
+
Object.defineProperty(log, "toString", {
|
|
908
|
+
value: () => getExtendedLogMessage(log),
|
|
909
|
+
writable: true
|
|
910
|
+
});
|
|
911
|
+
return log;
|
|
912
|
+
};
|
|
913
|
+
const defaultPrintLog = (level, log) => {
|
|
914
|
+
const message = getExtendedLogMessage(log);
|
|
915
|
+
switch (level) {
|
|
916
|
+
case LOG_LEVEL_WARN: {
|
|
917
|
+
return console.warn(message);
|
|
918
|
+
}
|
|
919
|
+
case LOG_LEVEL_DEBUG: {
|
|
920
|
+
return console.debug(message);
|
|
921
|
+
}
|
|
922
|
+
default: {
|
|
923
|
+
return console.info(message);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const getExtendedLogMessage = (log) => {
|
|
928
|
+
let prefix = "";
|
|
929
|
+
if (log.plugin) {
|
|
930
|
+
prefix += `(${log.plugin} plugin) `;
|
|
931
|
+
}
|
|
932
|
+
if (log.loc) {
|
|
933
|
+
prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
934
|
+
}
|
|
935
|
+
return prefix + log.message;
|
|
936
|
+
};
|
|
937
|
+
function relativeId(id) {
|
|
938
|
+
if (!path$1.isAbsolute(id)) return id;
|
|
939
|
+
return path$1.relative(path$1.resolve(), id);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
944
|
+
function normalizedStringOrRegex(pattern) {
|
|
945
|
+
if (!pattern) {
|
|
946
|
+
return undefined;
|
|
947
|
+
}
|
|
948
|
+
if (!Array.isArray(pattern)) {
|
|
949
|
+
pattern = [pattern];
|
|
950
|
+
}
|
|
951
|
+
return pattern;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/options/normalized-ecma-transform-plugin-config.ts
|
|
956
|
+
function normalizeEcmaTransformPluginConfig(config) {
|
|
957
|
+
if (!config) {
|
|
958
|
+
return undefined;
|
|
959
|
+
}
|
|
960
|
+
let normalizedConfig = {
|
|
961
|
+
jsxInject: config?.jsxInject,
|
|
962
|
+
exclude: normalizedStringOrRegex(config.exclude),
|
|
963
|
+
include: normalizedStringOrRegex(config.include),
|
|
964
|
+
targets: config.targets
|
|
965
|
+
};
|
|
966
|
+
return normalizedConfig;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region src/plugin/builtin-plugin.ts
|
|
971
|
+
var import_binding$5 = __toESM(require_binding());
|
|
972
|
+
class BuiltinPlugin {
|
|
973
|
+
constructor(name, options) {
|
|
974
|
+
this.name = name;
|
|
975
|
+
this.options = options;
|
|
976
|
+
this.name = name;
|
|
977
|
+
this.options = options;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
class ModulePreloadPolyfillPlugin extends BuiltinPlugin {
|
|
981
|
+
constructor(config) {
|
|
982
|
+
super(import_binding$5.BindingBuiltinPluginName.ModulePreloadPolyfillPlugin, config);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
class DynamicImportVarsPlugin extends BuiltinPlugin {
|
|
986
|
+
constructor() {
|
|
987
|
+
super(import_binding$5.BindingBuiltinPluginName.DynamicImportVarsPlugin);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
class ImportGlobPlugin extends BuiltinPlugin {
|
|
991
|
+
constructor(config) {
|
|
992
|
+
super(import_binding$5.BindingBuiltinPluginName.ImportGlobPlugin, config);
|
|
899
993
|
}
|
|
900
994
|
}
|
|
901
995
|
class ManifestPlugin extends BuiltinPlugin {
|
|
902
996
|
constructor(config) {
|
|
903
|
-
super(import_binding$
|
|
997
|
+
super(import_binding$5.BindingBuiltinPluginName.ManifestPlugin, config);
|
|
904
998
|
}
|
|
905
999
|
}
|
|
906
1000
|
class WasmHelperPlugin extends BuiltinPlugin {
|
|
907
1001
|
constructor() {
|
|
908
|
-
super(import_binding$
|
|
1002
|
+
super(import_binding$5.BindingBuiltinPluginName.WasmHelperPlugin);
|
|
909
1003
|
}
|
|
910
1004
|
}
|
|
911
1005
|
class WasmFallbackPlugin extends BuiltinPlugin {
|
|
912
1006
|
constructor() {
|
|
913
|
-
super(import_binding$
|
|
1007
|
+
super(import_binding$5.BindingBuiltinPluginName.WasmFallbackPlugin);
|
|
914
1008
|
}
|
|
915
1009
|
}
|
|
916
1010
|
class LoadFallbackPlugin extends BuiltinPlugin {
|
|
917
1011
|
constructor() {
|
|
918
|
-
super(import_binding$
|
|
1012
|
+
super(import_binding$5.BindingBuiltinPluginName.LoadFallbackPlugin);
|
|
919
1013
|
}
|
|
920
1014
|
}
|
|
921
1015
|
class AliasPlugin extends BuiltinPlugin {
|
|
922
1016
|
constructor(config) {
|
|
923
|
-
super(import_binding$
|
|
1017
|
+
super(import_binding$5.BindingBuiltinPluginName.AliasPlugin, config);
|
|
924
1018
|
}
|
|
925
1019
|
}
|
|
926
1020
|
class TransformPlugin extends BuiltinPlugin {
|
|
927
1021
|
constructor(config) {
|
|
928
1022
|
let normalizedConfig = normalizeEcmaTransformPluginConfig(config);
|
|
929
|
-
super(import_binding$
|
|
1023
|
+
super(import_binding$5.BindingBuiltinPluginName.TransformPlugin, normalizedConfig);
|
|
930
1024
|
}
|
|
931
1025
|
}
|
|
932
1026
|
class JsonPlugin extends BuiltinPlugin {
|
|
933
1027
|
constructor(config) {
|
|
934
|
-
super(import_binding$
|
|
1028
|
+
super(import_binding$5.BindingBuiltinPluginName.JsonPlugin, config);
|
|
935
1029
|
}
|
|
936
1030
|
}
|
|
937
1031
|
class BuildImportAnalysisPlugin extends BuiltinPlugin {
|
|
938
1032
|
constructor(config) {
|
|
939
|
-
super(import_binding$
|
|
1033
|
+
super(import_binding$5.BindingBuiltinPluginName.BuildImportAnalysisPlugin, config);
|
|
940
1034
|
}
|
|
941
1035
|
}
|
|
942
1036
|
class ReplacePlugin extends BuiltinPlugin {
|
|
943
1037
|
constructor(config) {
|
|
944
|
-
super(import_binding$
|
|
1038
|
+
super(import_binding$5.BindingBuiltinPluginName.ReplacePlugin, config);
|
|
945
1039
|
}
|
|
946
1040
|
}
|
|
947
1041
|
class ViteResolvePlugin extends BuiltinPlugin {
|
|
948
1042
|
constructor(config) {
|
|
949
|
-
super(import_binding$
|
|
1043
|
+
super(import_binding$5.BindingBuiltinPluginName.ViteResolvePlugin, config);
|
|
950
1044
|
}
|
|
951
1045
|
}
|
|
952
1046
|
function modulePreloadPolyfillPlugin(config) {
|
|
@@ -995,10 +1089,10 @@ function replacePlugin(values = {}, options = {}) {
|
|
|
995
1089
|
});
|
|
996
1090
|
}
|
|
997
1091
|
function isCallableCompatibleBuiltinPlugin(plugin) {
|
|
998
|
-
return plugin instanceof BuiltinPlugin && (0, import_binding$
|
|
1092
|
+
return plugin instanceof BuiltinPlugin && (0, import_binding$5.isCallableCompatibleBuiltinPlugin)(bindingifyBuiltInPlugin(plugin));
|
|
999
1093
|
}
|
|
1000
1094
|
function makeBuiltinPluginCallable(plugin) {
|
|
1001
|
-
let callablePlugin = new import_binding$
|
|
1095
|
+
let callablePlugin = new import_binding$5.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
1002
1096
|
const wrappedPlugin = {_original: callablePlugin};
|
|
1003
1097
|
for (const key in callablePlugin) {
|
|
1004
1098
|
if (key === "name") {
|
|
@@ -1012,7 +1106,7 @@ function makeBuiltinPluginCallable(plugin) {
|
|
|
1012
1106
|
return wrappedPlugin;
|
|
1013
1107
|
}
|
|
1014
1108
|
function isCallableBuiltinPlugin(plugin) {
|
|
1015
|
-
return "_original"in plugin && plugin._original instanceof import_binding$
|
|
1109
|
+
return "_original"in plugin && plugin._original instanceof import_binding$5.BindingCallableBuiltinPlugin;
|
|
1016
1110
|
}
|
|
1017
1111
|
function bindingifyBuiltInPlugin(plugin) {
|
|
1018
1112
|
return {
|
|
@@ -1051,9 +1145,9 @@ class PluginDriver {
|
|
|
1051
1145
|
}
|
|
1052
1146
|
return inputOptions;
|
|
1053
1147
|
}
|
|
1054
|
-
callOutputOptionsHook(
|
|
1055
|
-
const
|
|
1056
|
-
for (const plugin of
|
|
1148
|
+
callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
1149
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
1150
|
+
for (const plugin of sortedPlugins) {
|
|
1057
1151
|
const options = plugin.outputOptions;
|
|
1058
1152
|
if (options) {
|
|
1059
1153
|
const { handler: handler } = normalizeHook(options);
|
|
@@ -1104,134 +1198,60 @@ function getSortedPlugins(hookName, plugins) {
|
|
|
1104
1198
|
}
|
|
1105
1199
|
|
|
1106
1200
|
//#endregion
|
|
1107
|
-
//#region src/
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1201
|
+
//#region src/treeshake/module-side-effects.ts
|
|
1202
|
+
const ModuleSideEffectsRuleSchema = (z.object({
|
|
1203
|
+
test: (z.instanceof(RegExp)).optional(),
|
|
1204
|
+
external: (z.boolean()).optional(),
|
|
1205
|
+
sideEffects: z.boolean()
|
|
1206
|
+
})).refine((data) => {
|
|
1207
|
+
return data.test !== undefined || data.external !== undefined;
|
|
1208
|
+
}, "Either `test` or `external` should be set.");
|
|
1209
|
+
const ModuleSideEffectsOptionSchema = ((z.boolean()).or(z.array(ModuleSideEffectsRuleSchema))).or(z.literal("no-external"));
|
|
1210
|
+
const TreeshakingOptionsSchema = ((z.object({
|
|
1211
|
+
moduleSideEffects: ModuleSideEffectsOptionSchema.optional(),
|
|
1212
|
+
annotations: (z.boolean()).optional()
|
|
1213
|
+
})).passthrough()).or(z.boolean());
|
|
1214
|
+
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region src/utils/transform-sourcemap.ts
|
|
1217
|
+
function isEmptySourcemapFiled(array) {
|
|
1218
|
+
if (!array) {
|
|
1219
|
+
return true;
|
|
1220
|
+
}
|
|
1221
|
+
if (array.length === 0 || !array[0]) {
|
|
1222
|
+
return true;
|
|
1129
1223
|
}
|
|
1224
|
+
return false;
|
|
1130
1225
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
if (handler.call({
|
|
1150
|
-
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
1151
|
-
error: (log$1) => error(normalizeLog(log$1)),
|
|
1152
|
-
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
1153
|
-
meta: {
|
|
1154
|
-
rollupVersion: "4.23.0",
|
|
1155
|
-
rolldownVersion: VERSION,
|
|
1156
|
-
watchMode: false
|
|
1157
|
-
},
|
|
1158
|
-
warn: getLogHandler$1(LOG_LEVEL_WARN)
|
|
1159
|
-
}, level, log) === false) {
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
onLog(level, log);
|
|
1226
|
+
|
|
1227
|
+
//#endregion
|
|
1228
|
+
//#region src/utils/transform-module-info.ts
|
|
1229
|
+
function transformModuleInfo(info, option) {
|
|
1230
|
+
return {
|
|
1231
|
+
get ast() {
|
|
1232
|
+
return unsupported("ModuleInfo#ast");
|
|
1233
|
+
},
|
|
1234
|
+
get code() {
|
|
1235
|
+
return info.code;
|
|
1236
|
+
},
|
|
1237
|
+
id: info.id,
|
|
1238
|
+
importers: info.importers,
|
|
1239
|
+
dynamicImporters: info.dynamicImporters,
|
|
1240
|
+
importedIds: info.importedIds,
|
|
1241
|
+
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
1242
|
+
isEntry: info.isEntry,
|
|
1243
|
+
...option
|
|
1165
1244
|
};
|
|
1166
|
-
return logger;
|
|
1167
|
-
}
|
|
1168
|
-
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
1169
|
-
const { onwarn: onwarn, onLog: onLog } = config;
|
|
1170
|
-
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
1171
|
-
if (onLog) {
|
|
1172
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
1173
|
-
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
1174
|
-
if (level$1 === LOG_LEVEL_ERROR) {
|
|
1175
|
-
return error(normalizeLog(handledLog));
|
|
1176
|
-
}
|
|
1177
|
-
if (logLevelPriority[level$1] >= minimalPriority) {
|
|
1178
|
-
defaultOnLog(level$1, normalizeLog(handledLog));
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
return defaultOnLog;
|
|
1183
|
-
};
|
|
1184
|
-
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
1185
|
-
if (level === LOG_LEVEL_WARN) {
|
|
1186
|
-
onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
1187
|
-
} else {
|
|
1188
|
-
printLog(level, log);
|
|
1189
|
-
}
|
|
1190
|
-
} : printLog;
|
|
1191
|
-
const addLogToString = (log) => {
|
|
1192
|
-
Object.defineProperty(log, "toString", {
|
|
1193
|
-
value: () => getExtendedLogMessage(log),
|
|
1194
|
-
writable: true
|
|
1195
|
-
});
|
|
1196
|
-
return log;
|
|
1197
|
-
};
|
|
1198
|
-
const defaultPrintLog = (level, log) => {
|
|
1199
|
-
const message = getExtendedLogMessage(log);
|
|
1200
|
-
switch (level) {
|
|
1201
|
-
case LOG_LEVEL_WARN: {
|
|
1202
|
-
return console.warn(message);
|
|
1203
|
-
}
|
|
1204
|
-
case LOG_LEVEL_DEBUG: {
|
|
1205
|
-
return console.debug(message);
|
|
1206
|
-
}
|
|
1207
|
-
default: {
|
|
1208
|
-
return console.info(message);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
|
-
const getExtendedLogMessage = (log) => {
|
|
1213
|
-
let prefix = "";
|
|
1214
|
-
if (log.plugin) {
|
|
1215
|
-
prefix += `(${log.plugin} plugin) `;
|
|
1216
|
-
}
|
|
1217
|
-
if (log.loc) {
|
|
1218
|
-
prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
1219
|
-
}
|
|
1220
|
-
return prefix + log.message;
|
|
1221
|
-
};
|
|
1222
|
-
function relativeId(id) {
|
|
1223
|
-
if (!path$1.isAbsolute(id)) return id;
|
|
1224
|
-
return path$1.relative(path$1.resolve(), id);
|
|
1225
1245
|
}
|
|
1226
1246
|
|
|
1227
1247
|
//#endregion
|
|
1228
1248
|
//#region src/utils/transform-side-effects.ts
|
|
1229
|
-
var import_binding$
|
|
1249
|
+
var import_binding$4 = __toESM(require_binding());
|
|
1230
1250
|
function bindingifySideEffects(sideEffects) {
|
|
1231
1251
|
switch (sideEffects) {
|
|
1232
|
-
case true: return import_binding$
|
|
1233
|
-
case false: return import_binding$
|
|
1234
|
-
case "no-treeshake": return import_binding$
|
|
1252
|
+
case true: return import_binding$4.BindingHookSideEffects.True;
|
|
1253
|
+
case false: return import_binding$4.BindingHookSideEffects.False;
|
|
1254
|
+
case "no-treeshake": return import_binding$4.BindingHookSideEffects.NoTreeshake;
|
|
1235
1255
|
case null:
|
|
1236
1256
|
case undefined: return undefined;
|
|
1237
1257
|
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
@@ -1346,14 +1366,14 @@ class TransformPluginContext extends PluginContext {
|
|
|
1346
1366
|
|
|
1347
1367
|
//#endregion
|
|
1348
1368
|
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1349
|
-
var import_binding$
|
|
1369
|
+
var import_binding$3 = __toESM(require_binding());
|
|
1350
1370
|
function bindingifyPluginHookMeta(options) {
|
|
1351
1371
|
return {order: bindingPluginOrder(options.order)};
|
|
1352
1372
|
}
|
|
1353
1373
|
function bindingPluginOrder(order) {
|
|
1354
1374
|
switch (order) {
|
|
1355
|
-
case "post": return import_binding$
|
|
1356
|
-
case "pre": return import_binding$
|
|
1375
|
+
case "post": return import_binding$3.BindingPluginOrder.Post;
|
|
1376
|
+
case "pre": return import_binding$3.BindingPluginOrder.Pre;
|
|
1357
1377
|
case null:
|
|
1358
1378
|
case undefined: return undefined;
|
|
1359
1379
|
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
@@ -1558,21 +1578,10 @@ function bindingifyLoad(plugin, normalized_options, pluginContextData) {
|
|
|
1558
1578
|
if (typeof ret === "string") {
|
|
1559
1579
|
return {code: ret};
|
|
1560
1580
|
}
|
|
1561
|
-
|
|
1562
|
-
return {
|
|
1563
|
-
code: ret.code,
|
|
1564
|
-
moduleType: ret.moduleType
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
1568
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
1569
|
-
const directory = path.dirname(id) || ".";
|
|
1570
|
-
const sourceRoot = map.sourceRoot || ".";
|
|
1571
|
-
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
1572
|
-
}
|
|
1581
|
+
let map = preProcessSourceMap(ret, id);
|
|
1573
1582
|
const result = {
|
|
1574
1583
|
code: ret.code,
|
|
1575
|
-
map: bindingifySourcemap$1(map),
|
|
1584
|
+
map: map !== undefined ? bindingifySourcemap$1(map) : undefined,
|
|
1576
1585
|
moduleType: ret.moduleType
|
|
1577
1586
|
};
|
|
1578
1587
|
if (ret.moduleSideEffects !== null) {
|
|
@@ -1588,6 +1597,18 @@ function bindingifyLoad(plugin, normalized_options, pluginContextData) {
|
|
|
1588
1597
|
filter: bindingifyLoadFilter(options.filter)
|
|
1589
1598
|
};
|
|
1590
1599
|
}
|
|
1600
|
+
function preProcessSourceMap(ret, id) {
|
|
1601
|
+
if (!ret.map) {
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
1605
|
+
if (!isEmptySourcemapFiled(map.sources)) {
|
|
1606
|
+
const directory = path.dirname(id) || ".";
|
|
1607
|
+
const sourceRoot = map.sourceRoot || ".";
|
|
1608
|
+
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
1609
|
+
}
|
|
1610
|
+
return map;
|
|
1611
|
+
}
|
|
1591
1612
|
function bindingifyModuleParsed(plugin, options, pluginContextData) {
|
|
1592
1613
|
const hook = plugin.moduleParsed;
|
|
1593
1614
|
if (!hook) {
|
|
@@ -1957,66 +1978,83 @@ class PluginContextData {
|
|
|
1957
1978
|
|
|
1958
1979
|
//#endregion
|
|
1959
1980
|
//#region src/options/bindingify-input-options.ts
|
|
1960
|
-
var import_binding$
|
|
1961
|
-
function bindingifyInputOptions(
|
|
1981
|
+
var import_binding$2 = __toESM(require_binding());
|
|
1982
|
+
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions) {
|
|
1962
1983
|
const pluginContextData = new PluginContextData();
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
1984
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
1985
|
+
const onLog = inputOptions.onLog = getLogger(getObjectPlugins(rawPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
1986
|
+
const plugins = rawPlugins.map((plugin) => {
|
|
1987
|
+
if ("_parallel"in plugin) {
|
|
1988
|
+
return undefined;
|
|
1989
|
+
}
|
|
1990
|
+
if (plugin instanceof BuiltinPlugin) {
|
|
1991
|
+
return bindingifyBuiltInPlugin(plugin);
|
|
1992
|
+
}
|
|
1993
|
+
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData);
|
|
1994
|
+
});
|
|
1995
|
+
return {
|
|
1996
|
+
input: bindingifyInput(inputOptions.input),
|
|
1997
|
+
plugins,
|
|
1998
|
+
cwd: inputOptions.cwd ?? process.cwd(),
|
|
1999
|
+
external: bindingifyExternal(inputOptions.external),
|
|
2000
|
+
resolve: bindingifyResolve(inputOptions.resolve),
|
|
2001
|
+
platform: inputOptions.platform,
|
|
2002
|
+
shimMissingExports: inputOptions.shimMissingExports,
|
|
2003
|
+
logLevel: bindingifyLogLevel(logLevel),
|
|
2004
|
+
onLog,
|
|
2005
|
+
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
2006
|
+
moduleTypes: inputOptions.moduleTypes,
|
|
2007
|
+
define: inputOptions.define ? Object.entries(inputOptions.define) : undefined,
|
|
2008
|
+
inject: bindingifyInject(inputOptions.inject),
|
|
2009
|
+
experimental: {
|
|
2010
|
+
strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
|
|
2011
|
+
disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
|
|
2012
|
+
viteMode: inputOptions.experimental?.viteMode
|
|
2013
|
+
},
|
|
2014
|
+
profilerNames: inputOptions?.profilerNames,
|
|
2015
|
+
jsx: bindingifyJsx(inputOptions.jsx),
|
|
2016
|
+
watch: bindingifyWatch(inputOptions.watch),
|
|
2017
|
+
dropLabels: inputOptions.dropLabels
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
function bindingifyExternal(external) {
|
|
2021
|
+
if (external) {
|
|
2022
|
+
if (typeof external === "function") {
|
|
2023
|
+
return (id, importer, isResolved) => {
|
|
2024
|
+
if (id.startsWith("\0")) return false;
|
|
2025
|
+
return external(id, importer, isResolved) ?? false;
|
|
2005
2026
|
};
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2027
|
+
}
|
|
2028
|
+
const externalArr = arraify(external);
|
|
2029
|
+
return (id, _importer, _isResolved) => {
|
|
2030
|
+
return externalArr.some((pat) => {
|
|
2031
|
+
if (pat instanceof RegExp) {
|
|
2032
|
+
return pat.test(id);
|
|
2033
|
+
}
|
|
2034
|
+
return id === pat;
|
|
2014
2035
|
});
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function bindingifyResolve(resolve) {
|
|
2040
|
+
if (resolve) {
|
|
2041
|
+
const { alias: alias, extensionAlias: extensionAlias,...rest } = resolve;
|
|
2042
|
+
return {
|
|
2043
|
+
alias: alias ? (Object.entries(alias)).map(([name, replacement]) => ({
|
|
2044
|
+
find: name,
|
|
2045
|
+
replacements: [replacement]
|
|
2046
|
+
})) : undefined,
|
|
2047
|
+
extensionAlias: extensionAlias ? (Object.entries(extensionAlias)).map(([name, value]) => ({
|
|
2048
|
+
target: name,
|
|
2049
|
+
replacements: value
|
|
2050
|
+
})) : undefined,
|
|
2051
|
+
...rest
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
function bindingifyInject(inject) {
|
|
2056
|
+
if (inject) {
|
|
2057
|
+
return (Object.entries(inject)).map(([alias, item]) => {
|
|
2020
2058
|
if (Array.isArray(item)) {
|
|
2021
2059
|
if (item[1] === "*") {
|
|
2022
2060
|
return {
|
|
@@ -2039,39 +2077,34 @@ function bindingifyInputOptions(options, outputOptions) {
|
|
|
2039
2077
|
from: item
|
|
2040
2078
|
};
|
|
2041
2079
|
}
|
|
2042
|
-
})
|
|
2043
|
-
|
|
2044
|
-
strictExecutionOrder: options.experimental?.strictExecutionOrder,
|
|
2045
|
-
disableLiveBindings: options.experimental?.disableLiveBindings
|
|
2046
|
-
},
|
|
2047
|
-
profilerNames: options?.profilerNames,
|
|
2048
|
-
jsx: bindingifyJsx(options.jsx),
|
|
2049
|
-
watch: bindingifyWatch(options.watch),
|
|
2050
|
-
dropLabels: options.dropLabels
|
|
2051
|
-
};
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2052
2082
|
}
|
|
2053
2083
|
function bindingifyLogLevel(logLevel) {
|
|
2054
2084
|
switch (logLevel) {
|
|
2055
|
-
case "silent": return import_binding$
|
|
2056
|
-
case "
|
|
2057
|
-
case "
|
|
2058
|
-
case "
|
|
2085
|
+
case "silent": return import_binding$2.BindingLogLevel.Silent;
|
|
2086
|
+
case "debug": return import_binding$2.BindingLogLevel.Debug;
|
|
2087
|
+
case "warn": return import_binding$2.BindingLogLevel.Warn;
|
|
2088
|
+
case "info": return import_binding$2.BindingLogLevel.Info;
|
|
2059
2089
|
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
2060
2090
|
}
|
|
2061
2091
|
}
|
|
2062
2092
|
function bindingifyInput(input) {
|
|
2093
|
+
if (input === undefined) {
|
|
2094
|
+
return [];
|
|
2095
|
+
}
|
|
2096
|
+
if (typeof input === "string") {
|
|
2097
|
+
return [{import: input}];
|
|
2098
|
+
}
|
|
2063
2099
|
if (Array.isArray(input)) {
|
|
2064
|
-
return input.map((src) => {
|
|
2065
|
-
return {import: src};
|
|
2066
|
-
});
|
|
2067
|
-
} else {
|
|
2068
|
-
return (Object.entries(input)).map((value) => {
|
|
2069
|
-
return {
|
|
2070
|
-
name: value[0],
|
|
2071
|
-
import: value[1]
|
|
2072
|
-
};
|
|
2073
|
-
});
|
|
2100
|
+
return input.map((src) => ({import: src}));
|
|
2074
2101
|
}
|
|
2102
|
+
return (Object.entries(input)).map((value) => {
|
|
2103
|
+
return {
|
|
2104
|
+
name: value[0],
|
|
2105
|
+
import: value[1]
|
|
2106
|
+
};
|
|
2107
|
+
});
|
|
2075
2108
|
}
|
|
2076
2109
|
function bindingifyJsx(input) {
|
|
2077
2110
|
if (input) {
|
|
@@ -2105,88 +2138,15 @@ function bindingifyWatch(watch$1) {
|
|
|
2105
2138
|
return value;
|
|
2106
2139
|
}
|
|
2107
2140
|
}
|
|
2108
|
-
|
|
2109
|
-
//#endregion
|
|
2110
|
-
//#region src/utils/initialize-parallel-plugins.ts
|
|
2111
|
-
var import_binding$2 = __toESM(require_binding());
|
|
2112
|
-
async function initializeParallelPlugins(plugins) {
|
|
2113
|
-
const pluginInfos = [];
|
|
2114
|
-
for (const [index, plugin] of plugins.entries()) {
|
|
2115
|
-
if ("_parallel"in plugin) {
|
|
2116
|
-
const { fileUrl: fileUrl, options: options } = plugin._parallel;
|
|
2117
|
-
pluginInfos.push({
|
|
2118
|
-
index,
|
|
2119
|
-
fileUrl,
|
|
2120
|
-
options
|
|
2121
|
-
});
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
if (pluginInfos.length <= 0) {
|
|
2125
|
-
return undefined;
|
|
2126
|
-
}
|
|
2127
|
-
const count = Math.min(availableParallelism(), 8);
|
|
2128
|
-
const parallelJsPluginRegistry = new import_binding$2.ParallelJsPluginRegistry(count);
|
|
2129
|
-
const registryId = parallelJsPluginRegistry.id;
|
|
2130
|
-
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2131
|
-
const stopWorkers = async () => {
|
|
2132
|
-
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
2133
|
-
};
|
|
2134
|
-
return {
|
|
2135
|
-
registry: parallelJsPluginRegistry,
|
|
2136
|
-
stopWorkers
|
|
2137
|
-
};
|
|
2138
|
-
}
|
|
2139
|
-
function initializeWorkers(registryId, count, pluginInfos) {
|
|
2140
|
-
return Promise.all(Array.from({length: count}, (_, i) => initializeWorker(registryId, pluginInfos, i)));
|
|
2141
|
-
}
|
|
2142
|
-
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2143
|
-
const urlString = undefined("#parallel-plugin-worker");
|
|
2144
|
-
const workerData = {
|
|
2145
|
-
registryId,
|
|
2146
|
-
pluginInfos,
|
|
2147
|
-
threadNumber
|
|
2148
|
-
};
|
|
2149
|
-
let worker;
|
|
2150
|
-
try {
|
|
2151
|
-
worker = new Worker(new URL(urlString), {workerData});
|
|
2152
|
-
worker.unref();
|
|
2153
|
-
await new Promise((resolve, reject) => {
|
|
2154
|
-
worker.once("message", async (message) => {
|
|
2155
|
-
if (message.type === "error") {
|
|
2156
|
-
reject(message.error);
|
|
2157
|
-
} else {
|
|
2158
|
-
resolve();
|
|
2159
|
-
}
|
|
2160
|
-
});
|
|
2161
|
-
});
|
|
2162
|
-
return worker;
|
|
2163
|
-
} catch (e) {
|
|
2164
|
-
worker?.terminate();
|
|
2165
|
-
throw e;
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
//#endregion
|
|
2170
|
-
//#region src/utils/async-flatten.ts
|
|
2171
|
-
async function asyncFlatten(array) {
|
|
2172
|
-
do {
|
|
2173
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
2174
|
-
} while (array.some((v) => v?.then));
|
|
2175
|
-
return array;
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
//#endregion
|
|
2179
|
-
//#region src/utils/normalize-plugin-option.ts
|
|
2180
|
-
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
2181
|
-
|
|
2182
|
-
//#endregion
|
|
2183
|
-
//#region src/utils/normalize-tree-shake.ts
|
|
2184
|
-
function normalizeTreeshakeOptions(config) {
|
|
2141
|
+
function bindingifyTreeshakeOptions(config) {
|
|
2185
2142
|
if (config === false) {
|
|
2186
2143
|
return undefined;
|
|
2187
2144
|
}
|
|
2188
2145
|
if (config === true || config === undefined) {
|
|
2189
|
-
return {
|
|
2146
|
+
return {
|
|
2147
|
+
moduleSideEffects: true,
|
|
2148
|
+
annotations: true
|
|
2149
|
+
};
|
|
2190
2150
|
}
|
|
2191
2151
|
let normalizedConfig = {moduleSideEffects: true};
|
|
2192
2152
|
if (config.moduleSideEffects === undefined) {
|
|
@@ -2202,9 +2162,86 @@ function normalizeTreeshakeOptions(config) {
|
|
|
2202
2162
|
} else {
|
|
2203
2163
|
normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
2204
2164
|
}
|
|
2165
|
+
normalizedConfig.annotations = config.annotations ?? true;
|
|
2205
2166
|
return normalizedConfig;
|
|
2206
2167
|
}
|
|
2207
2168
|
|
|
2169
|
+
//#endregion
|
|
2170
|
+
//#region src/options/bindingify-output-options.ts
|
|
2171
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
2172
|
+
const { dir: dir, format: format, exports: exports, hashCharacters: hashCharacters, sourcemap: sourcemap, sourcemapIgnoreList: sourcemapIgnoreList, sourcemapPathTransform: sourcemapPathTransform, name: name, assetFileNames: assetFileNames, entryFileNames: entryFileNames, chunkFileNames: chunkFileNames, cssEntryFileNames: cssEntryFileNames, cssChunkFileNames: cssChunkFileNames, banner: banner, footer: footer, intro: intro, outro: outro, esModule: esModule, globals: globals, file: file } = outputOptions;
|
|
2173
|
+
return {
|
|
2174
|
+
dir,
|
|
2175
|
+
file: file == null ? undefined : file,
|
|
2176
|
+
format: bindingifyFormat(format),
|
|
2177
|
+
exports,
|
|
2178
|
+
hashCharacters,
|
|
2179
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
2180
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
2181
|
+
sourcemapPathTransform,
|
|
2182
|
+
banner: bindingifyAddon(banner),
|
|
2183
|
+
footer: bindingifyAddon(footer),
|
|
2184
|
+
intro: bindingifyAddon(intro),
|
|
2185
|
+
outro: bindingifyAddon(outro),
|
|
2186
|
+
extend: outputOptions.extend,
|
|
2187
|
+
globals,
|
|
2188
|
+
esModule,
|
|
2189
|
+
name,
|
|
2190
|
+
assetFileNames,
|
|
2191
|
+
entryFileNames,
|
|
2192
|
+
chunkFileNames,
|
|
2193
|
+
cssEntryFileNames,
|
|
2194
|
+
cssChunkFileNames,
|
|
2195
|
+
plugins: [],
|
|
2196
|
+
minify: outputOptions.minify,
|
|
2197
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2198
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2199
|
+
advancedChunks: outputOptions.advancedChunks
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
function bindingifyAddon(configAddon) {
|
|
2203
|
+
return async (chunk) => {
|
|
2204
|
+
if (typeof configAddon === "function") {
|
|
2205
|
+
return configAddon(chunk);
|
|
2206
|
+
}
|
|
2207
|
+
return configAddon || "";
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
function bindingifyFormat(format) {
|
|
2211
|
+
switch (format) {
|
|
2212
|
+
case undefined:
|
|
2213
|
+
case "es":
|
|
2214
|
+
case "esm":
|
|
2215
|
+
case "module": {
|
|
2216
|
+
return "es";
|
|
2217
|
+
}
|
|
2218
|
+
case "cjs":
|
|
2219
|
+
case "commonjs": {
|
|
2220
|
+
return "cjs";
|
|
2221
|
+
}
|
|
2222
|
+
case "iife": {
|
|
2223
|
+
return "iife";
|
|
2224
|
+
}
|
|
2225
|
+
case "umd": {
|
|
2226
|
+
return "umd";
|
|
2227
|
+
}
|
|
2228
|
+
default: unimplemented(`output.format: ${format}`);
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
function bindingifySourcemap(sourcemap) {
|
|
2232
|
+
switch (sourcemap) {
|
|
2233
|
+
case true: return "file";
|
|
2234
|
+
case "inline": return "inline";
|
|
2235
|
+
case false:
|
|
2236
|
+
case undefined: return undefined;
|
|
2237
|
+
case "hidden": return "hidden";
|
|
2238
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
2242
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2208
2245
|
//#endregion
|
|
2209
2246
|
//#region ../../node_modules/.pnpm/remeda@2.16.0/node_modules/remeda/dist/chunk-K26VP6CL.js
|
|
2210
2247
|
function u$1(t$1, n, a) {
|
|
@@ -2631,178 +2668,98 @@ function composeJsPlugins(plugins) {
|
|
|
2631
2668
|
}
|
|
2632
2669
|
|
|
2633
2670
|
//#endregion
|
|
2634
|
-
//#region src/utils/
|
|
2635
|
-
async function
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
}
|
|
2641
|
-
const treeshake = normalizeTreeshakeOptions(config.treeshake);
|
|
2642
|
-
const logLevel = config.logLevel || LOG_LEVEL_INFO;
|
|
2643
|
-
const onLog = getLogger(getObjectPlugins(plugins), getOnLog(config, logLevel), logLevel);
|
|
2644
|
-
return {
|
|
2645
|
-
...rest,
|
|
2646
|
-
input: input ? typeof input === "string" ? [input] : input : [],
|
|
2647
|
-
plugins,
|
|
2648
|
-
logLevel,
|
|
2649
|
-
onLog,
|
|
2650
|
-
treeshake
|
|
2651
|
-
};
|
|
2671
|
+
//#region src/utils/async-flatten.ts
|
|
2672
|
+
async function asyncFlatten(array) {
|
|
2673
|
+
do {
|
|
2674
|
+
array = (await Promise.all(array)).flat(Infinity);
|
|
2675
|
+
} while (array.some((v) => v?.then));
|
|
2676
|
+
return array;
|
|
2652
2677
|
}
|
|
2653
2678
|
|
|
2654
2679
|
//#endregion
|
|
2655
|
-
//#region src/utils/normalize-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
esModule: esModule ?? "if-default-prop",
|
|
2672
|
-
globals: globals ?? {},
|
|
2673
|
-
entryFileNames: entryFileNames ?? "[name].js",
|
|
2674
|
-
chunkFileNames: chunkFileNames ?? "[name]-[hash].js",
|
|
2675
|
-
cssEntryFileNames: cssEntryFileNames ?? "[name].css",
|
|
2676
|
-
cssChunkFileNames: cssChunkFileNames ?? "[name]-[hash].css",
|
|
2677
|
-
assetFileNames: assetFileNames ?? "assets/[name]-[hash][extname]",
|
|
2678
|
-
plugins: [],
|
|
2679
|
-
minify: opts.minify,
|
|
2680
|
-
extend: opts.extend,
|
|
2681
|
-
name,
|
|
2682
|
-
externalLiveBindings: opts.externalLiveBindings ?? true,
|
|
2683
|
-
inlineDynamicImports: opts.inlineDynamicImports ?? false,
|
|
2684
|
-
advancedChunks: opts.advancedChunks
|
|
2685
|
-
};
|
|
2686
|
-
}
|
|
2687
|
-
function getFormat(format) {
|
|
2688
|
-
switch (format) {
|
|
2689
|
-
case undefined:
|
|
2690
|
-
case "es":
|
|
2691
|
-
case "esm":
|
|
2692
|
-
case "module": {
|
|
2693
|
-
return "es";
|
|
2694
|
-
}
|
|
2695
|
-
case "cjs":
|
|
2696
|
-
case "commonjs": {
|
|
2697
|
-
return "cjs";
|
|
2698
|
-
}
|
|
2699
|
-
case "iife": {
|
|
2700
|
-
return "iife";
|
|
2701
|
-
}
|
|
2702
|
-
case "umd": {
|
|
2703
|
-
return "umd";
|
|
2680
|
+
//#region src/utils/normalize-plugin-option.ts
|
|
2681
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
2682
|
+
|
|
2683
|
+
//#endregion
|
|
2684
|
+
//#region src/utils/initialize-parallel-plugins.ts
|
|
2685
|
+
var import_binding$1 = __toESM(require_binding());
|
|
2686
|
+
async function initializeParallelPlugins(plugins) {
|
|
2687
|
+
const pluginInfos = [];
|
|
2688
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
2689
|
+
if ("_parallel"in plugin) {
|
|
2690
|
+
const { fileUrl: fileUrl, options: options } = plugin._parallel;
|
|
2691
|
+
pluginInfos.push({
|
|
2692
|
+
index,
|
|
2693
|
+
fileUrl,
|
|
2694
|
+
options
|
|
2695
|
+
});
|
|
2704
2696
|
}
|
|
2705
|
-
default: unimplemented(`output.format: ${format}`);
|
|
2706
2697
|
}
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2698
|
+
if (pluginInfos.length <= 0) {
|
|
2699
|
+
return undefined;
|
|
2700
|
+
}
|
|
2701
|
+
const count = Math.min(availableParallelism(), 8);
|
|
2702
|
+
const parallelJsPluginRegistry = new import_binding$1.ParallelJsPluginRegistry(count);
|
|
2703
|
+
const registryId = parallelJsPluginRegistry.id;
|
|
2704
|
+
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2705
|
+
const stopWorkers = async () => {
|
|
2706
|
+
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
2715
2707
|
};
|
|
2716
|
-
};
|
|
2717
|
-
|
|
2718
|
-
//#endregion
|
|
2719
|
-
//#region src/options/bindingify-output-options.ts
|
|
2720
|
-
function bindingifyOutputOptions(outputOptions) {
|
|
2721
|
-
const { dir: dir, format: format, exports: exports, hashCharacters: hashCharacters, sourcemap: sourcemap, sourcemapIgnoreList: sourcemapIgnoreList, sourcemapPathTransform: sourcemapPathTransform, name: name, assetFileNames: assetFileNames, entryFileNames: entryFileNames, chunkFileNames: chunkFileNames, cssEntryFileNames: cssEntryFileNames, cssChunkFileNames: cssChunkFileNames, banner: banner, footer: footer, intro: intro, outro: outro, esModule: esModule, globals: globals, file: file } = outputOptions;
|
|
2722
2708
|
return {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
format: function() {
|
|
2726
|
-
switch (format) {
|
|
2727
|
-
case "es": return "es";
|
|
2728
|
-
case "cjs": return "cjs";
|
|
2729
|
-
case "iife": return "iife";
|
|
2730
|
-
case "umd": return "umd";
|
|
2731
|
-
}
|
|
2732
|
-
}(),
|
|
2733
|
-
exports,
|
|
2734
|
-
hashCharacters,
|
|
2735
|
-
sourcemap: bindingifySourcemap(sourcemap),
|
|
2736
|
-
sourcemapIgnoreList,
|
|
2737
|
-
sourcemapPathTransform,
|
|
2738
|
-
banner,
|
|
2739
|
-
footer,
|
|
2740
|
-
intro,
|
|
2741
|
-
outro,
|
|
2742
|
-
extend: outputOptions.extend,
|
|
2743
|
-
globals,
|
|
2744
|
-
esModule: bindingifyEsModule(esModule),
|
|
2745
|
-
name,
|
|
2746
|
-
assetFileNames,
|
|
2747
|
-
entryFileNames,
|
|
2748
|
-
chunkFileNames,
|
|
2749
|
-
cssEntryFileNames,
|
|
2750
|
-
cssChunkFileNames,
|
|
2751
|
-
plugins: [],
|
|
2752
|
-
minify: outputOptions.minify,
|
|
2753
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2754
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2755
|
-
advancedChunks: outputOptions.advancedChunks
|
|
2709
|
+
registry: parallelJsPluginRegistry,
|
|
2710
|
+
stopWorkers
|
|
2756
2711
|
};
|
|
2757
2712
|
}
|
|
2758
|
-
function
|
|
2759
|
-
|
|
2760
|
-
case true: return "file";
|
|
2761
|
-
case "inline": return "inline";
|
|
2762
|
-
case false:
|
|
2763
|
-
case undefined: return undefined;
|
|
2764
|
-
case "hidden": return "hidden";
|
|
2765
|
-
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
2766
|
-
}
|
|
2713
|
+
function initializeWorkers(registryId, count, pluginInfos) {
|
|
2714
|
+
return Promise.all(Array.from({length: count}, (_, i) => initializeWorker(registryId, pluginInfos, i)));
|
|
2767
2715
|
}
|
|
2768
|
-
function
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2716
|
+
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2717
|
+
const urlString = undefined("#parallel-plugin-worker");
|
|
2718
|
+
const workerData = {
|
|
2719
|
+
registryId,
|
|
2720
|
+
pluginInfos,
|
|
2721
|
+
threadNumber
|
|
2722
|
+
};
|
|
2723
|
+
let worker;
|
|
2724
|
+
try {
|
|
2725
|
+
worker = new Worker(new URL(urlString), {workerData});
|
|
2726
|
+
worker.unref();
|
|
2727
|
+
await new Promise((resolve, reject) => {
|
|
2728
|
+
worker.once("message", async (message) => {
|
|
2729
|
+
if (message.type === "error") {
|
|
2730
|
+
reject(message.error);
|
|
2731
|
+
} else {
|
|
2732
|
+
resolve();
|
|
2733
|
+
}
|
|
2734
|
+
});
|
|
2735
|
+
});
|
|
2736
|
+
return worker;
|
|
2737
|
+
} catch (e) {
|
|
2738
|
+
worker?.terminate();
|
|
2739
|
+
throw e;
|
|
2774
2740
|
}
|
|
2775
2741
|
}
|
|
2776
2742
|
|
|
2777
|
-
//#endregion
|
|
2778
|
-
//#region src/treeshake/module-side-effects.ts
|
|
2779
|
-
const ModuleSideEffectsRuleSchema = (z.object({
|
|
2780
|
-
test: (z.instanceof(RegExp)).optional(),
|
|
2781
|
-
external: (z.boolean()).optional(),
|
|
2782
|
-
sideEffects: z.boolean()
|
|
2783
|
-
})).refine((data) => {
|
|
2784
|
-
return data.test !== undefined || data.external !== undefined;
|
|
2785
|
-
}, "Either `test` or `external` should be set.");
|
|
2786
|
-
const ModuleSideEffectsOptionSchema = ((z.boolean()).or(z.array(ModuleSideEffectsRuleSchema))).or(z.literal("no-external"));
|
|
2787
|
-
const TreeshakingOptionsSchema = ((z.object({moduleSideEffects: ModuleSideEffectsOptionSchema.optional()})).passthrough()).or(z.boolean());
|
|
2788
|
-
|
|
2789
2743
|
//#endregion
|
|
2790
2744
|
//#region src/utils/create-bundler.ts
|
|
2791
|
-
var import_binding
|
|
2745
|
+
var import_binding = __toESM(require_binding());
|
|
2792
2746
|
async function createBundler(inputOptions, outputOptions) {
|
|
2793
2747
|
const pluginDriver = new PluginDriver();
|
|
2794
2748
|
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2795
2749
|
if (inputOptions.treeshake !== undefined) {
|
|
2796
2750
|
TreeshakingOptionsSchema.parse(inputOptions.treeshake);
|
|
2797
2751
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2752
|
+
let plugins = await normalizePluginOption(inputOptions.plugins);
|
|
2753
|
+
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) {
|
|
2754
|
+
plugins = composeJsPlugins(plugins);
|
|
2755
|
+
}
|
|
2756
|
+
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
2800
2757
|
try {
|
|
2801
|
-
outputOptions = pluginDriver.callOutputOptionsHook(
|
|
2802
|
-
const
|
|
2803
|
-
const
|
|
2758
|
+
outputOptions = pluginDriver.callOutputOptionsHook(plugins, outputOptions);
|
|
2759
|
+
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions);
|
|
2760
|
+
const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
|
|
2804
2761
|
return {
|
|
2805
|
-
bundler: new import_binding
|
|
2762
|
+
bundler: new import_binding.Bundler(bindingInputOptions, bindingOutputOptions, parallelPluginInitResult?.registry),
|
|
2806
2763
|
stopWorkers: parallelPluginInitResult?.stopWorkers
|
|
2807
2764
|
};
|
|
2808
2765
|
} catch (e) {
|
|
@@ -2851,12 +2808,12 @@ class RolldownBuild {
|
|
|
2851
2808
|
|
|
2852
2809
|
//#endregion
|
|
2853
2810
|
//#region src/watcher.ts
|
|
2854
|
-
var import_binding = __toESM(require_binding());
|
|
2855
2811
|
class Watcher {
|
|
2856
2812
|
closed;
|
|
2857
2813
|
controller;
|
|
2858
2814
|
inner;
|
|
2859
2815
|
stopWorkers;
|
|
2816
|
+
listeners = new Map();
|
|
2860
2817
|
constructor(inner, stopWorkers) {
|
|
2861
2818
|
this.closed = false;
|
|
2862
2819
|
this.controller = new AbortController();
|
|
@@ -2870,48 +2827,11 @@ class Watcher {
|
|
|
2870
2827
|
this.controller.abort();
|
|
2871
2828
|
}
|
|
2872
2829
|
on(event, listener) {
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
break;
|
|
2879
|
-
case "event":
|
|
2880
|
-
this.inner.on(import_binding.BindingWatcherEvent.Event, async (data) => {
|
|
2881
|
-
const code = data.bundleEventKind();
|
|
2882
|
-
switch (code) {
|
|
2883
|
-
case "BUNDLE_END":
|
|
2884
|
-
const { duration: duration, output: output } = data.bundleEndData();
|
|
2885
|
-
await listener({
|
|
2886
|
-
code: "BUNDLE_END",
|
|
2887
|
-
duration,
|
|
2888
|
-
output: [output]
|
|
2889
|
-
});
|
|
2890
|
-
break;
|
|
2891
|
-
case "ERROR":
|
|
2892
|
-
await listener({
|
|
2893
|
-
code: "ERROR",
|
|
2894
|
-
error: {message: data.error()}
|
|
2895
|
-
});
|
|
2896
|
-
break;
|
|
2897
|
-
default:
|
|
2898
|
-
await listener({code});
|
|
2899
|
-
break;
|
|
2900
|
-
}
|
|
2901
|
-
});
|
|
2902
|
-
break;
|
|
2903
|
-
case "restart":
|
|
2904
|
-
this.inner.on(import_binding.BindingWatcherEvent.ReStart, async () => {
|
|
2905
|
-
await listener();
|
|
2906
|
-
});
|
|
2907
|
-
break;
|
|
2908
|
-
case "change":
|
|
2909
|
-
this.inner.on(import_binding.BindingWatcherEvent.Change, async (data) => {
|
|
2910
|
-
const { path: path$2, kind: kind } = data.watchChangeData();
|
|
2911
|
-
await listener(path$2, {event: kind});
|
|
2912
|
-
});
|
|
2913
|
-
break;
|
|
2914
|
-
default: throw new Error(`Unknown event: ${event}`);
|
|
2830
|
+
const listeners = this.listeners.get(event);
|
|
2831
|
+
if (listeners) {
|
|
2832
|
+
listeners.push(listener);
|
|
2833
|
+
} else {
|
|
2834
|
+
this.listeners.set(event, [listener]);
|
|
2915
2835
|
}
|
|
2916
2836
|
return this;
|
|
2917
2837
|
}
|
|
@@ -2920,7 +2840,51 @@ class Watcher {
|
|
|
2920
2840
|
this.controller.signal.addEventListener("abort", () => {
|
|
2921
2841
|
clearInterval(timer);
|
|
2922
2842
|
});
|
|
2923
|
-
process.nextTick(() => this.inner.start()
|
|
2843
|
+
process.nextTick(() => this.inner.start(async (event) => {
|
|
2844
|
+
const listeners = this.listeners.get(event.eventKind());
|
|
2845
|
+
if (listeners) {
|
|
2846
|
+
switch (event.eventKind()) {
|
|
2847
|
+
case "close":
|
|
2848
|
+
case "restart":
|
|
2849
|
+
for (const listener of listeners) {
|
|
2850
|
+
await listener();
|
|
2851
|
+
}
|
|
2852
|
+
break;
|
|
2853
|
+
case "event":
|
|
2854
|
+
for (const listener of listeners) {
|
|
2855
|
+
const code = event.bundleEventKind();
|
|
2856
|
+
switch (code) {
|
|
2857
|
+
case "BUNDLE_END":
|
|
2858
|
+
const { duration: duration, output: output } = event.bundleEndData();
|
|
2859
|
+
await listener({
|
|
2860
|
+
code: "BUNDLE_END",
|
|
2861
|
+
duration,
|
|
2862
|
+
output: [output]
|
|
2863
|
+
});
|
|
2864
|
+
break;
|
|
2865
|
+
case "ERROR":
|
|
2866
|
+
const errors = event.errors();
|
|
2867
|
+
await listener({
|
|
2868
|
+
code: "ERROR",
|
|
2869
|
+
error: normalizeErrors(errors)
|
|
2870
|
+
});
|
|
2871
|
+
break;
|
|
2872
|
+
default:
|
|
2873
|
+
await listener({code});
|
|
2874
|
+
break;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
break;
|
|
2878
|
+
case "change":
|
|
2879
|
+
for (const listener of listeners) {
|
|
2880
|
+
const { path: path$2, kind: kind } = event.watchChangeData();
|
|
2881
|
+
await listener(path$2, {event: kind});
|
|
2882
|
+
}
|
|
2883
|
+
break;
|
|
2884
|
+
default: throw new Error(`Unknown event: ${event}`);
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
}));
|
|
2924
2888
|
}
|
|
2925
2889
|
}
|
|
2926
2890
|
|