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,7 +1,7 @@
|
|
|
1
1
|
import __node_module__ from 'node:module';
|
|
2
2
|
const require = __node_module__.createRequire(import.meta.url)
|
|
3
|
-
import { default as path, default as path$1 } from "node:path";
|
|
4
3
|
import { z, z as z$1 } from "zod";
|
|
4
|
+
import { default as path, default as path$1 } from "node:path";
|
|
5
5
|
import { Worker } from "node:worker_threads";
|
|
6
6
|
import { availableParallelism } from "node:os";
|
|
7
7
|
|
|
@@ -76,6 +76,60 @@ function transformToRenderedModule(bindingRenderedModule) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/utils/error.ts
|
|
81
|
+
function normalizeErrors(rawErrors) {
|
|
82
|
+
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), e, {stack: undefined}));
|
|
83
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
84
|
+
for (let i = 0; i < errors.length; i++) {
|
|
85
|
+
if (i >= 5) {
|
|
86
|
+
summary += "\n...";
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
summary += getErrorMessage(errors[i]) + "\n";
|
|
90
|
+
}
|
|
91
|
+
const wrapper = new Error(summary);
|
|
92
|
+
Object.defineProperty(wrapper, "errors", {
|
|
93
|
+
configurable: true,
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: () => errors,
|
|
96
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
97
|
+
configurable: true,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
value
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
return wrapper;
|
|
103
|
+
}
|
|
104
|
+
function getErrorMessage(e) {
|
|
105
|
+
let s = "";
|
|
106
|
+
if (e.plugin) {
|
|
107
|
+
s += `[plugin ${e.plugin}]`;
|
|
108
|
+
}
|
|
109
|
+
const id = e.id ?? e.loc?.file;
|
|
110
|
+
if (id) {
|
|
111
|
+
s += " " + id;
|
|
112
|
+
if (e.loc) {
|
|
113
|
+
s += `:${e.loc.line}:${e.loc.column}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (s) {
|
|
117
|
+
s += "\n";
|
|
118
|
+
}
|
|
119
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
120
|
+
s += message;
|
|
121
|
+
if (e.frame) {
|
|
122
|
+
s = joinNewLine(s, e.frame);
|
|
123
|
+
}
|
|
124
|
+
if (e.stack) {
|
|
125
|
+
s = joinNewLine(s, e.stack.replace(message, ""));
|
|
126
|
+
}
|
|
127
|
+
return s;
|
|
128
|
+
}
|
|
129
|
+
function joinNewLine(s1, s2) {
|
|
130
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
131
|
+
}
|
|
132
|
+
|
|
79
133
|
//#endregion
|
|
80
134
|
//#region src/utils/transform-to-rollup-output.ts
|
|
81
135
|
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
@@ -156,56 +210,8 @@ function transformToRollupOutput(output, changed) {
|
|
|
156
210
|
function handleOutputErrors(output) {
|
|
157
211
|
const rawErrors = output.errors;
|
|
158
212
|
if (rawErrors.length > 0) {
|
|
159
|
-
|
|
160
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
161
|
-
for (let i = 0; i < errors.length; i++) {
|
|
162
|
-
if (i >= 5) {
|
|
163
|
-
summary += "\n...";
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
summary += getErrorMessage(errors[i]) + "\n";
|
|
167
|
-
}
|
|
168
|
-
const wrapper = new Error(summary);
|
|
169
|
-
Object.defineProperty(wrapper, "errors", {
|
|
170
|
-
configurable: true,
|
|
171
|
-
enumerable: true,
|
|
172
|
-
get: () => errors,
|
|
173
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
174
|
-
configurable: true,
|
|
175
|
-
enumerable: true,
|
|
176
|
-
value
|
|
177
|
-
})
|
|
178
|
-
});
|
|
179
|
-
throw wrapper;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function getErrorMessage(e) {
|
|
183
|
-
let s = "";
|
|
184
|
-
if (e.plugin) {
|
|
185
|
-
s += `[plugin ${e.plugin}]`;
|
|
186
|
-
}
|
|
187
|
-
const id = e.id ?? e.loc?.file;
|
|
188
|
-
if (id) {
|
|
189
|
-
s += " " + id;
|
|
190
|
-
if (e.loc) {
|
|
191
|
-
s += `:${e.loc.line}:${e.loc.column}`;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (s) {
|
|
195
|
-
s += "\n";
|
|
196
|
-
}
|
|
197
|
-
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
198
|
-
s += message;
|
|
199
|
-
if (e.frame) {
|
|
200
|
-
s = joinNewLine(s, e.frame);
|
|
213
|
+
throw normalizeErrors(rawErrors);
|
|
201
214
|
}
|
|
202
|
-
if (e.stack) {
|
|
203
|
-
s = joinNewLine(s, e.stack.replace(message, ""));
|
|
204
|
-
}
|
|
205
|
-
return s;
|
|
206
|
-
}
|
|
207
|
-
function joinNewLine(s1, s2) {
|
|
208
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
209
215
|
}
|
|
210
216
|
function transformToOutputBundle(output, changed) {
|
|
211
217
|
const bundle = Object.fromEntries((transformToRollupOutput(output, changed)).output.map((item) => [item.fileName, item,]));
|
|
@@ -596,14 +602,13 @@ var require_binding = __commonJSMin((exports, module) => {
|
|
|
596
602
|
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
|
|
597
603
|
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
|
|
598
604
|
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
|
|
599
|
-
module.exports.
|
|
605
|
+
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
600
606
|
module.exports.Bundler = nativeBinding.Bundler;
|
|
601
607
|
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
|
|
602
608
|
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
603
609
|
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
604
610
|
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
605
611
|
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
606
|
-
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
|
|
607
612
|
module.exports.isCallableCompatibleBuiltinPlugin = nativeBinding.isCallableCompatibleBuiltinPlugin;
|
|
608
613
|
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
609
614
|
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
@@ -637,58 +642,6 @@ function unsupported(info) {
|
|
|
637
642
|
}
|
|
638
643
|
function noop(..._args) {}
|
|
639
644
|
|
|
640
|
-
//#endregion
|
|
641
|
-
//#region src/utils/normalize-hook.ts
|
|
642
|
-
function normalizeHook(hook) {
|
|
643
|
-
if (typeof hook === "function" || typeof hook === "string") {
|
|
644
|
-
return {
|
|
645
|
-
handler: hook,
|
|
646
|
-
options: {},
|
|
647
|
-
meta: {}
|
|
648
|
-
};
|
|
649
|
-
} else if (typeof hook === "object" && hook !== null) {
|
|
650
|
-
const { handler: handler, order: order,...options } = hook;
|
|
651
|
-
return {
|
|
652
|
-
handler,
|
|
653
|
-
options,
|
|
654
|
-
meta: {order}
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
unreachable("Invalid hook type");
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
//#endregion
|
|
661
|
-
//#region src/utils/transform-sourcemap.ts
|
|
662
|
-
function isEmptySourcemapFiled(array) {
|
|
663
|
-
if (!array) {
|
|
664
|
-
return true;
|
|
665
|
-
}
|
|
666
|
-
if (array.length === 0 || !array[0]) {
|
|
667
|
-
return true;
|
|
668
|
-
}
|
|
669
|
-
return false;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
//#endregion
|
|
673
|
-
//#region src/utils/transform-module-info.ts
|
|
674
|
-
function transformModuleInfo(info, option) {
|
|
675
|
-
return {
|
|
676
|
-
get ast() {
|
|
677
|
-
return unsupported("ModuleInfo#ast");
|
|
678
|
-
},
|
|
679
|
-
get code() {
|
|
680
|
-
return info.code;
|
|
681
|
-
},
|
|
682
|
-
id: info.id,
|
|
683
|
-
importers: info.importers,
|
|
684
|
-
dynamicImporters: info.dynamicImporters,
|
|
685
|
-
importedIds: info.importedIds,
|
|
686
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
687
|
-
isEntry: info.isEntry,
|
|
688
|
-
...option
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
|
|
692
645
|
//#endregion
|
|
693
646
|
//#region src/log/logging.ts
|
|
694
647
|
const LogLevelSchema = ((z$1.literal("info")).or(z$1.literal("debug"))).or(z$1.literal("warn"));
|
|
@@ -876,107 +829,248 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
|
876
829
|
}
|
|
877
830
|
|
|
878
831
|
//#endregion
|
|
879
|
-
//#region src/utils/normalize-
|
|
880
|
-
function
|
|
881
|
-
if (
|
|
882
|
-
return
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
return undefined;
|
|
832
|
+
//#region src/utils/normalize-hook.ts
|
|
833
|
+
function normalizeHook(hook) {
|
|
834
|
+
if (typeof hook === "function" || typeof hook === "string") {
|
|
835
|
+
return {
|
|
836
|
+
handler: hook,
|
|
837
|
+
options: {},
|
|
838
|
+
meta: {}
|
|
839
|
+
};
|
|
840
|
+
} else if (typeof hook === "object" && hook !== null) {
|
|
841
|
+
const { handler: handler, order: order,...options } = hook;
|
|
842
|
+
return {
|
|
843
|
+
handler,
|
|
844
|
+
options,
|
|
845
|
+
meta: {order}
|
|
846
|
+
};
|
|
895
847
|
}
|
|
896
|
-
|
|
897
|
-
jsxInject: config?.jsxInject,
|
|
898
|
-
exclude: normalizedStringOrRegex(config.exclude),
|
|
899
|
-
include: normalizedStringOrRegex(config.include),
|
|
900
|
-
targets: config.targets
|
|
901
|
-
};
|
|
902
|
-
return normalizedConfig;
|
|
848
|
+
unreachable("Invalid hook type");
|
|
903
849
|
}
|
|
904
850
|
|
|
905
851
|
//#endregion
|
|
906
|
-
//#region src/
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
852
|
+
//#region src/log/logger.ts
|
|
853
|
+
class MinimalPluginContext {
|
|
854
|
+
info;
|
|
855
|
+
warn;
|
|
856
|
+
debug;
|
|
857
|
+
meta;
|
|
858
|
+
error;
|
|
859
|
+
constructor(options, plugin) {
|
|
860
|
+
const onLog = options.onLog;
|
|
861
|
+
const pluginName = plugin.name || "unknown";
|
|
862
|
+
const logLevel = options.logLevel || LOG_LEVEL_INFO;
|
|
863
|
+
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
864
|
+
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
865
|
+
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
866
|
+
this.error = (e) => {
|
|
867
|
+
return error(logPluginError(normalizeLog(e), pluginName));
|
|
868
|
+
};
|
|
869
|
+
this.meta = {
|
|
870
|
+
rollupVersion: "4.23.0",
|
|
871
|
+
rolldownVersion: VERSION,
|
|
872
|
+
watchMode: false
|
|
873
|
+
};
|
|
914
874
|
}
|
|
915
875
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
876
|
+
function getLogger(plugins, onLog, logLevel) {
|
|
877
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
878
|
+
const logger = (level, log, skipped = new Set()) => {
|
|
879
|
+
const logPriority = logLevelPriority[level];
|
|
880
|
+
if (logPriority < minimalPriority) {
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
for (const plugin of getSortedPlugins("onLog", plugins)) {
|
|
884
|
+
if (skipped.has(plugin)) continue;
|
|
885
|
+
const { onLog: pluginOnLog } = plugin;
|
|
886
|
+
if (pluginOnLog) {
|
|
887
|
+
const getLogHandler$1 = (level$1) => {
|
|
888
|
+
if (logLevelPriority[level$1] < minimalPriority) {
|
|
889
|
+
return () => {};
|
|
890
|
+
}
|
|
891
|
+
return (log$1) => logger(level$1, normalizeLog(log$1), (new Set(skipped)).add(plugin));
|
|
892
|
+
};
|
|
893
|
+
const handler = "handler"in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
894
|
+
if (handler.call({
|
|
895
|
+
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
896
|
+
error: (log$1) => error(normalizeLog(log$1)),
|
|
897
|
+
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
898
|
+
meta: {
|
|
899
|
+
rollupVersion: "4.23.0",
|
|
900
|
+
rolldownVersion: VERSION,
|
|
901
|
+
watchMode: false
|
|
902
|
+
},
|
|
903
|
+
warn: getLogHandler$1(LOG_LEVEL_WARN)
|
|
904
|
+
}, level, log) === false) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
onLog(level, log);
|
|
910
|
+
};
|
|
911
|
+
return logger;
|
|
920
912
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
913
|
+
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
914
|
+
const { onwarn: onwarn, onLog: onLog } = config;
|
|
915
|
+
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
916
|
+
if (onLog) {
|
|
917
|
+
const minimalPriority = logLevelPriority[logLevel];
|
|
918
|
+
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
919
|
+
if (level$1 === LOG_LEVEL_ERROR) {
|
|
920
|
+
return error(normalizeLog(handledLog));
|
|
921
|
+
}
|
|
922
|
+
if (logLevelPriority[level$1] >= minimalPriority) {
|
|
923
|
+
defaultOnLog(level$1, normalizeLog(handledLog));
|
|
924
|
+
}
|
|
925
|
+
});
|
|
924
926
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
927
|
+
return defaultOnLog;
|
|
928
|
+
};
|
|
929
|
+
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
930
|
+
if (level === LOG_LEVEL_WARN) {
|
|
931
|
+
onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
932
|
+
} else {
|
|
933
|
+
printLog(level, log);
|
|
934
|
+
}
|
|
935
|
+
} : printLog;
|
|
936
|
+
const addLogToString = (log) => {
|
|
937
|
+
Object.defineProperty(log, "toString", {
|
|
938
|
+
value: () => getExtendedLogMessage(log),
|
|
939
|
+
writable: true
|
|
940
|
+
});
|
|
941
|
+
return log;
|
|
942
|
+
};
|
|
943
|
+
const defaultPrintLog = (level, log) => {
|
|
944
|
+
const message = getExtendedLogMessage(log);
|
|
945
|
+
switch (level) {
|
|
946
|
+
case LOG_LEVEL_WARN: {
|
|
947
|
+
return console.warn(message);
|
|
948
|
+
}
|
|
949
|
+
case LOG_LEVEL_DEBUG: {
|
|
950
|
+
return console.debug(message);
|
|
951
|
+
}
|
|
952
|
+
default: {
|
|
953
|
+
return console.info(message);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
const getExtendedLogMessage = (log) => {
|
|
958
|
+
let prefix = "";
|
|
959
|
+
if (log.plugin) {
|
|
960
|
+
prefix += `(${log.plugin} plugin) `;
|
|
961
|
+
}
|
|
962
|
+
if (log.loc) {
|
|
963
|
+
prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
964
|
+
}
|
|
965
|
+
return prefix + log.message;
|
|
966
|
+
};
|
|
967
|
+
function relativeId(id) {
|
|
968
|
+
if (!path$1.isAbsolute(id)) return id;
|
|
969
|
+
return path$1.relative(path$1.resolve(), id);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/utils/normalize-string-or-regex.ts
|
|
974
|
+
function normalizedStringOrRegex(pattern) {
|
|
975
|
+
if (!pattern) {
|
|
976
|
+
return undefined;
|
|
977
|
+
}
|
|
978
|
+
if (!Array.isArray(pattern)) {
|
|
979
|
+
pattern = [pattern];
|
|
980
|
+
}
|
|
981
|
+
return pattern;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region src/options/normalized-ecma-transform-plugin-config.ts
|
|
986
|
+
function normalizeEcmaTransformPluginConfig(config) {
|
|
987
|
+
if (!config) {
|
|
988
|
+
return undefined;
|
|
989
|
+
}
|
|
990
|
+
let normalizedConfig = {
|
|
991
|
+
jsxInject: config?.jsxInject,
|
|
992
|
+
exclude: normalizedStringOrRegex(config.exclude),
|
|
993
|
+
include: normalizedStringOrRegex(config.include),
|
|
994
|
+
targets: config.targets
|
|
995
|
+
};
|
|
996
|
+
return normalizedConfig;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/plugin/builtin-plugin.ts
|
|
1001
|
+
var import_binding$5 = __toESM(require_binding());
|
|
1002
|
+
class BuiltinPlugin {
|
|
1003
|
+
constructor(name, options) {
|
|
1004
|
+
this.name = name;
|
|
1005
|
+
this.options = options;
|
|
1006
|
+
this.name = name;
|
|
1007
|
+
this.options = options;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
class ModulePreloadPolyfillPlugin extends BuiltinPlugin {
|
|
1011
|
+
constructor(config) {
|
|
1012
|
+
super(import_binding$5.BindingBuiltinPluginName.ModulePreloadPolyfillPlugin, config);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
class DynamicImportVarsPlugin extends BuiltinPlugin {
|
|
1016
|
+
constructor() {
|
|
1017
|
+
super(import_binding$5.BindingBuiltinPluginName.DynamicImportVarsPlugin);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
class ImportGlobPlugin extends BuiltinPlugin {
|
|
1021
|
+
constructor(config) {
|
|
1022
|
+
super(import_binding$5.BindingBuiltinPluginName.ImportGlobPlugin, config);
|
|
929
1023
|
}
|
|
930
1024
|
}
|
|
931
1025
|
class ManifestPlugin extends BuiltinPlugin {
|
|
932
1026
|
constructor(config) {
|
|
933
|
-
super(import_binding$
|
|
1027
|
+
super(import_binding$5.BindingBuiltinPluginName.ManifestPlugin, config);
|
|
934
1028
|
}
|
|
935
1029
|
}
|
|
936
1030
|
class WasmHelperPlugin extends BuiltinPlugin {
|
|
937
1031
|
constructor() {
|
|
938
|
-
super(import_binding$
|
|
1032
|
+
super(import_binding$5.BindingBuiltinPluginName.WasmHelperPlugin);
|
|
939
1033
|
}
|
|
940
1034
|
}
|
|
941
1035
|
class WasmFallbackPlugin extends BuiltinPlugin {
|
|
942
1036
|
constructor() {
|
|
943
|
-
super(import_binding$
|
|
1037
|
+
super(import_binding$5.BindingBuiltinPluginName.WasmFallbackPlugin);
|
|
944
1038
|
}
|
|
945
1039
|
}
|
|
946
1040
|
class LoadFallbackPlugin extends BuiltinPlugin {
|
|
947
1041
|
constructor() {
|
|
948
|
-
super(import_binding$
|
|
1042
|
+
super(import_binding$5.BindingBuiltinPluginName.LoadFallbackPlugin);
|
|
949
1043
|
}
|
|
950
1044
|
}
|
|
951
1045
|
class AliasPlugin extends BuiltinPlugin {
|
|
952
1046
|
constructor(config) {
|
|
953
|
-
super(import_binding$
|
|
1047
|
+
super(import_binding$5.BindingBuiltinPluginName.AliasPlugin, config);
|
|
954
1048
|
}
|
|
955
1049
|
}
|
|
956
1050
|
class TransformPlugin extends BuiltinPlugin {
|
|
957
1051
|
constructor(config) {
|
|
958
1052
|
let normalizedConfig = normalizeEcmaTransformPluginConfig(config);
|
|
959
|
-
super(import_binding$
|
|
1053
|
+
super(import_binding$5.BindingBuiltinPluginName.TransformPlugin, normalizedConfig);
|
|
960
1054
|
}
|
|
961
1055
|
}
|
|
962
1056
|
class JsonPlugin extends BuiltinPlugin {
|
|
963
1057
|
constructor(config) {
|
|
964
|
-
super(import_binding$
|
|
1058
|
+
super(import_binding$5.BindingBuiltinPluginName.JsonPlugin, config);
|
|
965
1059
|
}
|
|
966
1060
|
}
|
|
967
1061
|
class BuildImportAnalysisPlugin extends BuiltinPlugin {
|
|
968
1062
|
constructor(config) {
|
|
969
|
-
super(import_binding$
|
|
1063
|
+
super(import_binding$5.BindingBuiltinPluginName.BuildImportAnalysisPlugin, config);
|
|
970
1064
|
}
|
|
971
1065
|
}
|
|
972
1066
|
class ReplacePlugin extends BuiltinPlugin {
|
|
973
1067
|
constructor(config) {
|
|
974
|
-
super(import_binding$
|
|
1068
|
+
super(import_binding$5.BindingBuiltinPluginName.ReplacePlugin, config);
|
|
975
1069
|
}
|
|
976
1070
|
}
|
|
977
1071
|
class ViteResolvePlugin extends BuiltinPlugin {
|
|
978
1072
|
constructor(config) {
|
|
979
|
-
super(import_binding$
|
|
1073
|
+
super(import_binding$5.BindingBuiltinPluginName.ViteResolvePlugin, config);
|
|
980
1074
|
}
|
|
981
1075
|
}
|
|
982
1076
|
function modulePreloadPolyfillPlugin(config) {
|
|
@@ -1025,10 +1119,10 @@ function replacePlugin(values = {}, options = {}) {
|
|
|
1025
1119
|
});
|
|
1026
1120
|
}
|
|
1027
1121
|
function isCallableCompatibleBuiltinPlugin(plugin) {
|
|
1028
|
-
return plugin instanceof BuiltinPlugin && (0, import_binding$
|
|
1122
|
+
return plugin instanceof BuiltinPlugin && (0, import_binding$5.isCallableCompatibleBuiltinPlugin)(bindingifyBuiltInPlugin(plugin));
|
|
1029
1123
|
}
|
|
1030
1124
|
function makeBuiltinPluginCallable(plugin) {
|
|
1031
|
-
let callablePlugin = new import_binding$
|
|
1125
|
+
let callablePlugin = new import_binding$5.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
1032
1126
|
const wrappedPlugin = {_original: callablePlugin};
|
|
1033
1127
|
for (const key in callablePlugin) {
|
|
1034
1128
|
if (key === "name") {
|
|
@@ -1042,7 +1136,7 @@ function makeBuiltinPluginCallable(plugin) {
|
|
|
1042
1136
|
return wrappedPlugin;
|
|
1043
1137
|
}
|
|
1044
1138
|
function isCallableBuiltinPlugin(plugin) {
|
|
1045
|
-
return "_original"in plugin && plugin._original instanceof import_binding$
|
|
1139
|
+
return "_original"in plugin && plugin._original instanceof import_binding$5.BindingCallableBuiltinPlugin;
|
|
1046
1140
|
}
|
|
1047
1141
|
function bindingifyBuiltInPlugin(plugin) {
|
|
1048
1142
|
return {
|
|
@@ -1081,9 +1175,9 @@ class PluginDriver {
|
|
|
1081
1175
|
}
|
|
1082
1176
|
return inputOptions;
|
|
1083
1177
|
}
|
|
1084
|
-
callOutputOptionsHook(
|
|
1085
|
-
const
|
|
1086
|
-
for (const plugin of
|
|
1178
|
+
callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
1179
|
+
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
1180
|
+
for (const plugin of sortedPlugins) {
|
|
1087
1181
|
const options = plugin.outputOptions;
|
|
1088
1182
|
if (options) {
|
|
1089
1183
|
const { handler: handler } = normalizeHook(options);
|
|
@@ -1134,134 +1228,60 @@ function getSortedPlugins(hookName, plugins) {
|
|
|
1134
1228
|
}
|
|
1135
1229
|
|
|
1136
1230
|
//#endregion
|
|
1137
|
-
//#region src/
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1231
|
+
//#region src/treeshake/module-side-effects.ts
|
|
1232
|
+
const ModuleSideEffectsRuleSchema = (z.object({
|
|
1233
|
+
test: (z.instanceof(RegExp)).optional(),
|
|
1234
|
+
external: (z.boolean()).optional(),
|
|
1235
|
+
sideEffects: z.boolean()
|
|
1236
|
+
})).refine((data) => {
|
|
1237
|
+
return data.test !== undefined || data.external !== undefined;
|
|
1238
|
+
}, "Either `test` or `external` should be set.");
|
|
1239
|
+
const ModuleSideEffectsOptionSchema = ((z.boolean()).or(z.array(ModuleSideEffectsRuleSchema))).or(z.literal("no-external"));
|
|
1240
|
+
const TreeshakingOptionsSchema = ((z.object({
|
|
1241
|
+
moduleSideEffects: ModuleSideEffectsOptionSchema.optional(),
|
|
1242
|
+
annotations: (z.boolean()).optional()
|
|
1243
|
+
})).passthrough()).or(z.boolean());
|
|
1244
|
+
|
|
1245
|
+
//#endregion
|
|
1246
|
+
//#region src/utils/transform-sourcemap.ts
|
|
1247
|
+
function isEmptySourcemapFiled(array) {
|
|
1248
|
+
if (!array) {
|
|
1249
|
+
return true;
|
|
1250
|
+
}
|
|
1251
|
+
if (array.length === 0 || !array[0]) {
|
|
1252
|
+
return true;
|
|
1159
1253
|
}
|
|
1254
|
+
return false;
|
|
1160
1255
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
if (handler.call({
|
|
1180
|
-
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
1181
|
-
error: (log$1) => error(normalizeLog(log$1)),
|
|
1182
|
-
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
1183
|
-
meta: {
|
|
1184
|
-
rollupVersion: "4.23.0",
|
|
1185
|
-
rolldownVersion: VERSION,
|
|
1186
|
-
watchMode: false
|
|
1187
|
-
},
|
|
1188
|
-
warn: getLogHandler$1(LOG_LEVEL_WARN)
|
|
1189
|
-
}, level, log) === false) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
onLog(level, log);
|
|
1256
|
+
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/utils/transform-module-info.ts
|
|
1259
|
+
function transformModuleInfo(info, option) {
|
|
1260
|
+
return {
|
|
1261
|
+
get ast() {
|
|
1262
|
+
return unsupported("ModuleInfo#ast");
|
|
1263
|
+
},
|
|
1264
|
+
get code() {
|
|
1265
|
+
return info.code;
|
|
1266
|
+
},
|
|
1267
|
+
id: info.id,
|
|
1268
|
+
importers: info.importers,
|
|
1269
|
+
dynamicImporters: info.dynamicImporters,
|
|
1270
|
+
importedIds: info.importedIds,
|
|
1271
|
+
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
1272
|
+
isEntry: info.isEntry,
|
|
1273
|
+
...option
|
|
1195
1274
|
};
|
|
1196
|
-
return logger;
|
|
1197
|
-
}
|
|
1198
|
-
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
1199
|
-
const { onwarn: onwarn, onLog: onLog } = config;
|
|
1200
|
-
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
1201
|
-
if (onLog) {
|
|
1202
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
1203
|
-
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
1204
|
-
if (level$1 === LOG_LEVEL_ERROR) {
|
|
1205
|
-
return error(normalizeLog(handledLog));
|
|
1206
|
-
}
|
|
1207
|
-
if (logLevelPriority[level$1] >= minimalPriority) {
|
|
1208
|
-
defaultOnLog(level$1, normalizeLog(handledLog));
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
return defaultOnLog;
|
|
1213
|
-
};
|
|
1214
|
-
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
1215
|
-
if (level === LOG_LEVEL_WARN) {
|
|
1216
|
-
onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
1217
|
-
} else {
|
|
1218
|
-
printLog(level, log);
|
|
1219
|
-
}
|
|
1220
|
-
} : printLog;
|
|
1221
|
-
const addLogToString = (log) => {
|
|
1222
|
-
Object.defineProperty(log, "toString", {
|
|
1223
|
-
value: () => getExtendedLogMessage(log),
|
|
1224
|
-
writable: true
|
|
1225
|
-
});
|
|
1226
|
-
return log;
|
|
1227
|
-
};
|
|
1228
|
-
const defaultPrintLog = (level, log) => {
|
|
1229
|
-
const message = getExtendedLogMessage(log);
|
|
1230
|
-
switch (level) {
|
|
1231
|
-
case LOG_LEVEL_WARN: {
|
|
1232
|
-
return console.warn(message);
|
|
1233
|
-
}
|
|
1234
|
-
case LOG_LEVEL_DEBUG: {
|
|
1235
|
-
return console.debug(message);
|
|
1236
|
-
}
|
|
1237
|
-
default: {
|
|
1238
|
-
return console.info(message);
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
};
|
|
1242
|
-
const getExtendedLogMessage = (log) => {
|
|
1243
|
-
let prefix = "";
|
|
1244
|
-
if (log.plugin) {
|
|
1245
|
-
prefix += `(${log.plugin} plugin) `;
|
|
1246
|
-
}
|
|
1247
|
-
if (log.loc) {
|
|
1248
|
-
prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
1249
|
-
}
|
|
1250
|
-
return prefix + log.message;
|
|
1251
|
-
};
|
|
1252
|
-
function relativeId(id) {
|
|
1253
|
-
if (!path$1.isAbsolute(id)) return id;
|
|
1254
|
-
return path$1.relative(path$1.resolve(), id);
|
|
1255
1275
|
}
|
|
1256
1276
|
|
|
1257
1277
|
//#endregion
|
|
1258
1278
|
//#region src/utils/transform-side-effects.ts
|
|
1259
|
-
var import_binding$
|
|
1279
|
+
var import_binding$4 = __toESM(require_binding());
|
|
1260
1280
|
function bindingifySideEffects(sideEffects) {
|
|
1261
1281
|
switch (sideEffects) {
|
|
1262
|
-
case true: return import_binding$
|
|
1263
|
-
case false: return import_binding$
|
|
1264
|
-
case "no-treeshake": return import_binding$
|
|
1282
|
+
case true: return import_binding$4.BindingHookSideEffects.True;
|
|
1283
|
+
case false: return import_binding$4.BindingHookSideEffects.False;
|
|
1284
|
+
case "no-treeshake": return import_binding$4.BindingHookSideEffects.NoTreeshake;
|
|
1265
1285
|
case null:
|
|
1266
1286
|
case undefined: return undefined;
|
|
1267
1287
|
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
@@ -1376,14 +1396,14 @@ class TransformPluginContext extends PluginContext {
|
|
|
1376
1396
|
|
|
1377
1397
|
//#endregion
|
|
1378
1398
|
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1379
|
-
var import_binding$
|
|
1399
|
+
var import_binding$3 = __toESM(require_binding());
|
|
1380
1400
|
function bindingifyPluginHookMeta(options) {
|
|
1381
1401
|
return {order: bindingPluginOrder(options.order)};
|
|
1382
1402
|
}
|
|
1383
1403
|
function bindingPluginOrder(order) {
|
|
1384
1404
|
switch (order) {
|
|
1385
|
-
case "post": return import_binding$
|
|
1386
|
-
case "pre": return import_binding$
|
|
1405
|
+
case "post": return import_binding$3.BindingPluginOrder.Post;
|
|
1406
|
+
case "pre": return import_binding$3.BindingPluginOrder.Pre;
|
|
1387
1407
|
case null:
|
|
1388
1408
|
case undefined: return undefined;
|
|
1389
1409
|
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
@@ -1588,21 +1608,10 @@ function bindingifyLoad(plugin, normalized_options, pluginContextData) {
|
|
|
1588
1608
|
if (typeof ret === "string") {
|
|
1589
1609
|
return {code: ret};
|
|
1590
1610
|
}
|
|
1591
|
-
|
|
1592
|
-
return {
|
|
1593
|
-
code: ret.code,
|
|
1594
|
-
moduleType: ret.moduleType
|
|
1595
|
-
};
|
|
1596
|
-
}
|
|
1597
|
-
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
1598
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
1599
|
-
const directory = path.dirname(id) || ".";
|
|
1600
|
-
const sourceRoot = map.sourceRoot || ".";
|
|
1601
|
-
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
1602
|
-
}
|
|
1611
|
+
let map = preProcessSourceMap(ret, id);
|
|
1603
1612
|
const result = {
|
|
1604
1613
|
code: ret.code,
|
|
1605
|
-
map: bindingifySourcemap$1(map),
|
|
1614
|
+
map: map !== undefined ? bindingifySourcemap$1(map) : undefined,
|
|
1606
1615
|
moduleType: ret.moduleType
|
|
1607
1616
|
};
|
|
1608
1617
|
if (ret.moduleSideEffects !== null) {
|
|
@@ -1618,6 +1627,18 @@ function bindingifyLoad(plugin, normalized_options, pluginContextData) {
|
|
|
1618
1627
|
filter: bindingifyLoadFilter(options.filter)
|
|
1619
1628
|
};
|
|
1620
1629
|
}
|
|
1630
|
+
function preProcessSourceMap(ret, id) {
|
|
1631
|
+
if (!ret.map) {
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
1635
|
+
if (!isEmptySourcemapFiled(map.sources)) {
|
|
1636
|
+
const directory = path.dirname(id) || ".";
|
|
1637
|
+
const sourceRoot = map.sourceRoot || ".";
|
|
1638
|
+
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
1639
|
+
}
|
|
1640
|
+
return map;
|
|
1641
|
+
}
|
|
1621
1642
|
function bindingifyModuleParsed(plugin, options, pluginContextData) {
|
|
1622
1643
|
const hook = plugin.moduleParsed;
|
|
1623
1644
|
if (!hook) {
|
|
@@ -1987,66 +2008,83 @@ class PluginContextData {
|
|
|
1987
2008
|
|
|
1988
2009
|
//#endregion
|
|
1989
2010
|
//#region src/options/bindingify-input-options.ts
|
|
1990
|
-
var import_binding$
|
|
1991
|
-
function bindingifyInputOptions(
|
|
2011
|
+
var import_binding$2 = __toESM(require_binding());
|
|
2012
|
+
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions) {
|
|
1992
2013
|
const pluginContextData = new PluginContextData();
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2014
|
+
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
2015
|
+
const onLog = inputOptions.onLog = getLogger(getObjectPlugins(rawPlugins), getOnLog(inputOptions, logLevel), logLevel);
|
|
2016
|
+
const plugins = rawPlugins.map((plugin) => {
|
|
2017
|
+
if ("_parallel"in plugin) {
|
|
2018
|
+
return undefined;
|
|
2019
|
+
}
|
|
2020
|
+
if (plugin instanceof BuiltinPlugin) {
|
|
2021
|
+
return bindingifyBuiltInPlugin(plugin);
|
|
2022
|
+
}
|
|
2023
|
+
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData);
|
|
2024
|
+
});
|
|
2025
|
+
return {
|
|
2026
|
+
input: bindingifyInput(inputOptions.input),
|
|
2027
|
+
plugins,
|
|
2028
|
+
cwd: inputOptions.cwd ?? process.cwd(),
|
|
2029
|
+
external: bindingifyExternal(inputOptions.external),
|
|
2030
|
+
resolve: bindingifyResolve(inputOptions.resolve),
|
|
2031
|
+
platform: inputOptions.platform,
|
|
2032
|
+
shimMissingExports: inputOptions.shimMissingExports,
|
|
2033
|
+
logLevel: bindingifyLogLevel(logLevel),
|
|
2034
|
+
onLog,
|
|
2035
|
+
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
2036
|
+
moduleTypes: inputOptions.moduleTypes,
|
|
2037
|
+
define: inputOptions.define ? Object.entries(inputOptions.define) : undefined,
|
|
2038
|
+
inject: bindingifyInject(inputOptions.inject),
|
|
2039
|
+
experimental: {
|
|
2040
|
+
strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
|
|
2041
|
+
disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
|
|
2042
|
+
viteMode: inputOptions.experimental?.viteMode
|
|
2043
|
+
},
|
|
2044
|
+
profilerNames: inputOptions?.profilerNames,
|
|
2045
|
+
jsx: bindingifyJsx(inputOptions.jsx),
|
|
2046
|
+
watch: bindingifyWatch(inputOptions.watch),
|
|
2047
|
+
dropLabels: inputOptions.dropLabels
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
function bindingifyExternal(external) {
|
|
2051
|
+
if (external) {
|
|
2052
|
+
if (typeof external === "function") {
|
|
2053
|
+
return (id, importer, isResolved) => {
|
|
2054
|
+
if (id.startsWith("\0")) return false;
|
|
2055
|
+
return external(id, importer, isResolved) ?? false;
|
|
2035
2056
|
};
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2057
|
+
}
|
|
2058
|
+
const externalArr = arraify(external);
|
|
2059
|
+
return (id, _importer, _isResolved) => {
|
|
2060
|
+
return externalArr.some((pat) => {
|
|
2061
|
+
if (pat instanceof RegExp) {
|
|
2062
|
+
return pat.test(id);
|
|
2063
|
+
}
|
|
2064
|
+
return id === pat;
|
|
2044
2065
|
});
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function bindingifyResolve(resolve) {
|
|
2070
|
+
if (resolve) {
|
|
2071
|
+
const { alias: alias, extensionAlias: extensionAlias,...rest } = resolve;
|
|
2072
|
+
return {
|
|
2073
|
+
alias: alias ? (Object.entries(alias)).map(([name, replacement]) => ({
|
|
2074
|
+
find: name,
|
|
2075
|
+
replacements: [replacement]
|
|
2076
|
+
})) : undefined,
|
|
2077
|
+
extensionAlias: extensionAlias ? (Object.entries(extensionAlias)).map(([name, value]) => ({
|
|
2078
|
+
target: name,
|
|
2079
|
+
replacements: value
|
|
2080
|
+
})) : undefined,
|
|
2081
|
+
...rest
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
function bindingifyInject(inject) {
|
|
2086
|
+
if (inject) {
|
|
2087
|
+
return (Object.entries(inject)).map(([alias, item]) => {
|
|
2050
2088
|
if (Array.isArray(item)) {
|
|
2051
2089
|
if (item[1] === "*") {
|
|
2052
2090
|
return {
|
|
@@ -2069,39 +2107,34 @@ function bindingifyInputOptions(options, outputOptions) {
|
|
|
2069
2107
|
from: item
|
|
2070
2108
|
};
|
|
2071
2109
|
}
|
|
2072
|
-
})
|
|
2073
|
-
|
|
2074
|
-
strictExecutionOrder: options.experimental?.strictExecutionOrder,
|
|
2075
|
-
disableLiveBindings: options.experimental?.disableLiveBindings
|
|
2076
|
-
},
|
|
2077
|
-
profilerNames: options?.profilerNames,
|
|
2078
|
-
jsx: bindingifyJsx(options.jsx),
|
|
2079
|
-
watch: bindingifyWatch(options.watch),
|
|
2080
|
-
dropLabels: options.dropLabels
|
|
2081
|
-
};
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2082
2112
|
}
|
|
2083
2113
|
function bindingifyLogLevel(logLevel) {
|
|
2084
2114
|
switch (logLevel) {
|
|
2085
|
-
case "silent": return import_binding$
|
|
2086
|
-
case "
|
|
2087
|
-
case "
|
|
2088
|
-
case "
|
|
2115
|
+
case "silent": return import_binding$2.BindingLogLevel.Silent;
|
|
2116
|
+
case "debug": return import_binding$2.BindingLogLevel.Debug;
|
|
2117
|
+
case "warn": return import_binding$2.BindingLogLevel.Warn;
|
|
2118
|
+
case "info": return import_binding$2.BindingLogLevel.Info;
|
|
2089
2119
|
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
2090
2120
|
}
|
|
2091
2121
|
}
|
|
2092
2122
|
function bindingifyInput(input) {
|
|
2123
|
+
if (input === undefined) {
|
|
2124
|
+
return [];
|
|
2125
|
+
}
|
|
2126
|
+
if (typeof input === "string") {
|
|
2127
|
+
return [{import: input}];
|
|
2128
|
+
}
|
|
2093
2129
|
if (Array.isArray(input)) {
|
|
2094
|
-
return input.map((src) => {
|
|
2095
|
-
return {import: src};
|
|
2096
|
-
});
|
|
2097
|
-
} else {
|
|
2098
|
-
return (Object.entries(input)).map((value) => {
|
|
2099
|
-
return {
|
|
2100
|
-
name: value[0],
|
|
2101
|
-
import: value[1]
|
|
2102
|
-
};
|
|
2103
|
-
});
|
|
2130
|
+
return input.map((src) => ({import: src}));
|
|
2104
2131
|
}
|
|
2132
|
+
return (Object.entries(input)).map((value) => {
|
|
2133
|
+
return {
|
|
2134
|
+
name: value[0],
|
|
2135
|
+
import: value[1]
|
|
2136
|
+
};
|
|
2137
|
+
});
|
|
2105
2138
|
}
|
|
2106
2139
|
function bindingifyJsx(input) {
|
|
2107
2140
|
if (input) {
|
|
@@ -2135,88 +2168,15 @@ function bindingifyWatch(watch$1) {
|
|
|
2135
2168
|
return value;
|
|
2136
2169
|
}
|
|
2137
2170
|
}
|
|
2138
|
-
|
|
2139
|
-
//#endregion
|
|
2140
|
-
//#region src/utils/initialize-parallel-plugins.ts
|
|
2141
|
-
var import_binding$2 = __toESM(require_binding());
|
|
2142
|
-
async function initializeParallelPlugins(plugins) {
|
|
2143
|
-
const pluginInfos = [];
|
|
2144
|
-
for (const [index, plugin] of plugins.entries()) {
|
|
2145
|
-
if ("_parallel"in plugin) {
|
|
2146
|
-
const { fileUrl: fileUrl, options: options } = plugin._parallel;
|
|
2147
|
-
pluginInfos.push({
|
|
2148
|
-
index,
|
|
2149
|
-
fileUrl,
|
|
2150
|
-
options
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
if (pluginInfos.length <= 0) {
|
|
2155
|
-
return undefined;
|
|
2156
|
-
}
|
|
2157
|
-
const count = Math.min(availableParallelism(), 8);
|
|
2158
|
-
const parallelJsPluginRegistry = new import_binding$2.ParallelJsPluginRegistry(count);
|
|
2159
|
-
const registryId = parallelJsPluginRegistry.id;
|
|
2160
|
-
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2161
|
-
const stopWorkers = async () => {
|
|
2162
|
-
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
2163
|
-
};
|
|
2164
|
-
return {
|
|
2165
|
-
registry: parallelJsPluginRegistry,
|
|
2166
|
-
stopWorkers
|
|
2167
|
-
};
|
|
2168
|
-
}
|
|
2169
|
-
function initializeWorkers(registryId, count, pluginInfos) {
|
|
2170
|
-
return Promise.all(Array.from({length: count}, (_, i) => initializeWorker(registryId, pluginInfos, i)));
|
|
2171
|
-
}
|
|
2172
|
-
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2173
|
-
const urlString = import.meta.resolve("#parallel-plugin-worker");
|
|
2174
|
-
const workerData = {
|
|
2175
|
-
registryId,
|
|
2176
|
-
pluginInfos,
|
|
2177
|
-
threadNumber
|
|
2178
|
-
};
|
|
2179
|
-
let worker;
|
|
2180
|
-
try {
|
|
2181
|
-
worker = new Worker(new URL(urlString), {workerData});
|
|
2182
|
-
worker.unref();
|
|
2183
|
-
await new Promise((resolve, reject) => {
|
|
2184
|
-
worker.once("message", async (message) => {
|
|
2185
|
-
if (message.type === "error") {
|
|
2186
|
-
reject(message.error);
|
|
2187
|
-
} else {
|
|
2188
|
-
resolve();
|
|
2189
|
-
}
|
|
2190
|
-
});
|
|
2191
|
-
});
|
|
2192
|
-
return worker;
|
|
2193
|
-
} catch (e) {
|
|
2194
|
-
worker?.terminate();
|
|
2195
|
-
throw e;
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
//#endregion
|
|
2200
|
-
//#region src/utils/async-flatten.ts
|
|
2201
|
-
async function asyncFlatten(array) {
|
|
2202
|
-
do {
|
|
2203
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
2204
|
-
} while (array.some((v) => v?.then));
|
|
2205
|
-
return array;
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
//#endregion
|
|
2209
|
-
//#region src/utils/normalize-plugin-option.ts
|
|
2210
|
-
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
2211
|
-
|
|
2212
|
-
//#endregion
|
|
2213
|
-
//#region src/utils/normalize-tree-shake.ts
|
|
2214
|
-
function normalizeTreeshakeOptions(config) {
|
|
2171
|
+
function bindingifyTreeshakeOptions(config) {
|
|
2215
2172
|
if (config === false) {
|
|
2216
2173
|
return undefined;
|
|
2217
2174
|
}
|
|
2218
2175
|
if (config === true || config === undefined) {
|
|
2219
|
-
return {
|
|
2176
|
+
return {
|
|
2177
|
+
moduleSideEffects: true,
|
|
2178
|
+
annotations: true
|
|
2179
|
+
};
|
|
2220
2180
|
}
|
|
2221
2181
|
let normalizedConfig = {moduleSideEffects: true};
|
|
2222
2182
|
if (config.moduleSideEffects === undefined) {
|
|
@@ -2232,9 +2192,86 @@ function normalizeTreeshakeOptions(config) {
|
|
|
2232
2192
|
} else {
|
|
2233
2193
|
normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
2234
2194
|
}
|
|
2195
|
+
normalizedConfig.annotations = config.annotations ?? true;
|
|
2235
2196
|
return normalizedConfig;
|
|
2236
2197
|
}
|
|
2237
2198
|
|
|
2199
|
+
//#endregion
|
|
2200
|
+
//#region src/options/bindingify-output-options.ts
|
|
2201
|
+
function bindingifyOutputOptions(outputOptions) {
|
|
2202
|
+
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;
|
|
2203
|
+
return {
|
|
2204
|
+
dir,
|
|
2205
|
+
file: file == null ? undefined : file,
|
|
2206
|
+
format: bindingifyFormat(format),
|
|
2207
|
+
exports,
|
|
2208
|
+
hashCharacters,
|
|
2209
|
+
sourcemap: bindingifySourcemap(sourcemap),
|
|
2210
|
+
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
2211
|
+
sourcemapPathTransform,
|
|
2212
|
+
banner: bindingifyAddon(banner),
|
|
2213
|
+
footer: bindingifyAddon(footer),
|
|
2214
|
+
intro: bindingifyAddon(intro),
|
|
2215
|
+
outro: bindingifyAddon(outro),
|
|
2216
|
+
extend: outputOptions.extend,
|
|
2217
|
+
globals,
|
|
2218
|
+
esModule,
|
|
2219
|
+
name,
|
|
2220
|
+
assetFileNames,
|
|
2221
|
+
entryFileNames,
|
|
2222
|
+
chunkFileNames,
|
|
2223
|
+
cssEntryFileNames,
|
|
2224
|
+
cssChunkFileNames,
|
|
2225
|
+
plugins: [],
|
|
2226
|
+
minify: outputOptions.minify,
|
|
2227
|
+
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2228
|
+
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2229
|
+
advancedChunks: outputOptions.advancedChunks
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function bindingifyAddon(configAddon) {
|
|
2233
|
+
return async (chunk) => {
|
|
2234
|
+
if (typeof configAddon === "function") {
|
|
2235
|
+
return configAddon(chunk);
|
|
2236
|
+
}
|
|
2237
|
+
return configAddon || "";
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
function bindingifyFormat(format) {
|
|
2241
|
+
switch (format) {
|
|
2242
|
+
case undefined:
|
|
2243
|
+
case "es":
|
|
2244
|
+
case "esm":
|
|
2245
|
+
case "module": {
|
|
2246
|
+
return "es";
|
|
2247
|
+
}
|
|
2248
|
+
case "cjs":
|
|
2249
|
+
case "commonjs": {
|
|
2250
|
+
return "cjs";
|
|
2251
|
+
}
|
|
2252
|
+
case "iife": {
|
|
2253
|
+
return "iife";
|
|
2254
|
+
}
|
|
2255
|
+
case "umd": {
|
|
2256
|
+
return "umd";
|
|
2257
|
+
}
|
|
2258
|
+
default: unimplemented(`output.format: ${format}`);
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
function bindingifySourcemap(sourcemap) {
|
|
2262
|
+
switch (sourcemap) {
|
|
2263
|
+
case true: return "file";
|
|
2264
|
+
case "inline": return "inline";
|
|
2265
|
+
case false:
|
|
2266
|
+
case undefined: return undefined;
|
|
2267
|
+
case "hidden": return "hidden";
|
|
2268
|
+
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
2272
|
+
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2238
2275
|
//#endregion
|
|
2239
2276
|
//#region ../../node_modules/.pnpm/remeda@2.16.0/node_modules/remeda/dist/chunk-K26VP6CL.js
|
|
2240
2277
|
function u$1(t$1, n, a) {
|
|
@@ -2661,178 +2698,98 @@ function composeJsPlugins(plugins) {
|
|
|
2661
2698
|
}
|
|
2662
2699
|
|
|
2663
2700
|
//#endregion
|
|
2664
|
-
//#region src/utils/
|
|
2665
|
-
async function
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
}
|
|
2671
|
-
const treeshake = normalizeTreeshakeOptions(config.treeshake);
|
|
2672
|
-
const logLevel = config.logLevel || LOG_LEVEL_INFO;
|
|
2673
|
-
const onLog = getLogger(getObjectPlugins(plugins), getOnLog(config, logLevel), logLevel);
|
|
2674
|
-
return {
|
|
2675
|
-
...rest,
|
|
2676
|
-
input: input ? typeof input === "string" ? [input] : input : [],
|
|
2677
|
-
plugins,
|
|
2678
|
-
logLevel,
|
|
2679
|
-
onLog,
|
|
2680
|
-
treeshake
|
|
2681
|
-
};
|
|
2701
|
+
//#region src/utils/async-flatten.ts
|
|
2702
|
+
async function asyncFlatten(array) {
|
|
2703
|
+
do {
|
|
2704
|
+
array = (await Promise.all(array)).flat(Infinity);
|
|
2705
|
+
} while (array.some((v) => v?.then));
|
|
2706
|
+
return array;
|
|
2682
2707
|
}
|
|
2683
2708
|
|
|
2684
2709
|
//#endregion
|
|
2685
|
-
//#region src/utils/normalize-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
esModule: esModule ?? "if-default-prop",
|
|
2702
|
-
globals: globals ?? {},
|
|
2703
|
-
entryFileNames: entryFileNames ?? "[name].js",
|
|
2704
|
-
chunkFileNames: chunkFileNames ?? "[name]-[hash].js",
|
|
2705
|
-
cssEntryFileNames: cssEntryFileNames ?? "[name].css",
|
|
2706
|
-
cssChunkFileNames: cssChunkFileNames ?? "[name]-[hash].css",
|
|
2707
|
-
assetFileNames: assetFileNames ?? "assets/[name]-[hash][extname]",
|
|
2708
|
-
plugins: [],
|
|
2709
|
-
minify: opts.minify,
|
|
2710
|
-
extend: opts.extend,
|
|
2711
|
-
name,
|
|
2712
|
-
externalLiveBindings: opts.externalLiveBindings ?? true,
|
|
2713
|
-
inlineDynamicImports: opts.inlineDynamicImports ?? false,
|
|
2714
|
-
advancedChunks: opts.advancedChunks
|
|
2715
|
-
};
|
|
2716
|
-
}
|
|
2717
|
-
function getFormat(format) {
|
|
2718
|
-
switch (format) {
|
|
2719
|
-
case undefined:
|
|
2720
|
-
case "es":
|
|
2721
|
-
case "esm":
|
|
2722
|
-
case "module": {
|
|
2723
|
-
return "es";
|
|
2724
|
-
}
|
|
2725
|
-
case "cjs":
|
|
2726
|
-
case "commonjs": {
|
|
2727
|
-
return "cjs";
|
|
2728
|
-
}
|
|
2729
|
-
case "iife": {
|
|
2730
|
-
return "iife";
|
|
2731
|
-
}
|
|
2732
|
-
case "umd": {
|
|
2733
|
-
return "umd";
|
|
2710
|
+
//#region src/utils/normalize-plugin-option.ts
|
|
2711
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
2712
|
+
|
|
2713
|
+
//#endregion
|
|
2714
|
+
//#region src/utils/initialize-parallel-plugins.ts
|
|
2715
|
+
var import_binding$1 = __toESM(require_binding());
|
|
2716
|
+
async function initializeParallelPlugins(plugins) {
|
|
2717
|
+
const pluginInfos = [];
|
|
2718
|
+
for (const [index, plugin] of plugins.entries()) {
|
|
2719
|
+
if ("_parallel"in plugin) {
|
|
2720
|
+
const { fileUrl: fileUrl, options: options } = plugin._parallel;
|
|
2721
|
+
pluginInfos.push({
|
|
2722
|
+
index,
|
|
2723
|
+
fileUrl,
|
|
2724
|
+
options
|
|
2725
|
+
});
|
|
2734
2726
|
}
|
|
2735
|
-
default: unimplemented(`output.format: ${format}`);
|
|
2736
2727
|
}
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2728
|
+
if (pluginInfos.length <= 0) {
|
|
2729
|
+
return undefined;
|
|
2730
|
+
}
|
|
2731
|
+
const count = Math.min(availableParallelism(), 8);
|
|
2732
|
+
const parallelJsPluginRegistry = new import_binding$1.ParallelJsPluginRegistry(count);
|
|
2733
|
+
const registryId = parallelJsPluginRegistry.id;
|
|
2734
|
+
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
2735
|
+
const stopWorkers = async () => {
|
|
2736
|
+
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
2745
2737
|
};
|
|
2746
|
-
};
|
|
2747
|
-
|
|
2748
|
-
//#endregion
|
|
2749
|
-
//#region src/options/bindingify-output-options.ts
|
|
2750
|
-
function bindingifyOutputOptions(outputOptions) {
|
|
2751
|
-
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;
|
|
2752
2738
|
return {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
format: function() {
|
|
2756
|
-
switch (format) {
|
|
2757
|
-
case "es": return "es";
|
|
2758
|
-
case "cjs": return "cjs";
|
|
2759
|
-
case "iife": return "iife";
|
|
2760
|
-
case "umd": return "umd";
|
|
2761
|
-
}
|
|
2762
|
-
}(),
|
|
2763
|
-
exports,
|
|
2764
|
-
hashCharacters,
|
|
2765
|
-
sourcemap: bindingifySourcemap(sourcemap),
|
|
2766
|
-
sourcemapIgnoreList,
|
|
2767
|
-
sourcemapPathTransform,
|
|
2768
|
-
banner,
|
|
2769
|
-
footer,
|
|
2770
|
-
intro,
|
|
2771
|
-
outro,
|
|
2772
|
-
extend: outputOptions.extend,
|
|
2773
|
-
globals,
|
|
2774
|
-
esModule: bindingifyEsModule(esModule),
|
|
2775
|
-
name,
|
|
2776
|
-
assetFileNames,
|
|
2777
|
-
entryFileNames,
|
|
2778
|
-
chunkFileNames,
|
|
2779
|
-
cssEntryFileNames,
|
|
2780
|
-
cssChunkFileNames,
|
|
2781
|
-
plugins: [],
|
|
2782
|
-
minify: outputOptions.minify,
|
|
2783
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2784
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2785
|
-
advancedChunks: outputOptions.advancedChunks
|
|
2739
|
+
registry: parallelJsPluginRegistry,
|
|
2740
|
+
stopWorkers
|
|
2786
2741
|
};
|
|
2787
2742
|
}
|
|
2788
|
-
function
|
|
2789
|
-
|
|
2790
|
-
case true: return "file";
|
|
2791
|
-
case "inline": return "inline";
|
|
2792
|
-
case false:
|
|
2793
|
-
case undefined: return undefined;
|
|
2794
|
-
case "hidden": return "hidden";
|
|
2795
|
-
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
2796
|
-
}
|
|
2743
|
+
function initializeWorkers(registryId, count, pluginInfos) {
|
|
2744
|
+
return Promise.all(Array.from({length: count}, (_, i) => initializeWorker(registryId, pluginInfos, i)));
|
|
2797
2745
|
}
|
|
2798
|
-
function
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2746
|
+
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
2747
|
+
const urlString = import.meta.resolve("#parallel-plugin-worker");
|
|
2748
|
+
const workerData = {
|
|
2749
|
+
registryId,
|
|
2750
|
+
pluginInfos,
|
|
2751
|
+
threadNumber
|
|
2752
|
+
};
|
|
2753
|
+
let worker;
|
|
2754
|
+
try {
|
|
2755
|
+
worker = new Worker(new URL(urlString), {workerData});
|
|
2756
|
+
worker.unref();
|
|
2757
|
+
await new Promise((resolve, reject) => {
|
|
2758
|
+
worker.once("message", async (message) => {
|
|
2759
|
+
if (message.type === "error") {
|
|
2760
|
+
reject(message.error);
|
|
2761
|
+
} else {
|
|
2762
|
+
resolve();
|
|
2763
|
+
}
|
|
2764
|
+
});
|
|
2765
|
+
});
|
|
2766
|
+
return worker;
|
|
2767
|
+
} catch (e) {
|
|
2768
|
+
worker?.terminate();
|
|
2769
|
+
throw e;
|
|
2804
2770
|
}
|
|
2805
2771
|
}
|
|
2806
2772
|
|
|
2807
|
-
//#endregion
|
|
2808
|
-
//#region src/treeshake/module-side-effects.ts
|
|
2809
|
-
const ModuleSideEffectsRuleSchema = (z.object({
|
|
2810
|
-
test: (z.instanceof(RegExp)).optional(),
|
|
2811
|
-
external: (z.boolean()).optional(),
|
|
2812
|
-
sideEffects: z.boolean()
|
|
2813
|
-
})).refine((data) => {
|
|
2814
|
-
return data.test !== undefined || data.external !== undefined;
|
|
2815
|
-
}, "Either `test` or `external` should be set.");
|
|
2816
|
-
const ModuleSideEffectsOptionSchema = ((z.boolean()).or(z.array(ModuleSideEffectsRuleSchema))).or(z.literal("no-external"));
|
|
2817
|
-
const TreeshakingOptionsSchema = ((z.object({moduleSideEffects: ModuleSideEffectsOptionSchema.optional()})).passthrough()).or(z.boolean());
|
|
2818
|
-
|
|
2819
2773
|
//#endregion
|
|
2820
2774
|
//#region src/utils/create-bundler.ts
|
|
2821
|
-
var import_binding
|
|
2775
|
+
var import_binding = __toESM(require_binding());
|
|
2822
2776
|
async function createBundler(inputOptions, outputOptions) {
|
|
2823
2777
|
const pluginDriver = new PluginDriver();
|
|
2824
2778
|
inputOptions = await pluginDriver.callOptionsHook(inputOptions);
|
|
2825
2779
|
if (inputOptions.treeshake !== undefined) {
|
|
2826
2780
|
TreeshakingOptionsSchema.parse(inputOptions.treeshake);
|
|
2827
2781
|
}
|
|
2828
|
-
|
|
2829
|
-
|
|
2782
|
+
let plugins = await normalizePluginOption(inputOptions.plugins);
|
|
2783
|
+
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) {
|
|
2784
|
+
plugins = composeJsPlugins(plugins);
|
|
2785
|
+
}
|
|
2786
|
+
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
2830
2787
|
try {
|
|
2831
|
-
outputOptions = pluginDriver.callOutputOptionsHook(
|
|
2832
|
-
const
|
|
2833
|
-
const
|
|
2788
|
+
outputOptions = pluginDriver.callOutputOptionsHook(plugins, outputOptions);
|
|
2789
|
+
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions);
|
|
2790
|
+
const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
|
|
2834
2791
|
return {
|
|
2835
|
-
bundler: new import_binding
|
|
2792
|
+
bundler: new import_binding.Bundler(bindingInputOptions, bindingOutputOptions, parallelPluginInitResult?.registry),
|
|
2836
2793
|
stopWorkers: parallelPluginInitResult?.stopWorkers
|
|
2837
2794
|
};
|
|
2838
2795
|
} catch (e) {
|
|
@@ -2881,12 +2838,12 @@ class RolldownBuild {
|
|
|
2881
2838
|
|
|
2882
2839
|
//#endregion
|
|
2883
2840
|
//#region src/watcher.ts
|
|
2884
|
-
var import_binding = __toESM(require_binding());
|
|
2885
2841
|
class Watcher {
|
|
2886
2842
|
closed;
|
|
2887
2843
|
controller;
|
|
2888
2844
|
inner;
|
|
2889
2845
|
stopWorkers;
|
|
2846
|
+
listeners = new Map();
|
|
2890
2847
|
constructor(inner, stopWorkers) {
|
|
2891
2848
|
this.closed = false;
|
|
2892
2849
|
this.controller = new AbortController();
|
|
@@ -2900,48 +2857,11 @@ class Watcher {
|
|
|
2900
2857
|
this.controller.abort();
|
|
2901
2858
|
}
|
|
2902
2859
|
on(event, listener) {
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
break;
|
|
2909
|
-
case "event":
|
|
2910
|
-
this.inner.on(import_binding.BindingWatcherEvent.Event, async (data) => {
|
|
2911
|
-
const code = data.bundleEventKind();
|
|
2912
|
-
switch (code) {
|
|
2913
|
-
case "BUNDLE_END":
|
|
2914
|
-
const { duration: duration, output: output } = data.bundleEndData();
|
|
2915
|
-
await listener({
|
|
2916
|
-
code: "BUNDLE_END",
|
|
2917
|
-
duration,
|
|
2918
|
-
output: [output]
|
|
2919
|
-
});
|
|
2920
|
-
break;
|
|
2921
|
-
case "ERROR":
|
|
2922
|
-
await listener({
|
|
2923
|
-
code: "ERROR",
|
|
2924
|
-
error: {message: data.error()}
|
|
2925
|
-
});
|
|
2926
|
-
break;
|
|
2927
|
-
default:
|
|
2928
|
-
await listener({code});
|
|
2929
|
-
break;
|
|
2930
|
-
}
|
|
2931
|
-
});
|
|
2932
|
-
break;
|
|
2933
|
-
case "restart":
|
|
2934
|
-
this.inner.on(import_binding.BindingWatcherEvent.ReStart, async () => {
|
|
2935
|
-
await listener();
|
|
2936
|
-
});
|
|
2937
|
-
break;
|
|
2938
|
-
case "change":
|
|
2939
|
-
this.inner.on(import_binding.BindingWatcherEvent.Change, async (data) => {
|
|
2940
|
-
const { path: path$2, kind: kind } = data.watchChangeData();
|
|
2941
|
-
await listener(path$2, {event: kind});
|
|
2942
|
-
});
|
|
2943
|
-
break;
|
|
2944
|
-
default: throw new Error(`Unknown event: ${event}`);
|
|
2860
|
+
const listeners = this.listeners.get(event);
|
|
2861
|
+
if (listeners) {
|
|
2862
|
+
listeners.push(listener);
|
|
2863
|
+
} else {
|
|
2864
|
+
this.listeners.set(event, [listener]);
|
|
2945
2865
|
}
|
|
2946
2866
|
return this;
|
|
2947
2867
|
}
|
|
@@ -2950,7 +2870,51 @@ class Watcher {
|
|
|
2950
2870
|
this.controller.signal.addEventListener("abort", () => {
|
|
2951
2871
|
clearInterval(timer);
|
|
2952
2872
|
});
|
|
2953
|
-
process.nextTick(() => this.inner.start()
|
|
2873
|
+
process.nextTick(() => this.inner.start(async (event) => {
|
|
2874
|
+
const listeners = this.listeners.get(event.eventKind());
|
|
2875
|
+
if (listeners) {
|
|
2876
|
+
switch (event.eventKind()) {
|
|
2877
|
+
case "close":
|
|
2878
|
+
case "restart":
|
|
2879
|
+
for (const listener of listeners) {
|
|
2880
|
+
await listener();
|
|
2881
|
+
}
|
|
2882
|
+
break;
|
|
2883
|
+
case "event":
|
|
2884
|
+
for (const listener of listeners) {
|
|
2885
|
+
const code = event.bundleEventKind();
|
|
2886
|
+
switch (code) {
|
|
2887
|
+
case "BUNDLE_END":
|
|
2888
|
+
const { duration: duration, output: output } = event.bundleEndData();
|
|
2889
|
+
await listener({
|
|
2890
|
+
code: "BUNDLE_END",
|
|
2891
|
+
duration,
|
|
2892
|
+
output: [output]
|
|
2893
|
+
});
|
|
2894
|
+
break;
|
|
2895
|
+
case "ERROR":
|
|
2896
|
+
const errors = event.errors();
|
|
2897
|
+
await listener({
|
|
2898
|
+
code: "ERROR",
|
|
2899
|
+
error: normalizeErrors(errors)
|
|
2900
|
+
});
|
|
2901
|
+
break;
|
|
2902
|
+
default:
|
|
2903
|
+
await listener({code});
|
|
2904
|
+
break;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
break;
|
|
2908
|
+
case "change":
|
|
2909
|
+
for (const listener of listeners) {
|
|
2910
|
+
const { path: path$2, kind: kind } = event.watchChangeData();
|
|
2911
|
+
await listener(path$2, {event: kind});
|
|
2912
|
+
}
|
|
2913
|
+
break;
|
|
2914
|
+
default: throw new Error(`Unknown event: ${event}`);
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
}));
|
|
2954
2918
|
}
|
|
2955
2919
|
}
|
|
2956
2920
|
|