rolldown 1.0.0-beta.7-commit.51b53fd → 1.0.0-beta.7-commit.25f3c61
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/bin/cli.js +1 -1
- package/dist/cjs/cli.cjs +457 -457
- package/dist/cjs/experimental-index.cjs +24 -24
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/cjs/parse-ast-index.cjs +1 -1
- package/dist/esm/cli.mjs +457 -457
- package/dist/esm/experimental-index.mjs +24 -24
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +2 -2
- package/dist/esm/parse-ast-index.mjs +1 -1
- package/dist/shared/{parse-ast-index-DbQWN9pL.cjs → parse-ast-index-0ei4fTjl.cjs} +253 -252
- package/dist/shared/{parse-ast-index-B-UemHTj.mjs → parse-ast-index-DNOUVcBy.mjs} +253 -252
- package/dist/shared/{src-eC0JqPTa.cjs → src-BPcsb-4N.cjs} +464 -464
- package/dist/shared/{src-DJ0d0UY6.mjs → src-DllTyFDp.mjs} +464 -464
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/binding.d.ts +5 -1
- package/dist/types/builtin-plugin/constructors.d.ts +1 -1
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -1
- package/dist/types/cli/arguments/index.d.ts +1 -1
- package/dist/types/cli/arguments/normalize.d.ts +5 -1
- package/dist/types/experimental-index.d.ts +5 -5
- package/dist/types/index.d.ts +23 -23
- package/dist/types/log/logger.d.ts +2 -2
- package/dist/types/options/generated/checks-options.d.ts +11 -11
- package/dist/types/options/input-options.d.ts +4 -4
- package/dist/types/options/normalized-input-options.d.ts +2 -2
- package/dist/types/options/normalized-output-options.d.ts +1 -1
- package/dist/types/options/output-options.d.ts +2 -2
- package/dist/types/parallel-plugin.d.ts +1 -1
- package/dist/types/plugin/bindingify-build-hooks.d.ts +1 -1
- package/dist/types/plugin/bindingify-hook-filter.d.ts +2 -2
- package/dist/types/plugin/bindingify-output-hooks.d.ts +2 -2
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +1 -1
- package/dist/types/plugin/bindingify-plugin.d.ts +3 -3
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +1 -1
- package/dist/types/plugin/hook-filter.d.ts +1 -1
- package/dist/types/plugin/index.d.ts +15 -16
- package/dist/types/plugin/plugin-context-data.d.ts +2 -2
- package/dist/types/plugin/plugin-context.d.ts +7 -7
- package/dist/types/plugin/plugin-driver.d.ts +2 -2
- package/dist/types/plugin/transform-plugin-context.d.ts +4 -4
- package/dist/types/types/rolldown-output.d.ts +1 -1
- package/dist/types/utils/bindingify-input-options.d.ts +3 -3
- package/dist/types/utils/create-bundler-option.d.ts +1 -1
- package/dist/types/utils/define-config.d.ts +1 -1
- package/dist/types/utils/initialize-parallel-plugins.d.ts +1 -1
- package/dist/types/utils/normalize-hook.d.ts +1 -1
- package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
- package/dist/types/utils/transform-module-info.d.ts +2 -2
- package/dist/types/utils/transform-to-rollup-output.d.ts +2 -2
- package/package.json +25 -26
|
@@ -1,29 +1,98 @@
|
|
|
1
|
-
import { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-
|
|
1
|
+
import { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-DNOUVcBy.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import * as v from "valibot";
|
|
4
3
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
4
|
+
import * as v from "valibot";
|
|
5
5
|
import { Buffer } from "node:buffer";
|
|
6
|
-
import { Worker } from "node:worker_threads";
|
|
7
6
|
import { availableParallelism } from "node:os";
|
|
7
|
+
import { Worker } from "node:worker_threads";
|
|
8
8
|
|
|
9
|
-
//#region
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
//#region package.json
|
|
10
|
+
var version = "1.0.0-beta.7-commit.25f3c61";
|
|
11
|
+
var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/builtin-plugin/utils.ts
|
|
15
|
+
function makeBuiltinPluginCallable(plugin) {
|
|
16
|
+
let callablePlugin = new import_binding.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
17
|
+
const wrappedPlugin = plugin;
|
|
18
|
+
for (const key in callablePlugin) wrappedPlugin[key] = function(...args) {
|
|
19
|
+
return callablePlugin[key](...args);
|
|
20
|
+
};
|
|
21
|
+
return wrappedPlugin;
|
|
22
|
+
}
|
|
23
|
+
function bindingifyBuiltInPlugin(plugin) {
|
|
24
|
+
return {
|
|
25
|
+
__name: plugin.name,
|
|
26
|
+
options: plugin._options
|
|
27
|
+
};
|
|
12
28
|
}
|
|
13
29
|
|
|
14
30
|
//#endregion
|
|
15
|
-
//#region src/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const logLevelPriority = {
|
|
22
|
-
[LOG_LEVEL_DEBUG]: 0,
|
|
23
|
-
[LOG_LEVEL_INFO]: 1,
|
|
24
|
-
[LOG_LEVEL_WARN]: 2,
|
|
25
|
-
[LOG_LEVEL_SILENT]: 3
|
|
31
|
+
//#region src/builtin-plugin/constructors.ts
|
|
32
|
+
var BuiltinPlugin = class {
|
|
33
|
+
constructor(name, _options) {
|
|
34
|
+
this.name = name;
|
|
35
|
+
this._options = _options;
|
|
36
|
+
}
|
|
26
37
|
};
|
|
38
|
+
function modulePreloadPolyfillPlugin(config) {
|
|
39
|
+
return new BuiltinPlugin("builtin:module-preload-polyfill", config);
|
|
40
|
+
}
|
|
41
|
+
function dynamicImportVarsPlugin() {
|
|
42
|
+
return new BuiltinPlugin("builtin:dynamic-import-vars");
|
|
43
|
+
}
|
|
44
|
+
function importGlobPlugin(config) {
|
|
45
|
+
return new BuiltinPlugin("builtin:import-glob", config);
|
|
46
|
+
}
|
|
47
|
+
function manifestPlugin(config) {
|
|
48
|
+
return new BuiltinPlugin("builtin:manifest", config);
|
|
49
|
+
}
|
|
50
|
+
function wasmHelperPlugin() {
|
|
51
|
+
return new BuiltinPlugin("builtin:wasm-helper");
|
|
52
|
+
}
|
|
53
|
+
function wasmFallbackPlugin() {
|
|
54
|
+
return new BuiltinPlugin("builtin:wasm-fallback");
|
|
55
|
+
}
|
|
56
|
+
function loadFallbackPlugin() {
|
|
57
|
+
return new BuiltinPlugin("builtin:load-fallback");
|
|
58
|
+
}
|
|
59
|
+
function jsonPlugin(config) {
|
|
60
|
+
return new BuiltinPlugin("builtin:json", config);
|
|
61
|
+
}
|
|
62
|
+
function buildImportAnalysisPlugin(config) {
|
|
63
|
+
return new BuiltinPlugin("builtin:build-import-analysis", config);
|
|
64
|
+
}
|
|
65
|
+
function viteResolvePlugin(config) {
|
|
66
|
+
const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", {
|
|
67
|
+
...config,
|
|
68
|
+
runtime: process.versions.deno ? "deno" : process.versions.bun ? "bun" : "node"
|
|
69
|
+
});
|
|
70
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
71
|
+
}
|
|
72
|
+
function moduleFederationPlugin(config) {
|
|
73
|
+
return new BuiltinPlugin("builtin:module-federation", {
|
|
74
|
+
...config,
|
|
75
|
+
remotes: config.remotes && Object.entries(config.remotes).map(([name, remote]) => {
|
|
76
|
+
if (typeof remote === "string") {
|
|
77
|
+
const [entryGlobalName] = remote.split("@");
|
|
78
|
+
const entry = remote.replace(entryGlobalName + "@", "");
|
|
79
|
+
return {
|
|
80
|
+
entry,
|
|
81
|
+
name,
|
|
82
|
+
entryGlobalName
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...remote,
|
|
87
|
+
name: remote.name ?? name
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
manifest: config.manifest === false ? void 0 : config.manifest === true ? {} : config.manifest
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function isolatedDeclarationPlugin(config) {
|
|
94
|
+
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
95
|
+
}
|
|
27
96
|
|
|
28
97
|
//#endregion
|
|
29
98
|
//#region src/utils/misc.ts
|
|
@@ -47,23 +116,18 @@ function unsupported(info) {
|
|
|
47
116
|
function noop(..._args) {}
|
|
48
117
|
|
|
49
118
|
//#endregion
|
|
50
|
-
//#region src/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
meta: { order }
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
unreachable("Invalid hook type");
|
|
66
|
-
}
|
|
119
|
+
//#region src/log/logging.ts
|
|
120
|
+
const LOG_LEVEL_SILENT = "silent";
|
|
121
|
+
const LOG_LEVEL_ERROR = "error";
|
|
122
|
+
const LOG_LEVEL_WARN = "warn";
|
|
123
|
+
const LOG_LEVEL_INFO = "info";
|
|
124
|
+
const LOG_LEVEL_DEBUG = "debug";
|
|
125
|
+
const logLevelPriority = {
|
|
126
|
+
[LOG_LEVEL_DEBUG]: 0,
|
|
127
|
+
[LOG_LEVEL_INFO]: 1,
|
|
128
|
+
[LOG_LEVEL_WARN]: 2,
|
|
129
|
+
[LOG_LEVEL_SILENT]: 3
|
|
130
|
+
};
|
|
67
131
|
|
|
68
132
|
//#endregion
|
|
69
133
|
//#region src/log/log-handler.ts
|
|
@@ -157,96 +221,22 @@ function relativeId(id) {
|
|
|
157
221
|
}
|
|
158
222
|
|
|
159
223
|
//#endregion
|
|
160
|
-
//#region src/
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
return wrappedPlugin;
|
|
168
|
-
}
|
|
169
|
-
function bindingifyBuiltInPlugin(plugin) {
|
|
170
|
-
return {
|
|
171
|
-
__name: plugin.name,
|
|
172
|
-
options: plugin._options
|
|
224
|
+
//#region src/utils/normalize-hook.ts
|
|
225
|
+
function normalizeHook(hook) {
|
|
226
|
+
if (typeof hook === "function" || typeof hook === "string") return {
|
|
227
|
+
handler: hook,
|
|
228
|
+
options: {},
|
|
229
|
+
meta: {}
|
|
173
230
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this._options = _options;
|
|
231
|
+
if (typeof hook === "object" && hook !== null) {
|
|
232
|
+
const { handler, order,...options } = hook;
|
|
233
|
+
return {
|
|
234
|
+
handler,
|
|
235
|
+
options,
|
|
236
|
+
meta: { order }
|
|
237
|
+
};
|
|
182
238
|
}
|
|
183
|
-
|
|
184
|
-
function modulePreloadPolyfillPlugin(config) {
|
|
185
|
-
return new BuiltinPlugin("builtin:module-preload-polyfill", config);
|
|
186
|
-
}
|
|
187
|
-
function dynamicImportVarsPlugin() {
|
|
188
|
-
return new BuiltinPlugin("builtin:dynamic-import-vars");
|
|
189
|
-
}
|
|
190
|
-
function importGlobPlugin(config) {
|
|
191
|
-
return new BuiltinPlugin("builtin:import-glob", config);
|
|
192
|
-
}
|
|
193
|
-
function manifestPlugin(config) {
|
|
194
|
-
return new BuiltinPlugin("builtin:manifest", config);
|
|
195
|
-
}
|
|
196
|
-
function wasmHelperPlugin() {
|
|
197
|
-
return new BuiltinPlugin("builtin:wasm-helper");
|
|
198
|
-
}
|
|
199
|
-
function wasmFallbackPlugin() {
|
|
200
|
-
return new BuiltinPlugin("builtin:wasm-fallback");
|
|
201
|
-
}
|
|
202
|
-
function loadFallbackPlugin() {
|
|
203
|
-
return new BuiltinPlugin("builtin:load-fallback");
|
|
204
|
-
}
|
|
205
|
-
function jsonPlugin(config) {
|
|
206
|
-
return new BuiltinPlugin("builtin:json", config);
|
|
207
|
-
}
|
|
208
|
-
function buildImportAnalysisPlugin(config) {
|
|
209
|
-
return new BuiltinPlugin("builtin:build-import-analysis", config);
|
|
210
|
-
}
|
|
211
|
-
function viteResolvePlugin(config) {
|
|
212
|
-
const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", {
|
|
213
|
-
...config,
|
|
214
|
-
runtime: process.versions.deno ? "deno" : process.versions.bun ? "bun" : "node"
|
|
215
|
-
});
|
|
216
|
-
return makeBuiltinPluginCallable(builtinPlugin);
|
|
217
|
-
}
|
|
218
|
-
function moduleFederationPlugin(config) {
|
|
219
|
-
return new BuiltinPlugin("builtin:module-federation", {
|
|
220
|
-
...config,
|
|
221
|
-
remotes: config.remotes && Object.entries(config.remotes).map(([name, remote]) => {
|
|
222
|
-
if (typeof remote === "string") {
|
|
223
|
-
const [entryGlobalName] = remote.split("@");
|
|
224
|
-
const entry = remote.replace(entryGlobalName + "@", "");
|
|
225
|
-
return {
|
|
226
|
-
entry,
|
|
227
|
-
name,
|
|
228
|
-
entryGlobalName
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
...remote,
|
|
233
|
-
name: remote.name ?? name
|
|
234
|
-
};
|
|
235
|
-
}),
|
|
236
|
-
manifest: config.manifest === false ? void 0 : config.manifest === true ? {} : config.manifest
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function isolatedDeclarationPlugin(config) {
|
|
240
|
-
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/utils/async-flatten.ts
|
|
245
|
-
async function asyncFlatten(array) {
|
|
246
|
-
do
|
|
247
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
248
|
-
while (array.some((v$1) => v$1?.then));
|
|
249
|
-
return array;
|
|
239
|
+
unreachable("Invalid hook type");
|
|
250
240
|
}
|
|
251
241
|
|
|
252
242
|
//#endregion
|
|
@@ -308,6 +298,15 @@ const DEFINED_HOOK_NAMES = {
|
|
|
308
298
|
[ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
|
|
309
299
|
};
|
|
310
300
|
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/utils/async-flatten.ts
|
|
303
|
+
async function asyncFlatten(array) {
|
|
304
|
+
do
|
|
305
|
+
array = (await Promise.all(array)).flat(Infinity);
|
|
306
|
+
while (array.some((v$1) => v$1?.then));
|
|
307
|
+
return array;
|
|
308
|
+
}
|
|
309
|
+
|
|
311
310
|
//#endregion
|
|
312
311
|
//#region src/utils/normalize-plugin-option.ts
|
|
313
312
|
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
@@ -796,22 +795,39 @@ function getJsonSchema() {
|
|
|
796
795
|
}
|
|
797
796
|
|
|
798
797
|
//#endregion
|
|
799
|
-
//#region src/
|
|
800
|
-
|
|
801
|
-
return bindingAssetSource$1.inner;
|
|
802
|
-
}
|
|
803
|
-
function bindingAssetSource(source) {
|
|
804
|
-
return { inner: source };
|
|
805
|
-
}
|
|
798
|
+
//#region src/constants/plugin-context.ts
|
|
799
|
+
const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
806
800
|
|
|
807
801
|
//#endregion
|
|
808
|
-
//#region src/
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
802
|
+
//#region src/options/normalized-input-options.ts
|
|
803
|
+
var NormalizedInputOptionsImpl = class {
|
|
804
|
+
inner;
|
|
805
|
+
constructor(inner, onLog) {
|
|
806
|
+
this.onLog = onLog;
|
|
807
|
+
this.inner = inner;
|
|
808
|
+
}
|
|
809
|
+
get shimMissingExports() {
|
|
810
|
+
return this.inner.shimMissingExports;
|
|
811
|
+
}
|
|
812
|
+
get input() {
|
|
813
|
+
return this.inner.input;
|
|
814
|
+
}
|
|
815
|
+
get cwd() {
|
|
816
|
+
return this.inner.cwd ?? void 0;
|
|
817
|
+
}
|
|
818
|
+
get platform() {
|
|
819
|
+
return this.inner.platform;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/types/sourcemap.ts
|
|
825
|
+
function bindingifySourcemap$1(map) {
|
|
826
|
+
if (map == null) return;
|
|
827
|
+
return { inner: typeof map === "string" ? map : {
|
|
828
|
+
file: map.file ?? void 0,
|
|
829
|
+
mappings: map.mappings,
|
|
830
|
+
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
|
|
815
831
|
sources: map.sources?.map((s) => s ?? void 0),
|
|
816
832
|
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
|
|
817
833
|
names: map.names,
|
|
@@ -871,221 +887,21 @@ function joinNewLine(s1, s2) {
|
|
|
871
887
|
}
|
|
872
888
|
|
|
873
889
|
//#endregion
|
|
874
|
-
//#region src/utils/
|
|
875
|
-
function
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
get renderedLength() {
|
|
881
|
-
return bindingRenderedModule.code?.length || 0;
|
|
882
|
-
},
|
|
883
|
-
get renderedExports() {
|
|
884
|
-
return bindingRenderedModule.renderedExports;
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
//#endregion
|
|
890
|
-
//#region src/utils/transform-rendered-chunk.ts
|
|
891
|
-
function transformRenderedChunk(chunk) {
|
|
892
|
-
let modules = null;
|
|
893
|
-
return {
|
|
894
|
-
get name() {
|
|
895
|
-
return chunk.name;
|
|
896
|
-
},
|
|
897
|
-
get isEntry() {
|
|
898
|
-
return chunk.isEntry;
|
|
899
|
-
},
|
|
900
|
-
get isDynamicEntry() {
|
|
901
|
-
return chunk.isDynamicEntry;
|
|
902
|
-
},
|
|
903
|
-
get facadeModuleId() {
|
|
904
|
-
return chunk.facadeModuleId;
|
|
905
|
-
},
|
|
906
|
-
get moduleIds() {
|
|
907
|
-
return chunk.moduleIds;
|
|
908
|
-
},
|
|
909
|
-
get exports() {
|
|
910
|
-
return chunk.exports;
|
|
911
|
-
},
|
|
912
|
-
get fileName() {
|
|
913
|
-
return chunk.fileName;
|
|
914
|
-
},
|
|
915
|
-
get imports() {
|
|
916
|
-
return chunk.imports;
|
|
917
|
-
},
|
|
918
|
-
get dynamicImports() {
|
|
919
|
-
return chunk.dynamicImports;
|
|
920
|
-
},
|
|
921
|
-
get modules() {
|
|
922
|
-
if (!modules) modules = transformChunkModules(chunk.modules);
|
|
923
|
-
return modules;
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
function transformChunkModules(modules) {
|
|
928
|
-
const result = {};
|
|
929
|
-
for (let i = 0; i < modules.values.length; i++) {
|
|
930
|
-
let key = modules.keys[i];
|
|
931
|
-
const mod = modules.values[i];
|
|
932
|
-
result[key] = transformToRenderedModule(mod);
|
|
890
|
+
//#region src/utils/resolved-external.ts
|
|
891
|
+
function transformResolvedExternal(bindingResolvedExternal$1) {
|
|
892
|
+
switch (bindingResolvedExternal$1.type) {
|
|
893
|
+
case "Bool": return bindingResolvedExternal$1.field0;
|
|
894
|
+
case "Absolute": return "absolute";
|
|
895
|
+
case "Relative": unreachable(`The PluginContext resolve result external couldn't be 'relative'`);
|
|
933
896
|
}
|
|
934
|
-
return result;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
//#endregion
|
|
938
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
939
|
-
function transformToRollupSourceMap(map) {
|
|
940
|
-
const parsed = JSON.parse(map);
|
|
941
|
-
const obj = {
|
|
942
|
-
...parsed,
|
|
943
|
-
toString() {
|
|
944
|
-
return JSON.stringify(obj);
|
|
945
|
-
},
|
|
946
|
-
toUrl() {
|
|
947
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
return obj;
|
|
951
|
-
}
|
|
952
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
953
|
-
const chunk = {
|
|
954
|
-
type: "chunk",
|
|
955
|
-
get code() {
|
|
956
|
-
return bindingChunk.code;
|
|
957
|
-
},
|
|
958
|
-
fileName: bindingChunk.fileName,
|
|
959
|
-
name: bindingChunk.name,
|
|
960
|
-
get modules() {
|
|
961
|
-
return transformChunkModules(bindingChunk.modules);
|
|
962
|
-
},
|
|
963
|
-
get imports() {
|
|
964
|
-
return bindingChunk.imports;
|
|
965
|
-
},
|
|
966
|
-
get dynamicImports() {
|
|
967
|
-
return bindingChunk.dynamicImports;
|
|
968
|
-
},
|
|
969
|
-
exports: bindingChunk.exports,
|
|
970
|
-
isEntry: bindingChunk.isEntry,
|
|
971
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
972
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
973
|
-
get moduleIds() {
|
|
974
|
-
return bindingChunk.moduleIds;
|
|
975
|
-
},
|
|
976
|
-
get map() {
|
|
977
|
-
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
978
|
-
},
|
|
979
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
980
|
-
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
981
|
-
};
|
|
982
|
-
const cache = {};
|
|
983
|
-
return new Proxy(chunk, {
|
|
984
|
-
get(target, p) {
|
|
985
|
-
if (p in cache) return cache[p];
|
|
986
|
-
return target[p];
|
|
987
|
-
},
|
|
988
|
-
set(target, p, newValue) {
|
|
989
|
-
cache[p] = newValue;
|
|
990
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
991
|
-
return true;
|
|
992
|
-
},
|
|
993
|
-
has(target, p) {
|
|
994
|
-
if (p in cache) return true;
|
|
995
|
-
return p in target;
|
|
996
|
-
}
|
|
997
|
-
});
|
|
998
897
|
}
|
|
999
|
-
function
|
|
1000
|
-
|
|
1001
|
-
type: "
|
|
1002
|
-
|
|
1003
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
1004
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
1005
|
-
get source() {
|
|
1006
|
-
return transformAssetSource(bindingAsset.source);
|
|
1007
|
-
},
|
|
1008
|
-
name: bindingAsset.name ?? void 0,
|
|
1009
|
-
names: bindingAsset.names
|
|
1010
|
-
};
|
|
1011
|
-
const cache = {};
|
|
1012
|
-
return new Proxy(asset, {
|
|
1013
|
-
get(target, p) {
|
|
1014
|
-
if (p in cache) return cache[p];
|
|
1015
|
-
return target[p];
|
|
1016
|
-
},
|
|
1017
|
-
set(target, p, newValue) {
|
|
1018
|
-
cache[p] = newValue;
|
|
1019
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
1020
|
-
return true;
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
function transformToRollupOutput(output, changed) {
|
|
1025
|
-
handleOutputErrors(output);
|
|
1026
|
-
const { chunks, assets } = output;
|
|
1027
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
1028
|
-
}
|
|
1029
|
-
function handleOutputErrors(output) {
|
|
1030
|
-
const rawErrors = output.errors;
|
|
1031
|
-
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
1032
|
-
}
|
|
1033
|
-
function transformToOutputBundle(output, changed) {
|
|
1034
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
1035
|
-
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
1036
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
1037
|
-
return true;
|
|
1038
|
-
} });
|
|
1039
|
-
}
|
|
1040
|
-
function collectChangedBundle(changed, bundle) {
|
|
1041
|
-
const assets = [];
|
|
1042
|
-
const chunks = [];
|
|
1043
|
-
for (const key in bundle) {
|
|
1044
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
1045
|
-
const item = bundle[key];
|
|
1046
|
-
if (item.type === "asset") assets.push({
|
|
1047
|
-
filename: item.fileName,
|
|
1048
|
-
originalFileNames: item.originalFileNames,
|
|
1049
|
-
source: bindingAssetSource(item.source),
|
|
1050
|
-
names: item.names
|
|
1051
|
-
});
|
|
1052
|
-
else chunks.push({
|
|
1053
|
-
code: item.code,
|
|
1054
|
-
filename: item.fileName,
|
|
1055
|
-
name: item.name,
|
|
1056
|
-
isEntry: item.isEntry,
|
|
1057
|
-
exports: item.exports,
|
|
1058
|
-
modules: {},
|
|
1059
|
-
imports: item.imports,
|
|
1060
|
-
dynamicImports: item.dynamicImports,
|
|
1061
|
-
facadeModuleId: item.facadeModuleId || void 0,
|
|
1062
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
1063
|
-
moduleIds: item.moduleIds,
|
|
1064
|
-
map: bindingifySourcemap$1(item.map),
|
|
1065
|
-
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
1066
|
-
preliminaryFilename: item.preliminaryFileName
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
return {
|
|
1070
|
-
assets,
|
|
1071
|
-
chunks,
|
|
1072
|
-
deleted: Array.from(changed.deleted)
|
|
898
|
+
function bindingResolvedExternal(external) {
|
|
899
|
+
if (typeof external === "boolean") return {
|
|
900
|
+
type: "Bool",
|
|
901
|
+
field0: external
|
|
1073
902
|
};
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
//#endregion
|
|
1077
|
-
//#region src/utils/transform-sourcemap.ts
|
|
1078
|
-
function isEmptySourcemapFiled(array) {
|
|
1079
|
-
if (!array) return true;
|
|
1080
|
-
if (array.length === 0 || !array[0]) return true;
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
1084
|
-
if (!rawMap) return;
|
|
1085
|
-
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
1086
|
-
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
1087
|
-
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
1088
|
-
return map;
|
|
903
|
+
if (external === "absolute") return { type: "Absolute" };
|
|
904
|
+
if (external === "relative") return { type: "Relative" };
|
|
1089
905
|
}
|
|
1090
906
|
|
|
1091
907
|
//#endregion
|
|
@@ -1123,21 +939,71 @@ function bindingifySideEffects(sideEffects) {
|
|
|
1123
939
|
}
|
|
1124
940
|
|
|
1125
941
|
//#endregion
|
|
1126
|
-
//#region src/utils/
|
|
1127
|
-
function
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
case "Relative": unreachable(`The PluginContext resolve result external couldn't be 'relative'`);
|
|
1132
|
-
}
|
|
942
|
+
//#region src/utils/transform-sourcemap.ts
|
|
943
|
+
function isEmptySourcemapFiled(array) {
|
|
944
|
+
if (!array) return true;
|
|
945
|
+
if (array.length === 0 || !array[0]) return true;
|
|
946
|
+
return false;
|
|
1133
947
|
}
|
|
1134
|
-
function
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1137
|
-
|
|
948
|
+
function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
949
|
+
if (!rawMap) return;
|
|
950
|
+
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
951
|
+
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
952
|
+
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
|
|
953
|
+
return map;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/plugin/bindingify-hook-filter.ts
|
|
958
|
+
function bindingifyStringFilter(matcher) {
|
|
959
|
+
if (typeof matcher === "string" || matcher instanceof RegExp) return { include: [matcher] };
|
|
960
|
+
if (Array.isArray(matcher)) return { include: matcher };
|
|
961
|
+
return {
|
|
962
|
+
include: matcher.include ? arraify(matcher.include) : void 0,
|
|
963
|
+
exclude: matcher.exclude ? arraify(matcher.exclude) : void 0
|
|
1138
964
|
};
|
|
1139
|
-
|
|
1140
|
-
|
|
965
|
+
}
|
|
966
|
+
function bindingifyResolveIdFilter(filterOption) {
|
|
967
|
+
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
968
|
+
}
|
|
969
|
+
function bindingifyLoadFilter(filterOption) {
|
|
970
|
+
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
971
|
+
}
|
|
972
|
+
function bindingifyTransformFilter(filterOption) {
|
|
973
|
+
if (!filterOption) return void 0;
|
|
974
|
+
const { id, code, moduleType } = filterOption;
|
|
975
|
+
let moduleTypeRet;
|
|
976
|
+
if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
|
|
977
|
+
else moduleTypeRet = moduleType.include;
|
|
978
|
+
return {
|
|
979
|
+
id: id ? bindingifyStringFilter(id) : void 0,
|
|
980
|
+
code: code ? bindingifyStringFilter(code) : void 0,
|
|
981
|
+
moduleType: moduleTypeRet
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
987
|
+
function bindingifyPluginHookMeta(options) {
|
|
988
|
+
return { order: bindingPluginOrder(options.order) };
|
|
989
|
+
}
|
|
990
|
+
function bindingPluginOrder(order) {
|
|
991
|
+
switch (order) {
|
|
992
|
+
case "post": return import_binding.BindingPluginOrder.Post;
|
|
993
|
+
case "pre": return import_binding.BindingPluginOrder.Pre;
|
|
994
|
+
case null:
|
|
995
|
+
case void 0: return void 0;
|
|
996
|
+
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/utils/asset-source.ts
|
|
1002
|
+
function transformAssetSource(bindingAssetSource$1) {
|
|
1003
|
+
return bindingAssetSource$1.inner;
|
|
1004
|
+
}
|
|
1005
|
+
function bindingAssetSource(source) {
|
|
1006
|
+
return { inner: source };
|
|
1141
1007
|
}
|
|
1142
1008
|
|
|
1143
1009
|
//#endregion
|
|
@@ -1244,91 +1110,21 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
|
|
|
1244
1110
|
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
1245
1111
|
log.id = moduleId;
|
|
1246
1112
|
log.hook = "transform";
|
|
1247
|
-
handler(log);
|
|
1248
|
-
};
|
|
1249
|
-
this.debug = getLogHandler$1(this.debug);
|
|
1250
|
-
this.warn = getLogHandler$1(this.warn);
|
|
1251
|
-
this.info = getLogHandler$1(this.info);
|
|
1252
|
-
}
|
|
1253
|
-
error(e, pos) {
|
|
1254
|
-
if (typeof e === "string") e = { message: e };
|
|
1255
|
-
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1256
|
-
e.id = this.moduleId;
|
|
1257
|
-
e.hook = "transform";
|
|
1258
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
1259
|
-
}
|
|
1260
|
-
getCombinedSourcemap() {
|
|
1261
|
-
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
|
-
//#endregion
|
|
1266
|
-
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
1267
|
-
function bindingifyPluginHookMeta(options) {
|
|
1268
|
-
return { order: bindingPluginOrder(options.order) };
|
|
1269
|
-
}
|
|
1270
|
-
function bindingPluginOrder(order) {
|
|
1271
|
-
switch (order) {
|
|
1272
|
-
case "post": return import_binding.BindingPluginOrder.Post;
|
|
1273
|
-
case "pre": return import_binding.BindingPluginOrder.Pre;
|
|
1274
|
-
case null:
|
|
1275
|
-
case void 0: return void 0;
|
|
1276
|
-
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
//#endregion
|
|
1281
|
-
//#region src/constants/plugin-context.ts
|
|
1282
|
-
const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
1283
|
-
|
|
1284
|
-
//#endregion
|
|
1285
|
-
//#region src/plugin/bindingify-hook-filter.ts
|
|
1286
|
-
function bindingifyStringFilter(matcher) {
|
|
1287
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return { include: [matcher] };
|
|
1288
|
-
if (Array.isArray(matcher)) return { include: matcher };
|
|
1289
|
-
return {
|
|
1290
|
-
include: matcher.include ? arraify(matcher.include) : void 0,
|
|
1291
|
-
exclude: matcher.exclude ? arraify(matcher.exclude) : void 0
|
|
1292
|
-
};
|
|
1293
|
-
}
|
|
1294
|
-
function bindingifyResolveIdFilter(filterOption) {
|
|
1295
|
-
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
1296
|
-
}
|
|
1297
|
-
function bindingifyLoadFilter(filterOption) {
|
|
1298
|
-
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : void 0;
|
|
1299
|
-
}
|
|
1300
|
-
function bindingifyTransformFilter(filterOption) {
|
|
1301
|
-
if (!filterOption) return void 0;
|
|
1302
|
-
const { id, code, moduleType } = filterOption;
|
|
1303
|
-
let moduleTypeRet;
|
|
1304
|
-
if (moduleType) if (Array.isArray(moduleType)) moduleTypeRet = moduleType;
|
|
1305
|
-
else moduleTypeRet = moduleType.include;
|
|
1306
|
-
return {
|
|
1307
|
-
id: id ? bindingifyStringFilter(id) : void 0,
|
|
1308
|
-
code: code ? bindingifyStringFilter(code) : void 0,
|
|
1309
|
-
moduleType: moduleTypeRet
|
|
1310
|
-
};
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
//#endregion
|
|
1314
|
-
//#region src/options/normalized-input-options.ts
|
|
1315
|
-
var NormalizedInputOptionsImpl = class {
|
|
1316
|
-
inner;
|
|
1317
|
-
constructor(inner, onLog) {
|
|
1318
|
-
this.onLog = onLog;
|
|
1319
|
-
this.inner = inner;
|
|
1320
|
-
}
|
|
1321
|
-
get shimMissingExports() {
|
|
1322
|
-
return this.inner.shimMissingExports;
|
|
1323
|
-
}
|
|
1324
|
-
get input() {
|
|
1325
|
-
return this.inner.input;
|
|
1113
|
+
handler(log);
|
|
1114
|
+
};
|
|
1115
|
+
this.debug = getLogHandler$1(this.debug);
|
|
1116
|
+
this.warn = getLogHandler$1(this.warn);
|
|
1117
|
+
this.info = getLogHandler$1(this.info);
|
|
1326
1118
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1119
|
+
error(e, pos) {
|
|
1120
|
+
if (typeof e === "string") e = { message: e };
|
|
1121
|
+
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
1122
|
+
e.id = this.moduleId;
|
|
1123
|
+
e.hook = "transform";
|
|
1124
|
+
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
1329
1125
|
}
|
|
1330
|
-
|
|
1331
|
-
return this.inner.
|
|
1126
|
+
getCombinedSourcemap() {
|
|
1127
|
+
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
1332
1128
|
}
|
|
1333
1129
|
};
|
|
1334
1130
|
|
|
@@ -1496,6 +1292,70 @@ function bindingifyModuleParsed(args) {
|
|
|
1496
1292
|
};
|
|
1497
1293
|
}
|
|
1498
1294
|
|
|
1295
|
+
//#endregion
|
|
1296
|
+
//#region src/utils/transform-rendered-module.ts
|
|
1297
|
+
function transformToRenderedModule(bindingRenderedModule) {
|
|
1298
|
+
return {
|
|
1299
|
+
get code() {
|
|
1300
|
+
return bindingRenderedModule.code;
|
|
1301
|
+
},
|
|
1302
|
+
get renderedLength() {
|
|
1303
|
+
return bindingRenderedModule.code?.length || 0;
|
|
1304
|
+
},
|
|
1305
|
+
get renderedExports() {
|
|
1306
|
+
return bindingRenderedModule.renderedExports;
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
//#endregion
|
|
1312
|
+
//#region src/utils/transform-rendered-chunk.ts
|
|
1313
|
+
function transformRenderedChunk(chunk) {
|
|
1314
|
+
let modules = null;
|
|
1315
|
+
return {
|
|
1316
|
+
get name() {
|
|
1317
|
+
return chunk.name;
|
|
1318
|
+
},
|
|
1319
|
+
get isEntry() {
|
|
1320
|
+
return chunk.isEntry;
|
|
1321
|
+
},
|
|
1322
|
+
get isDynamicEntry() {
|
|
1323
|
+
return chunk.isDynamicEntry;
|
|
1324
|
+
},
|
|
1325
|
+
get facadeModuleId() {
|
|
1326
|
+
return chunk.facadeModuleId;
|
|
1327
|
+
},
|
|
1328
|
+
get moduleIds() {
|
|
1329
|
+
return chunk.moduleIds;
|
|
1330
|
+
},
|
|
1331
|
+
get exports() {
|
|
1332
|
+
return chunk.exports;
|
|
1333
|
+
},
|
|
1334
|
+
get fileName() {
|
|
1335
|
+
return chunk.fileName;
|
|
1336
|
+
},
|
|
1337
|
+
get imports() {
|
|
1338
|
+
return chunk.imports;
|
|
1339
|
+
},
|
|
1340
|
+
get dynamicImports() {
|
|
1341
|
+
return chunk.dynamicImports;
|
|
1342
|
+
},
|
|
1343
|
+
get modules() {
|
|
1344
|
+
if (!modules) modules = transformChunkModules(chunk.modules);
|
|
1345
|
+
return modules;
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
function transformChunkModules(modules) {
|
|
1350
|
+
const result = {};
|
|
1351
|
+
for (let i = 0; i < modules.values.length; i++) {
|
|
1352
|
+
let key = modules.keys[i];
|
|
1353
|
+
const mod = modules.values[i];
|
|
1354
|
+
result[key] = transformToRenderedModule(mod);
|
|
1355
|
+
}
|
|
1356
|
+
return result;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1499
1359
|
//#endregion
|
|
1500
1360
|
//#region src/utils/bindingify-output-options.ts
|
|
1501
1361
|
function bindingifyOutputOptions(outputOptions) {
|
|
@@ -1679,6 +1539,145 @@ function normalizeAddon(value) {
|
|
|
1679
1539
|
return () => value || "";
|
|
1680
1540
|
}
|
|
1681
1541
|
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/utils/transform-to-rollup-output.ts
|
|
1544
|
+
function transformToRollupSourceMap(map) {
|
|
1545
|
+
const parsed = JSON.parse(map);
|
|
1546
|
+
const obj = {
|
|
1547
|
+
...parsed,
|
|
1548
|
+
toString() {
|
|
1549
|
+
return JSON.stringify(obj);
|
|
1550
|
+
},
|
|
1551
|
+
toUrl() {
|
|
1552
|
+
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
return obj;
|
|
1556
|
+
}
|
|
1557
|
+
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
1558
|
+
const chunk = {
|
|
1559
|
+
type: "chunk",
|
|
1560
|
+
get code() {
|
|
1561
|
+
return bindingChunk.code;
|
|
1562
|
+
},
|
|
1563
|
+
fileName: bindingChunk.fileName,
|
|
1564
|
+
name: bindingChunk.name,
|
|
1565
|
+
get modules() {
|
|
1566
|
+
return transformChunkModules(bindingChunk.modules);
|
|
1567
|
+
},
|
|
1568
|
+
get imports() {
|
|
1569
|
+
return bindingChunk.imports;
|
|
1570
|
+
},
|
|
1571
|
+
get dynamicImports() {
|
|
1572
|
+
return bindingChunk.dynamicImports;
|
|
1573
|
+
},
|
|
1574
|
+
exports: bindingChunk.exports,
|
|
1575
|
+
isEntry: bindingChunk.isEntry,
|
|
1576
|
+
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
1577
|
+
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
1578
|
+
get moduleIds() {
|
|
1579
|
+
return bindingChunk.moduleIds;
|
|
1580
|
+
},
|
|
1581
|
+
get map() {
|
|
1582
|
+
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
1583
|
+
},
|
|
1584
|
+
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
1585
|
+
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
1586
|
+
};
|
|
1587
|
+
const cache = {};
|
|
1588
|
+
return new Proxy(chunk, {
|
|
1589
|
+
get(target, p) {
|
|
1590
|
+
if (p in cache) return cache[p];
|
|
1591
|
+
return target[p];
|
|
1592
|
+
},
|
|
1593
|
+
set(target, p, newValue) {
|
|
1594
|
+
cache[p] = newValue;
|
|
1595
|
+
changed?.updated.add(bindingChunk.fileName);
|
|
1596
|
+
return true;
|
|
1597
|
+
},
|
|
1598
|
+
has(target, p) {
|
|
1599
|
+
if (p in cache) return true;
|
|
1600
|
+
return p in target;
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
1605
|
+
const asset = {
|
|
1606
|
+
type: "asset",
|
|
1607
|
+
fileName: bindingAsset.fileName,
|
|
1608
|
+
originalFileName: bindingAsset.originalFileName || null,
|
|
1609
|
+
originalFileNames: bindingAsset.originalFileNames,
|
|
1610
|
+
get source() {
|
|
1611
|
+
return transformAssetSource(bindingAsset.source);
|
|
1612
|
+
},
|
|
1613
|
+
name: bindingAsset.name ?? void 0,
|
|
1614
|
+
names: bindingAsset.names
|
|
1615
|
+
};
|
|
1616
|
+
const cache = {};
|
|
1617
|
+
return new Proxy(asset, {
|
|
1618
|
+
get(target, p) {
|
|
1619
|
+
if (p in cache) return cache[p];
|
|
1620
|
+
return target[p];
|
|
1621
|
+
},
|
|
1622
|
+
set(target, p, newValue) {
|
|
1623
|
+
cache[p] = newValue;
|
|
1624
|
+
changed?.updated.add(bindingAsset.fileName);
|
|
1625
|
+
return true;
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
function transformToRollupOutput(output, changed) {
|
|
1630
|
+
handleOutputErrors(output);
|
|
1631
|
+
const { chunks, assets } = output;
|
|
1632
|
+
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
1633
|
+
}
|
|
1634
|
+
function handleOutputErrors(output) {
|
|
1635
|
+
const rawErrors = output.errors;
|
|
1636
|
+
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
1637
|
+
}
|
|
1638
|
+
function transformToOutputBundle(output, changed) {
|
|
1639
|
+
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
1640
|
+
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
1641
|
+
if (typeof property === "string") changed.deleted.add(property);
|
|
1642
|
+
return true;
|
|
1643
|
+
} });
|
|
1644
|
+
}
|
|
1645
|
+
function collectChangedBundle(changed, bundle) {
|
|
1646
|
+
const assets = [];
|
|
1647
|
+
const chunks = [];
|
|
1648
|
+
for (const key in bundle) {
|
|
1649
|
+
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
1650
|
+
const item = bundle[key];
|
|
1651
|
+
if (item.type === "asset") assets.push({
|
|
1652
|
+
filename: item.fileName,
|
|
1653
|
+
originalFileNames: item.originalFileNames,
|
|
1654
|
+
source: bindingAssetSource(item.source),
|
|
1655
|
+
names: item.names
|
|
1656
|
+
});
|
|
1657
|
+
else chunks.push({
|
|
1658
|
+
code: item.code,
|
|
1659
|
+
filename: item.fileName,
|
|
1660
|
+
name: item.name,
|
|
1661
|
+
isEntry: item.isEntry,
|
|
1662
|
+
exports: item.exports,
|
|
1663
|
+
modules: {},
|
|
1664
|
+
imports: item.imports,
|
|
1665
|
+
dynamicImports: item.dynamicImports,
|
|
1666
|
+
facadeModuleId: item.facadeModuleId || void 0,
|
|
1667
|
+
isDynamicEntry: item.isDynamicEntry,
|
|
1668
|
+
moduleIds: item.moduleIds,
|
|
1669
|
+
map: bindingifySourcemap$1(item.map),
|
|
1670
|
+
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
1671
|
+
preliminaryFilename: item.preliminaryFileName
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
return {
|
|
1675
|
+
assets,
|
|
1676
|
+
chunks,
|
|
1677
|
+
deleted: Array.from(changed.deleted)
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1682
1681
|
//#endregion
|
|
1683
1682
|
//#region src/plugin/bindingify-output-hooks.ts
|
|
1684
1683
|
function bindingifyRenderStart(args) {
|
|
@@ -1697,8 +1696,8 @@ function bindingifyRenderChunk(args) {
|
|
|
1697
1696
|
if (!hook) return {};
|
|
1698
1697
|
const { handler, meta } = normalizeHook(hook);
|
|
1699
1698
|
return {
|
|
1700
|
-
plugin: async (ctx, code, chunk, opts,
|
|
1701
|
-
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
1699
|
+
plugin: async (ctx, code, chunk, opts, meta$1) => {
|
|
1700
|
+
if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
1702
1701
|
const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args.outputOptions, args.normalizedOutputPlugins), args.pluginContextData.getRenderChunkMeta());
|
|
1703
1702
|
if (ret == null) return;
|
|
1704
1703
|
if (typeof ret === "string") return { code: ret };
|
|
@@ -2736,6 +2735,22 @@ const rolldown = async (input) => {
|
|
|
2736
2735
|
return new RolldownBuild(inputOptions);
|
|
2737
2736
|
};
|
|
2738
2737
|
|
|
2738
|
+
//#endregion
|
|
2739
|
+
//#region src/api/build.ts
|
|
2740
|
+
async function build(options) {
|
|
2741
|
+
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
2742
|
+
else {
|
|
2743
|
+
const { output, write = true,...inputOptions } = options;
|
|
2744
|
+
const build$1 = await rolldown(inputOptions);
|
|
2745
|
+
try {
|
|
2746
|
+
if (write) return await build$1.write(output);
|
|
2747
|
+
else return await build$1.generate(output);
|
|
2748
|
+
} finally {
|
|
2749
|
+
await build$1.close();
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2739
2754
|
//#endregion
|
|
2740
2755
|
//#region src/api/watch/watch-emitter.ts
|
|
2741
2756
|
var WatcherEmitter = class {
|
|
@@ -2860,24 +2875,9 @@ const watch = (input) => {
|
|
|
2860
2875
|
};
|
|
2861
2876
|
|
|
2862
2877
|
//#endregion
|
|
2863
|
-
//#region
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
//#endregion
|
|
2868
|
-
//#region src/api/build.ts
|
|
2869
|
-
async function build(options) {
|
|
2870
|
-
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
2871
|
-
else {
|
|
2872
|
-
const { output, write = true,...inputOptions } = options;
|
|
2873
|
-
const build$1 = await rolldown(inputOptions);
|
|
2874
|
-
try {
|
|
2875
|
-
if (write) return await build$1.write(output);
|
|
2876
|
-
else return await build$1.generate(output);
|
|
2877
|
-
} finally {
|
|
2878
|
-
await build$1.close();
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2878
|
+
//#region src/utils/define-config.ts
|
|
2879
|
+
function defineConfig(config) {
|
|
2880
|
+
return config;
|
|
2881
2881
|
}
|
|
2882
2882
|
|
|
2883
2883
|
//#endregion
|