@rolldown/browser 1.0.0-beta.49 → 1.0.0-beta.51

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 (48) hide show
  1. package/dist/cli.mjs +12 -8
  2. package/dist/config.d.mts +3 -3
  3. package/dist/config.mjs +9 -5
  4. package/dist/constructors-DoUEJY6G.js +65 -0
  5. package/dist/experimental-index.browser.mjs +17 -11
  6. package/dist/experimental-index.d.mts +52 -15
  7. package/dist/experimental-index.mjs +21 -13
  8. package/dist/filter-index.d.mts +3 -3
  9. package/dist/filter-index.mjs +2 -1
  10. package/dist/index.browser.mjs +161 -2
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +36 -4
  13. package/dist/normalize-string-or-regex-BXFT9GiS.js +830 -0
  14. package/dist/parallel-plugin-worker.mjs +5 -4
  15. package/dist/parallel-plugin.d.mts +3 -3
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +1 -1
  18. package/dist/plugins-index.browser.mjs +2 -2
  19. package/dist/plugins-index.d.mts +3 -3
  20. package/dist/plugins-index.mjs +3 -2
  21. package/dist/rolldown-binding.wasi-browser.js +5 -2
  22. package/dist/rolldown-binding.wasi.cjs +5 -2
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/{src-CnMyHYgB.js → rolldown-build-C0UB1WZy.js} +32 -756
  25. package/dist/shared/{binding-B4uTNiw2.d.mts → binding-lSvYApx7.d.mts} +198 -89
  26. package/dist/shared/bindingify-input-options-CSdAtTcQ.mjs +1568 -0
  27. package/dist/shared/{composable-filters-CBpK2Fbc.mjs → composable-filters-DZ5ToxRJ.mjs} +1 -22
  28. package/dist/shared/constructors-DF6M1PTb.mjs +65 -0
  29. package/dist/shared/constructors-DgFF472b.d.mts +31 -0
  30. package/dist/shared/{define-config-BAQ9c-hh.d.mts → define-config-BKu-xa_0.d.mts} +10 -49
  31. package/dist/shared/define-config-DfeZGBEt.mjs +7 -0
  32. package/dist/shared/{load-config-DQI-2sfE.mjs → load-config-Beo_LOwd.mjs} +1 -1
  33. package/dist/shared/misc-5GYLGQ20.mjs +22 -0
  34. package/dist/shared/normalize-string-or-regex-DvECZN2V.mjs +629 -0
  35. package/dist/shared/{parse-ast-index-D9jH_38U.mjs → parse-ast-index-C_M-Y4oC.mjs} +3 -3
  36. package/dist/shared/{prompt-Ckjl2FdJ.mjs → prompt-pmGBC3ws.mjs} +1 -1
  37. package/dist/shared/rolldown-BhV7L6Kg.mjs +10 -0
  38. package/dist/shared/rolldown-build-DYR94CyF.mjs +2121 -0
  39. package/dist/shared/utils-BJWI2OzT.d.mts +62 -0
  40. package/dist/shared/watch-Cjxo-3u4.mjs +338 -0
  41. package/package.json +1 -1
  42. package/dist/constructors-EhfoQfqh.js +0 -68
  43. package/dist/normalize-string-or-regex-d47jXr3r.js +0 -231
  44. package/dist/shared/constructors-CaN9lKj2.d.mts +0 -32
  45. package/dist/shared/constructors-DcEzB0nc.mjs +0 -68
  46. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +0 -46
  47. package/dist/shared/src-CZ_U2fML.mjs +0 -4597
  48. package/dist/shared/utils-CduIqa7h.d.mts +0 -18
