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