@@ -1,231 +0,0 @@
1
- import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
2
-
3
- //#region src/utils/code-frame.ts
4
- function spaces(index) {
5
- let result = "";
6
- while (index--) result += " ";
7
- return result;
8
- }
9
- function tabsToSpaces(value) {
10
- return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
11
- }
12
- const LINE_TRUNCATE_LENGTH = 120;
13
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
14
- const ELLIPSIS = "...";
15
- function getCodeFrame(source, line, column) {
16
- let lines = source.split("\n");
17
- if (line > lines.length) return "";
18
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
19
- const frameStart = Math.max(0, line - 3);
20
- let frameEnd = Math.min(line + 2, lines.length);
21
- lines = lines.slice(frameStart, frameEnd);
22
- while (!/\S/.test(lines[lines.length - 1])) {
23
- lines.pop();
24
- frameEnd -= 1;
25
- }
26
- const digits = String(frameEnd).length;
27
- return lines.map((sourceLine, index) => {
28
- const isErrorLine = frameStart + index + 1 === line;
29
- let lineNumber = String(index + frameStart + 1);
30
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
31
- let displayedLine = tabsToSpaces(sourceLine);
32
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
33
- if (isErrorLine) {
34
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
35
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
36
- }
37
- return `${lineNumber}: ${displayedLine}`;
38
- }).join("\n");
39
- }
40
-
41
- //#endregion
42
- //#region src/log/locate-character/index.js
43
- /** @typedef {import('./types').Location} Location */
44
- /**
45
- * @param {import('./types').Range} range
46
- * @param {number} index
47
- */
48
- function rangeContains(range, index) {
49
- return range.start <= index && index < range.end;
50
- }
51
- /**
52
- * @param {string} source
53
- * @param {import('./types').Options} [options]
54
- */
55
- function getLocator(source, options = {}) {
56
- const { offsetLine = 0, offsetColumn = 0 } = options;
57
- let start = 0;
58
- const ranges = source.split("\n").map((line, i$1) => {
59
- const end = start + line.length + 1;
60
- /** @type {import('./types').Range} */
61
- const range = {
62
- start,
63
- end,
64
- line: i$1
65
- };
66
- start = end;
67
- return range;
68
- });
69
- let i = 0;
70
- /**
71
- * @param {string | number} search
72
- * @param {number} [index]
73
- * @returns {Location | undefined}
74
- */
75
- function locator(search, index) {
76
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
77
- if (search === -1) return void 0;
78
- let range = ranges[i];
79
- const d = search >= range.end ? 1 : -1;
80
- while (range) {
81
- if (rangeContains(range, search)) return {
82
- line: offsetLine + range.line,
83
- column: offsetColumn + search - range.start,
84
- character: search
85
- };
86
- i += d;
87
- range = ranges[i];
88
- }
89
- }
90
- return locator;
91
- }
92
- /**
93
- * @param {string} source
94
- * @param {string | number} search
95
- * @param {import('./types').Options} [options]
96
- * @returns {Location | undefined}
97
- */
98
- function locate(source, search, options) {
99
- return getLocator(source, options)(search, options && options.startIndex);
100
- }
101
-
102
- //#endregion
103
- //#region src/log/logs.ts
104
- const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
105
- function logParseError(message) {
106
- return {
107
- code: PARSE_ERROR,
108
- message
109
- };
110
- }
111
- function logInvalidLogPosition(pluginName) {
112
- return {
113
- code: INVALID_LOG_POSITION,
114
- message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
115
- };
116
- }
117
- function logInputHookInOutputPlugin(pluginName, hookName) {
118
- return {
119
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
120
- message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
121
- };
122
- }
123
- function logCycleLoading(pluginName, moduleId) {
124
- return {
125
- code: CYCLE_LOADING,
126
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
127
- };
128
- }
129
- function logMultiplyNotifyOption() {
130
- return {
131
- code: MULTIPLY_NOTIFY_OPTION,
132
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
133
- };
134
- }
135
- function logNoFileSystemInBrowser(method) {
136
- return {
137
- code: NO_FS_IN_BROWSER,
138
- message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
139
- };
140
- }
141
- function logPluginError(error$1, plugin, { hook, id } = {}) {
142
- try {
143
- const code = error$1.code;
144
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
145
- error$1.code = PLUGIN_ERROR;
146
- error$1.plugin = plugin;
147
- if (hook) error$1.hook = hook;
148
- if (id) error$1.id = id;
149
- } catch (_) {} finally {
150
- return error$1;
151
- }
152
- }
153
- function error(base) {
154
- if (!(base instanceof Error)) {
155
- base = Object.assign(new Error(base.message), base);
156
- Object.defineProperty(base, "name", {
157
- value: "RollupError",
158
- writable: true
159
- });
160
- }
161
- throw base;
162
- }
163
- function augmentCodeLocation(properties, pos, source, id) {
164
- if (typeof pos === "object") {
165
- const { line, column } = pos;
166
- properties.loc = {
167
- column,
168
- file: id,
169
- line
170
- };
171
- } else {
172
- properties.pos = pos;
173
- const location = locate(source, pos, { offsetLine: 1 });
174
- if (!location) return;
175
- const { line, column } = location;
176
- properties.loc = {
177
- column,
178
- file: id,
179
- line
180
- };
181
- }
182
- if (properties.frame === void 0) {
183
- const { line, column } = properties.loc;
184
- properties.frame = getCodeFrame(source, line, column);
185
- }
186
- }
187
-
188
- //#endregion
189
- //#region src/builtin-plugin/utils.ts
190
- var BuiltinPlugin = class {
191
- constructor(name, _options) {
192
- this.name = name;
193
- this._options = _options;
194
- }
195
- };
196
- function makeBuiltinPluginCallable(plugin) {
197
- let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
198
- const wrappedPlugin = plugin;
199
- for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
200
- try {
201
- return await callablePlugin[key](...args);
202
- } catch (e) {
203
- if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
204
- return error(logPluginError(e, plugin.name, {
205
- hook: key,
206
- id: key === "transform" ? args[2] : void 0
207
- }));
208
- }
209
- };
210
- return wrappedPlugin;
211
- }
212
- function bindingifyBuiltInPlugin(plugin) {
213
- return {
214
- __name: plugin.name,
215
- options: plugin._options
216
- };
217
- }
218
-
219
- //#endregion
220
- //#region src/utils/normalize-string-or-regex.ts
221
- function normalizedStringOrRegex(pattern) {
222
- if (!pattern) return;
223
- if (!isReadonlyArray(pattern)) return [pattern];
224
- return pattern;
225
- }
226
- function isReadonlyArray(input) {
227
- return Array.isArray(input);
228
- }
229
-
230
- //#endregion
231
- export { augmentCodeLocation as a, logInputHookInOutputPlugin as c, logNoFileSystemInBrowser as d, logParseError as f, getCodeFrame as h, makeBuiltinPluginCallable as i, logInvalidLogPosition as l, locate as m, BuiltinPlugin as n, error as o, logPluginError as p, bindingifyBuiltInPlugin as r, logCycleLoading as s, normalizedStringOrRegex as t, logMultiplyNotifyOption as u };
@@ -1,32 +0,0 @@
1
- import { C as BindingViteCssPostPluginConfig, E as BindingWasmHelperPluginConfig, T as BindingViteResolvePluginConfig, a as BindingDynamicImportVarsPluginConfig, c as BindingImportGlobPluginConfig, f as BindingManifestPluginConfig, l as BindingIsolatedDeclarationPluginConfig, m as BindingReactRefreshWrapperPluginConfig, n as BindingBuildImportAnalysisPluginConfig, o as BindingEsmExternalRequirePluginConfig, p as BindingModulePreloadPolyfillPluginConfig, u as BindingJsonPluginConfig, v as BindingReporterPluginConfig, w as BindingViteHtmlPluginConfig } from "./binding-B4uTNiw2.mjs";
2
- import { s as StringOrRegExp, t as BuiltinPlugin } from "./utils-CduIqa7h.mjs";
3
-
4
- //#region src/builtin-plugin/constructors.d.ts
5
- declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
6
- type DynamicImportVarsPluginConfig = Omit<BindingDynamicImportVarsPluginConfig, "include" | "exclude"> & {
7
- include?: StringOrRegExp | StringOrRegExp[];
8
- exclude?: StringOrRegExp | StringOrRegExp[];
9
- };
10
- declare function dynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
11
- declare function importGlobPlugin(config?: BindingImportGlobPluginConfig): BuiltinPlugin;
12
- declare function reporterPlugin(config?: BindingReporterPluginConfig): BuiltinPlugin;
13
- declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
14
- declare function wasmHelperPlugin(config?: BindingWasmHelperPluginConfig): BuiltinPlugin;
15
- declare function wasmFallbackPlugin(): BuiltinPlugin;
16
- declare function loadFallbackPlugin(): BuiltinPlugin;
17
- declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
18
- declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
19
- declare function viteResolvePlugin(config: BindingViteResolvePluginConfig): BuiltinPlugin;
20
- declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
21
- declare function webWorkerPostPlugin(): BuiltinPlugin;
22
- declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
23
- type ReactRefreshWrapperPluginConfig = Omit<BindingReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
24
- include?: StringOrRegExp | StringOrRegExp[];
25
- exclude?: StringOrRegExp | StringOrRegExp[];
26
- };
27
- declare function reactRefreshWrapperPlugin(config: ReactRefreshWrapperPluginConfig): BuiltinPlugin;
28
- declare function viteCSSPostPlugin(config?: BindingViteCssPostPluginConfig): BuiltinPlugin;
29
- declare function viteHtmlPlugin(config?: BindingViteHtmlPluginConfig): BuiltinPlugin;
30
- declare function htmlInlineProxyPlugin(): BuiltinPlugin;
31
- //#endregion
32
- export { wasmHelperPlugin as _, importGlobPlugin as a, loadFallbackPlugin as c, reactRefreshWrapperPlugin as d, reporterPlugin as f, wasmFallbackPlugin as g, viteResolvePlugin as h, htmlInlineProxyPlugin as i, manifestPlugin as l, viteHtmlPlugin as m, dynamicImportVarsPlugin as n, isolatedDeclarationPlugin as o, viteCSSPostPlugin as p, esmExternalRequirePlugin as r, jsonPlugin as s, buildImportAnalysisPlugin as t, modulePreloadPolyfillPlugin as u, webWorkerPostPlugin as v };
@@ -1,68 +0,0 @@
1
- import { i as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-CbDij6KB.mjs";
2
-
3
- //#region src/builtin-plugin/constructors.ts
4
- function modulePreloadPolyfillPlugin(config) {
5
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
6
- }
7
- function dynamicImportVarsPlugin(config) {
8
- if (config) {
9
- config.include = normalizedStringOrRegex(config.include);
10
- config.exclude = normalizedStringOrRegex(config.exclude);
11
- }
12
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
13
- }
14
- function importGlobPlugin(config) {
15
- return new BuiltinPlugin("builtin:import-glob", config);
16
- }
17
- function reporterPlugin(config) {
18
- return new BuiltinPlugin("builtin:reporter", config);
19
- }
20
- function manifestPlugin(config) {
21
- return new BuiltinPlugin("builtin:manifest", config);
22
- }
23
- function wasmHelperPlugin(config) {
24
- return new BuiltinPlugin("builtin:wasm-helper", config);
25
- }
26
- function wasmFallbackPlugin() {
27
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:wasm-fallback"));
28
- }
29
- function loadFallbackPlugin() {
30
- return new BuiltinPlugin("builtin:load-fallback");
31
- }
32
- function jsonPlugin(config) {
33
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:json", config));
34
- }
35
- function buildImportAnalysisPlugin(config) {
36
- return new BuiltinPlugin("builtin:build-import-analysis", config);
37
- }
38
- function viteResolvePlugin(config) {
39
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", config));
40
- }
41
- function isolatedDeclarationPlugin(config) {
42
- return new BuiltinPlugin("builtin:isolated-declaration", config);
43
- }
44
- function webWorkerPostPlugin() {
45
- return new BuiltinPlugin("builtin:web-worker-post");
46
- }
47
- function esmExternalRequirePlugin(config) {
48
- return new BuiltinPlugin("builtin:esm-external-require", config);
49
- }
50
- function reactRefreshWrapperPlugin(config) {
51
- if (config) {
52
- config.include = normalizedStringOrRegex(config.include);
53
- config.exclude = normalizedStringOrRegex(config.exclude);
54
- }
55
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:react-refresh-wrapper", config));
56
- }
57
- function viteCSSPostPlugin(config) {
58
- return new BuiltinPlugin("builtin:vite-css-post", config);
59
- }
60
- function viteHtmlPlugin(config) {
61
- return new BuiltinPlugin("builtin:vite-html", config);
62
- }
63
- function htmlInlineProxyPlugin() {
64
- return new BuiltinPlugin("builtin:html-inline-proxy");
65
- }
66
-
67
- //#endregion
68
- export { wasmHelperPlugin as _, importGlobPlugin as a, loadFallbackPlugin as c, reactRefreshWrapperPlugin as d, reporterPlugin as f, wasmFallbackPlugin as g, viteResolvePlugin as h, htmlInlineProxyPlugin as i, manifestPlugin as l, viteHtmlPlugin as m, dynamicImportVarsPlugin as n, isolatedDeclarationPlugin as o, viteCSSPostPlugin as p, esmExternalRequirePlugin as r, jsonPlugin as s, buildImportAnalysisPlugin as t, modulePreloadPolyfillPlugin as u, webWorkerPostPlugin as v };
@@ -1,46 +0,0 @@
1
- import { c as logPluginError, n as error } from "./logs-CPsamAuj.mjs";
2
- import { BindingCallableBuiltinPlugin } from "../rolldown-binding.wasi.cjs";
3
-
4
- //#region src/builtin-plugin/utils.ts
5
- var BuiltinPlugin = class {
6
- constructor(name, _options) {
7
- this.name = name;
8
- this._options = _options;
9
- }
10
- };
11
- function makeBuiltinPluginCallable(plugin) {
12
- let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
13
- const wrappedPlugin = plugin;
14
- for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
15
- try {
16
- return await callablePlugin[key](...args);
17
- } catch (e) {
18
- if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
19
- return error(logPluginError(e, plugin.name, {
20
- hook: key,
21
- id: key === "transform" ? args[2] : void 0
22
- }));
23
- }
24
- };
25
- return wrappedPlugin;
26
- }
27
- function bindingifyBuiltInPlugin(plugin) {
28
- return {
29
- __name: plugin.name,
30
- options: plugin._options
31
- };
32
- }
33
-
34
- //#endregion
35
- //#region src/utils/normalize-string-or-regex.ts
36
- function normalizedStringOrRegex(pattern) {
37
- if (!pattern) return;
38
- if (!isReadonlyArray(pattern)) return [pattern];
39
- return pattern;
40
- }
41
- function isReadonlyArray(input) {
42
- return Array.isArray(input);
43
- }
44
-
45
- //#endregion
46
- export { makeBuiltinPluginCallable as i, BuiltinPlugin as n, bindingifyBuiltInPlugin as r, normalizedStringOrRegex as t };