@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +961 -1551
- package/dist/config.d.mts +9 -6
- package/dist/config.mjs +9 -11
- package/dist/constructors-DsfxKD6A.js +68 -0
- package/dist/error-BeZaDkS8.js +157 -0
- package/dist/experimental-index.browser.mjs +278 -44
- package/dist/experimental-index.d.mts +228 -68
- package/dist/experimental-index.mjs +274 -55
- package/dist/experimental-runtime-types.d.ts +98 -0
- package/dist/filter-index.d.mts +104 -2
- package/dist/filter-index.mjs +144 -5
- package/dist/get-log-filter.d.mts +3 -0
- package/dist/get-log-filter.mjs +68 -0
- package/dist/index.browser.mjs +238 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +53 -6
- package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-TtAGUp42.js} +74 -147
- package/dist/parallel-plugin-worker.mjs +27 -35
- package/dist/parallel-plugin.d.mts +7 -7
- package/dist/parallel-plugin.mjs +1 -2
- package/dist/parse-ast-index.d.mts +28 -5
- package/dist/parse-ast-index.mjs +60 -4
- package/dist/plugins-index.browser.mjs +40 -0
- package/dist/plugins-index.d.mts +33 -0
- package/dist/plugins-index.mjs +40 -0
- package/dist/resolve-tsconfig-DThkUPSZ.js +112 -0
- package/dist/rolldown-binding.wasi-browser.js +46 -24
- package/dist/rolldown-binding.wasi.cjs +67 -24
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/rolldown-build-Chx5S-TB.js +5349 -0
- package/dist/shared/bindingify-input-options-Czbczr8Z.mjs +2168 -0
- package/dist/shared/composable-filters-B2ByPP8y.mjs +224 -0
- package/dist/shared/constructors-BVnf_fH1.d.mts +37 -0
- package/dist/shared/constructors-CemeNi29.mjs +68 -0
- package/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
- package/dist/shared/define-config-i6TWE2hm.d.mts +3855 -0
- package/dist/shared/error-CQ6njWsV.mjs +86 -0
- package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
- package/dist/shared/{load-config-D7UduHRZ.mjs → load-config-CxvL5JxT.mjs} +32 -36
- package/dist/shared/logging-C6h4g8dA.d.mts +50 -0
- package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-D80CXhvg.mjs} +25 -123
- package/dist/shared/normalize-string-or-regex-CF3Uz6aU.mjs +57 -0
- package/dist/shared/parse-CRhjbrcT.mjs +73 -0
- package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-BYQIwEjg.mjs} +301 -310
- package/dist/shared/resolve-tsconfig-Cwoo4h_o.mjs +112 -0
- package/dist/shared/rolldown-C3wFxOwq.mjs +40 -0
- package/dist/shared/rolldown-build-ChZOz6BP.mjs +3318 -0
- package/dist/shared/transform-DEgNAQOQ.d.mts +149 -0
- package/dist/shared/types-Cx3HYorz.d.mts +1302 -0
- package/dist/shared/utils-6wxe_LMG.d.mts +22 -0
- package/dist/shared/watch-C1jC1oFT.mjs +373 -0
- package/dist/utils-index.browser.mjs +2414 -0
- package/dist/utils-index.d.mts +374 -0
- package/dist/utils-index.mjs +2415 -0
- package/package.json +33 -38
- package/dist/cli.cjs +0 -1748
- package/dist/cli.d.cts +0 -1
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -11
- package/dist/experimental-index.cjs +0 -129
- package/dist/experimental-index.d.cts +0 -96
- package/dist/filter-index.cjs +0 -53
- package/dist/filter-index.d.cts +0 -3
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -3
- package/dist/parallel-plugin-worker.cjs +0 -33
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -14
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -9
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
- package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
- package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
- package/dist/shared/dist-BMVjvV-v.cjs +0 -249
- package/dist/shared/dist-CAn6dxW6.mjs +0 -153
- package/dist/shared/load-config-CtKjQ8Mn.cjs +0 -125
- package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
- package/dist/shared/src-D0nc44MQ.mjs +0 -4691
- package/dist/shared/src-s89s870G.cjs +0 -4647
- package/dist/src-CeWghjQt.js +0 -4329
package/dist/config.d.mts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-i6TWE2hm.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/load-config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Load config from a file in a way that Rolldown does.
|
|
6
|
+
*
|
|
7
|
+
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
|
|
8
|
+
* @returns The loaded config export
|
|
9
|
+
*
|
|
10
|
+
* @category Config
|
|
11
|
+
*/
|
|
4
12
|
declare function loadConfig(configPath: string): Promise<ConfigExport>;
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/config.d.ts
|
|
8
|
-
declare const VERSION: string;
|
|
9
|
-
|
|
10
13
|
//#endregion
|
|
11
14
|
export { VERSION, defineConfig, loadConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./shared/
|
|
3
|
-
import "./shared/
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { VERSION, defineConfig, loadConfig };
|
|
1
|
+
import "./shared/normalize-string-or-regex-CF3Uz6aU.mjs";
|
|
2
|
+
import { x as VERSION } from "./shared/bindingify-input-options-Czbczr8Z.mjs";
|
|
3
|
+
import "./shared/rolldown-build-ChZOz6BP.mjs";
|
|
4
|
+
import "./shared/error-CQ6njWsV.mjs";
|
|
5
|
+
import "./shared/parse-CRhjbrcT.mjs";
|
|
6
|
+
import "./shared/rolldown-C3wFxOwq.mjs";
|
|
7
|
+
import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
|
|
8
|
+
import { t as loadConfig } from "./shared/load-config-CxvL5JxT.mjs";
|
|
9
|
+
export { VERSION, defineConfig, loadConfig };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-TtAGUp42.js";
|
|
2
|
+
//#region src/builtin-plugin/constructors.ts
|
|
3
|
+
function viteModulePreloadPolyfillPlugin(config) {
|
|
4
|
+
return new BuiltinPlugin("builtin:vite-module-preload-polyfill", config);
|
|
5
|
+
}
|
|
6
|
+
function viteDynamicImportVarsPlugin(config) {
|
|
7
|
+
if (config) {
|
|
8
|
+
config.include = normalizedStringOrRegex(config.include);
|
|
9
|
+
config.exclude = normalizedStringOrRegex(config.exclude);
|
|
10
|
+
}
|
|
11
|
+
return new BuiltinPlugin("builtin:vite-dynamic-import-vars", config);
|
|
12
|
+
}
|
|
13
|
+
function viteImportGlobPlugin(config) {
|
|
14
|
+
return new BuiltinPlugin("builtin:vite-import-glob", config);
|
|
15
|
+
}
|
|
16
|
+
function viteReporterPlugin(config) {
|
|
17
|
+
return new BuiltinPlugin("builtin:vite-reporter", config);
|
|
18
|
+
}
|
|
19
|
+
function viteWasmFallbackPlugin() {
|
|
20
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-wasm-fallback"));
|
|
21
|
+
}
|
|
22
|
+
function viteLoadFallbackPlugin() {
|
|
23
|
+
return new BuiltinPlugin("builtin:vite-load-fallback");
|
|
24
|
+
}
|
|
25
|
+
function viteJsonPlugin(config) {
|
|
26
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-json", config));
|
|
27
|
+
}
|
|
28
|
+
function viteBuildImportAnalysisPlugin(config) {
|
|
29
|
+
return new BuiltinPlugin("builtin:vite-build-import-analysis", config);
|
|
30
|
+
}
|
|
31
|
+
function viteResolvePlugin(config) {
|
|
32
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", {
|
|
33
|
+
...config,
|
|
34
|
+
yarnPnp: typeof process === "object" && !!process.versions?.pnp
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function isolatedDeclarationPlugin(config) {
|
|
38
|
+
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
39
|
+
}
|
|
40
|
+
function viteWebWorkerPostPlugin() {
|
|
41
|
+
return new BuiltinPlugin("builtin:vite-web-worker-post");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
|
|
45
|
+
*
|
|
46
|
+
* @see https://rolldown.rs/builtin-plugins/esm-external-require
|
|
47
|
+
* @category Builtin Plugins
|
|
48
|
+
*/
|
|
49
|
+
function esmExternalRequirePlugin(config) {
|
|
50
|
+
const plugin = new BuiltinPlugin("builtin:esm-external-require", config);
|
|
51
|
+
plugin.enforce = "pre";
|
|
52
|
+
return plugin;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This plugin should not be used for Rolldown.
|
|
56
|
+
*/
|
|
57
|
+
function oxcRuntimePlugin() {
|
|
58
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:oxc-runtime"));
|
|
59
|
+
}
|
|
60
|
+
function viteReactRefreshWrapperPlugin(config) {
|
|
61
|
+
if (config) {
|
|
62
|
+
config.include = normalizedStringOrRegex(config.include);
|
|
63
|
+
config.exclude = normalizedStringOrRegex(config.exclude);
|
|
64
|
+
}
|
|
65
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-react-refresh-wrapper", config));
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, viteWebWorkerPostPlugin as m, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWasmFallbackPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { parse, parseSync } from "./rolldown-binding.wasi-browser.js";
|
|
2
|
+
//#region src/types/sourcemap.ts
|
|
3
|
+
function bindingifySourcemap(map) {
|
|
4
|
+
if (map == null) return;
|
|
5
|
+
return { inner: typeof map === "string" ? map : {
|
|
6
|
+
file: map.file ?? void 0,
|
|
7
|
+
mappings: map.mappings,
|
|
8
|
+
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
|
|
9
|
+
sources: map.sources?.map((s) => s ?? void 0),
|
|
10
|
+
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
|
|
11
|
+
names: map.names,
|
|
12
|
+
x_google_ignoreList: map.x_google_ignoreList,
|
|
13
|
+
debugId: "debugId" in map ? map.debugId : void 0
|
|
14
|
+
} };
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.120.0/node_modules/oxc-parser/src-js/wrap.js
|
|
18
|
+
function wrap(result) {
|
|
19
|
+
let program, module, comments, errors;
|
|
20
|
+
return {
|
|
21
|
+
get program() {
|
|
22
|
+
if (!program) program = jsonParseAst(result.program);
|
|
23
|
+
return program;
|
|
24
|
+
},
|
|
25
|
+
get module() {
|
|
26
|
+
if (!module) module = result.module;
|
|
27
|
+
return module;
|
|
28
|
+
},
|
|
29
|
+
get comments() {
|
|
30
|
+
if (!comments) comments = result.comments;
|
|
31
|
+
return comments;
|
|
32
|
+
},
|
|
33
|
+
get errors() {
|
|
34
|
+
if (!errors) errors = result.errors;
|
|
35
|
+
return errors;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function jsonParseAst(programJson) {
|
|
40
|
+
const { node: program, fixes } = JSON.parse(programJson);
|
|
41
|
+
for (const fixPath of fixes) applyFix(program, fixPath);
|
|
42
|
+
return program;
|
|
43
|
+
}
|
|
44
|
+
function applyFix(program, fixPath) {
|
|
45
|
+
let node = program;
|
|
46
|
+
for (const key of fixPath) node = node[key];
|
|
47
|
+
if (node.bigint) node.value = BigInt(node.bigint);
|
|
48
|
+
else try {
|
|
49
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
50
|
+
} catch {}
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/utils/parse.ts
|
|
54
|
+
/**
|
|
55
|
+
* Parse JS/TS source asynchronously on a separate thread.
|
|
56
|
+
*
|
|
57
|
+
* Note that not all of the workload can happen on a separate thread.
|
|
58
|
+
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
|
|
59
|
+
* has to happen on current thread. This synchronous deserialization work typically outweighs
|
|
60
|
+
* the asynchronous parsing by a factor of between 3 and 20.
|
|
61
|
+
*
|
|
62
|
+
* i.e. the majority of the workload cannot be parallelized by using this method.
|
|
63
|
+
*
|
|
64
|
+
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
|
|
65
|
+
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
|
|
66
|
+
*
|
|
67
|
+
* @category Utilities
|
|
68
|
+
*/
|
|
69
|
+
async function parse$1(filename, sourceText, options) {
|
|
70
|
+
return wrap(await parse(filename, sourceText, options));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parse JS/TS source synchronously on current thread.
|
|
74
|
+
*
|
|
75
|
+
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
|
|
76
|
+
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
|
|
77
|
+
* (see {@linkcode parse} documentation for details).
|
|
78
|
+
*
|
|
79
|
+
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
|
|
80
|
+
* with {@linkcode parseSync} rather than using {@linkcode parse}.
|
|
81
|
+
*
|
|
82
|
+
* @category Utilities
|
|
83
|
+
*/
|
|
84
|
+
function parseSync$1(filename, sourceText, options) {
|
|
85
|
+
return wrap(parseSync(filename, sourceText, options));
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/utils/error.ts
|
|
89
|
+
function unwrapBindingResult(container) {
|
|
90
|
+
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
|
|
91
|
+
return container;
|
|
92
|
+
}
|
|
93
|
+
function normalizeBindingResult(container) {
|
|
94
|
+
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
|
|
95
|
+
return container;
|
|
96
|
+
}
|
|
97
|
+
function normalizeBindingError(e) {
|
|
98
|
+
return e.type === "JsError" ? e.field0 : Object.assign(/* @__PURE__ */ new Error(), {
|
|
99
|
+
code: e.field0.kind,
|
|
100
|
+
kind: e.field0.kind,
|
|
101
|
+
message: e.field0.message,
|
|
102
|
+
id: e.field0.id,
|
|
103
|
+
exporter: e.field0.exporter,
|
|
104
|
+
loc: e.field0.loc,
|
|
105
|
+
pos: e.field0.pos,
|
|
106
|
+
stack: void 0
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function aggregateBindingErrorsIntoJsError(rawErrors) {
|
|
110
|
+
const errors = rawErrors.map(normalizeBindingError);
|
|
111
|
+
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
112
|
+
for (let i = 0; i < errors.length; i++) {
|
|
113
|
+
summary += "\n";
|
|
114
|
+
if (i >= 5) {
|
|
115
|
+
summary += "...";
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
summary += getErrorMessage(errors[i]);
|
|
119
|
+
}
|
|
120
|
+
const wrapper = new Error(summary);
|
|
121
|
+
Object.defineProperty(wrapper, "errors", {
|
|
122
|
+
configurable: true,
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: () => errors,
|
|
125
|
+
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
126
|
+
configurable: true,
|
|
127
|
+
enumerable: true,
|
|
128
|
+
value
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
return wrapper;
|
|
132
|
+
}
|
|
133
|
+
function getErrorMessage(e) {
|
|
134
|
+
if (Object.hasOwn(e, "kind")) return e.message;
|
|
135
|
+
let s = "";
|
|
136
|
+
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
137
|
+
const id = e.id ?? e.loc?.file;
|
|
138
|
+
if (id) {
|
|
139
|
+
s += " " + id;
|
|
140
|
+
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
141
|
+
}
|
|
142
|
+
if (s) s += "\n";
|
|
143
|
+
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
144
|
+
s += message;
|
|
145
|
+
if (e.frame) s = joinNewLine(s, e.frame);
|
|
146
|
+
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
147
|
+
if (e.cause) {
|
|
148
|
+
s = joinNewLine(s, "Caused by:");
|
|
149
|
+
s = joinNewLine(s, getErrorMessage(e.cause).split("\n").map((line) => " " + line).join("\n"));
|
|
150
|
+
}
|
|
151
|
+
return s;
|
|
152
|
+
}
|
|
153
|
+
function joinNewLine(s1, s2) {
|
|
154
|
+
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { parse$1 as a, unwrapBindingResult as i, normalizeBindingError as n, parseSync$1 as o, normalizeBindingResult as r, bindingifySourcemap as s, aggregateBindingErrorsIntoJsError as t };
|
|
@@ -1,76 +1,310 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-TtAGUp42.js";
|
|
2
|
+
import { a as validateOption, i as transformToRollupOutput, n as createBundlerOptions, o as PluginDriver, t as RolldownBuild } from "./rolldown-build-Chx5S-TB.js";
|
|
3
|
+
import { a as parse$2, i as unwrapBindingResult, o as parseSync$2, r as normalizeBindingResult } from "./error-BeZaDkS8.js";
|
|
4
|
+
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWasmFallbackPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./constructors-DsfxKD6A.js";
|
|
5
|
+
import { a as minify$2, i as transformSync$1, n as resolveTsconfig, o as minifySync$2, r as transform$1, t as TsconfigCache$2 } from "./resolve-tsconfig-DThkUPSZ.js";
|
|
6
|
+
import * as binding from "./rolldown-binding.wasi-browser.js";
|
|
7
|
+
import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, isolatedDeclarationSync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
|
|
8
|
+
//#region src/api/dev/dev-engine.ts
|
|
9
|
+
var DevEngine = class DevEngine {
|
|
10
|
+
#inner;
|
|
11
|
+
#cachedBuildFinishPromise = null;
|
|
12
|
+
static async create(inputOptions, outputOptions = {}, devOptions = {}) {
|
|
13
|
+
inputOptions = await PluginDriver.callOptionsHook(inputOptions);
|
|
14
|
+
const options = await createBundlerOptions(inputOptions, outputOptions, false);
|
|
15
|
+
const userOnHmrUpdates = devOptions.onHmrUpdates;
|
|
16
|
+
const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {
|
|
17
|
+
const result = normalizeBindingResult(rawResult);
|
|
18
|
+
if (result instanceof Error) {
|
|
19
|
+
userOnHmrUpdates(result);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const [updates, changedFiles] = result;
|
|
23
|
+
userOnHmrUpdates({
|
|
24
|
+
updates,
|
|
25
|
+
changedFiles
|
|
26
|
+
});
|
|
27
|
+
} : void 0;
|
|
28
|
+
const userOnOutput = devOptions.onOutput;
|
|
29
|
+
const bindingDevOptions = {
|
|
30
|
+
onHmrUpdates: bindingOnHmrUpdates,
|
|
31
|
+
onOutput: userOnOutput ? function(rawResult) {
|
|
32
|
+
const result = normalizeBindingResult(rawResult);
|
|
33
|
+
if (result instanceof Error) {
|
|
34
|
+
userOnOutput(result);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
userOnOutput(transformToRollupOutput(result));
|
|
38
|
+
} : void 0,
|
|
39
|
+
rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? BindingRebuildStrategy$1.Always : devOptions.rebuildStrategy === "auto" ? BindingRebuildStrategy$1.Auto : BindingRebuildStrategy$1.Never : void 0,
|
|
40
|
+
watch: devOptions.watch && {
|
|
41
|
+
skipWrite: devOptions.watch.skipWrite,
|
|
42
|
+
usePolling: devOptions.watch.usePolling,
|
|
43
|
+
pollInterval: devOptions.watch.pollInterval,
|
|
44
|
+
useDebounce: devOptions.watch.useDebounce,
|
|
45
|
+
debounceDuration: devOptions.watch.debounceDuration,
|
|
46
|
+
compareContentsForPolling: devOptions.watch.compareContentsForPolling,
|
|
47
|
+
debounceTickRate: devOptions.watch.debounceTickRate
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return new DevEngine(new BindingDevEngine(options.bundlerOptions, bindingDevOptions));
|
|
51
|
+
}
|
|
52
|
+
constructor(inner) {
|
|
53
|
+
this.#inner = inner;
|
|
54
|
+
}
|
|
55
|
+
async run() {
|
|
56
|
+
await this.#inner.run();
|
|
57
|
+
}
|
|
58
|
+
async ensureCurrentBuildFinish() {
|
|
59
|
+
if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
|
|
60
|
+
const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
|
|
61
|
+
this.#cachedBuildFinishPromise = null;
|
|
62
|
+
});
|
|
63
|
+
this.#cachedBuildFinishPromise = promise;
|
|
64
|
+
return promise;
|
|
65
|
+
}
|
|
66
|
+
async getBundleState() {
|
|
67
|
+
return this.#inner.getBundleState();
|
|
68
|
+
}
|
|
69
|
+
async ensureLatestBuildOutput() {
|
|
70
|
+
await this.#inner.ensureLatestBuildOutput();
|
|
71
|
+
}
|
|
72
|
+
async invalidate(file, firstInvalidatedBy) {
|
|
73
|
+
return this.#inner.invalidate(file, firstInvalidatedBy);
|
|
74
|
+
}
|
|
75
|
+
async registerModules(clientId, modules) {
|
|
76
|
+
await this.#inner.registerModules(clientId, modules);
|
|
77
|
+
}
|
|
78
|
+
async removeClient(clientId) {
|
|
79
|
+
await this.#inner.removeClient(clientId);
|
|
80
|
+
}
|
|
81
|
+
async close() {
|
|
82
|
+
await this.#inner.close();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Compile a lazy entry module and return HMR-style patch code.
|
|
86
|
+
*
|
|
87
|
+
* This is called when a dynamically imported module is first requested at runtime.
|
|
88
|
+
* The module was previously stubbed with a proxy, and now we need to compile the
|
|
89
|
+
* actual module and its dependencies.
|
|
90
|
+
*
|
|
91
|
+
* @param moduleId - The absolute file path of the module to compile
|
|
92
|
+
* @param clientId - The client ID requesting this compilation
|
|
93
|
+
* @returns The compiled JavaScript code as a string (HMR patch format)
|
|
94
|
+
*/
|
|
95
|
+
async compileEntry(moduleId, clientId) {
|
|
96
|
+
return this.#inner.compileEntry(moduleId, clientId);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/api/dev/index.ts
|
|
101
|
+
const dev = (...args) => DevEngine.create(...args);
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/types/external-memory-handle.ts
|
|
104
|
+
const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
|
|
105
|
+
/**
|
|
106
|
+
* Frees the external memory held by the given handle.
|
|
107
|
+
*
|
|
108
|
+
* This is useful when you want to manually release memory held by Rust objects
|
|
109
|
+
* (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
|
|
110
|
+
*
|
|
111
|
+
* @param handle - The object with external memory to free
|
|
112
|
+
* @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
|
|
113
|
+
* This will take time to copy data from Rust to JavaScript, but prevents errors
|
|
114
|
+
* when accessing properties after the memory is freed.
|
|
115
|
+
* @returns Status object with `freed` boolean and optional `reason` string.
|
|
116
|
+
* - `{ freed: true }` if memory was successfully freed
|
|
117
|
+
* - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { freeExternalMemory } from 'rolldown/experimental';
|
|
122
|
+
*
|
|
123
|
+
* const output = await bundle.generate();
|
|
124
|
+
* const chunk = output.output[0];
|
|
125
|
+
*
|
|
126
|
+
* // Use the chunk...
|
|
127
|
+
*
|
|
128
|
+
* // Manually free the memory (fast, but accessing properties after will throw)
|
|
129
|
+
* const status = freeExternalMemory(chunk); // { freed: true }
|
|
130
|
+
* const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
|
|
131
|
+
*
|
|
132
|
+
* // Keep data alive before freeing (slower, but data remains accessible)
|
|
133
|
+
* freeExternalMemory(chunk, true); // Evaluates all lazy fields first
|
|
134
|
+
* console.log(chunk.code); // OK - data was copied to JavaScript before freeing
|
|
135
|
+
*
|
|
136
|
+
* // Without keepDataAlive, accessing chunk properties after freeing will throw an error
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
function freeExternalMemory(handle, keepDataAlive = false) {
|
|
140
|
+
return handle[symbolForExternalMemoryHandle](keepDataAlive);
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
4
143
|
//#region src/api/experimental.ts
|
|
5
144
|
/**
|
|
6
|
-
* This is an experimental API.
|
|
145
|
+
* This is an experimental API. Its behavior may change in the future.
|
|
146
|
+
*
|
|
147
|
+
* - Calling this API will only execute the `scan/build` stage of rolldown.
|
|
148
|
+
* - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
|
|
7
149
|
*
|
|
8
|
-
*
|
|
150
|
+
* @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { scan } from 'rolldown/api/experimental';
|
|
153
|
+
*
|
|
154
|
+
* const cleanupPromise = await scan(...);
|
|
155
|
+
* await cleanupPromise;
|
|
156
|
+
* // Now all resources have been cleaned up.
|
|
157
|
+
* ```
|
|
9
158
|
*/
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
159
|
+
const scan = async (rawInputOptions, rawOutputOptions = {}) => {
|
|
160
|
+
validateOption("input", rawInputOptions);
|
|
161
|
+
validateOption("output", rawOutputOptions);
|
|
162
|
+
const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
|
|
163
|
+
const bundler = new BindingBundler();
|
|
164
|
+
if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
|
|
165
|
+
async function cleanup() {
|
|
166
|
+
await bundler.close();
|
|
167
|
+
await ret.stopWorkers?.();
|
|
168
|
+
shutdownAsyncRuntime();
|
|
169
|
+
RolldownBuild.asyncRuntimeShutdown = true;
|
|
170
|
+
}
|
|
171
|
+
let cleanupPromise = Promise.resolve();
|
|
172
|
+
try {
|
|
173
|
+
unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
|
|
174
|
+
} catch (err) {
|
|
175
|
+
await cleanup();
|
|
176
|
+
throw err;
|
|
177
|
+
} finally {
|
|
178
|
+
cleanupPromise = cleanup();
|
|
179
|
+
}
|
|
180
|
+
return cleanupPromise;
|
|
15
181
|
};
|
|
16
|
-
|
|
17
182
|
//#endregion
|
|
18
183
|
//#region src/plugin/parallel-plugin.ts
|
|
19
184
|
function defineParallelPlugin(pluginPath) {
|
|
20
185
|
throw new Error("`defineParallelPlugin` is not supported in browser build");
|
|
21
186
|
}
|
|
22
|
-
|
|
23
187
|
//#endregion
|
|
24
188
|
//#region src/builtin-plugin/alias-plugin.ts
|
|
25
|
-
function
|
|
26
|
-
return new BuiltinPlugin("builtin:alias", config);
|
|
189
|
+
function viteAliasPlugin(config) {
|
|
190
|
+
return new BuiltinPlugin("builtin:vite-alias", config);
|
|
27
191
|
}
|
|
28
|
-
|
|
29
192
|
//#endregion
|
|
30
|
-
//#region src/builtin-plugin/
|
|
193
|
+
//#region src/builtin-plugin/bundle-analyzer-plugin.ts
|
|
31
194
|
/**
|
|
32
|
-
*
|
|
195
|
+
* A plugin that analyzes bundle composition and generates detailed reports.
|
|
196
|
+
*
|
|
197
|
+
* The plugin outputs a file containing detailed information about:
|
|
198
|
+
* - All chunks and their relationships
|
|
199
|
+
* - Modules bundled in each chunk
|
|
200
|
+
* - Import dependencies between chunks
|
|
201
|
+
* - Reachable modules from each entry point
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```js
|
|
205
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
206
|
+
*
|
|
207
|
+
* export default {
|
|
208
|
+
* plugins: [
|
|
209
|
+
* bundleAnalyzerPlugin()
|
|
210
|
+
* ]
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
33
213
|
*
|
|
34
214
|
* @example
|
|
35
|
-
*
|
|
215
|
+
* **Custom filename**
|
|
36
216
|
* ```js
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
217
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
218
|
+
*
|
|
219
|
+
* export default {
|
|
220
|
+
* plugins: [
|
|
221
|
+
* bundleAnalyzerPlugin({
|
|
222
|
+
* fileName: 'bundle-analysis.json'
|
|
223
|
+
* })
|
|
224
|
+
* ]
|
|
225
|
+
* }
|
|
42
226
|
* ```
|
|
227
|
+
*
|
|
43
228
|
* @example
|
|
44
|
-
*
|
|
229
|
+
* **LLM-friendly markdown output**
|
|
45
230
|
* ```js
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
231
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
232
|
+
*
|
|
233
|
+
* export default {
|
|
234
|
+
* plugins: [
|
|
235
|
+
* bundleAnalyzerPlugin({
|
|
236
|
+
* format: 'md'
|
|
237
|
+
* })
|
|
238
|
+
* ]
|
|
239
|
+
* }
|
|
53
240
|
* ```
|
|
54
241
|
*/
|
|
55
|
-
function
|
|
56
|
-
return new BuiltinPlugin("builtin:
|
|
57
|
-
...options,
|
|
58
|
-
values
|
|
59
|
-
});
|
|
242
|
+
function bundleAnalyzerPlugin(config) {
|
|
243
|
+
return new BuiltinPlugin("builtin:bundle-analyzer", config);
|
|
60
244
|
}
|
|
61
|
-
|
|
62
245
|
//#endregion
|
|
63
246
|
//#region src/builtin-plugin/transform-plugin.ts
|
|
64
|
-
function
|
|
65
|
-
|
|
247
|
+
function viteTransformPlugin(config) {
|
|
248
|
+
return new BuiltinPlugin("builtin:vite-transform", {
|
|
66
249
|
...config,
|
|
67
250
|
include: normalizedStringOrRegex(config.include),
|
|
68
251
|
exclude: normalizedStringOrRegex(config.exclude),
|
|
69
252
|
jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
|
|
70
|
-
jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
|
|
71
|
-
|
|
72
|
-
|
|
253
|
+
jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),
|
|
254
|
+
yarnPnp: typeof process === "object" && !!process.versions?.pnp
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/builtin-plugin/vite-manifest-plugin.ts
|
|
259
|
+
function viteManifestPlugin(config) {
|
|
260
|
+
return new BuiltinPlugin("builtin:vite-manifest", config);
|
|
73
261
|
}
|
|
74
|
-
|
|
75
262
|
//#endregion
|
|
76
|
-
|
|
263
|
+
//#region src/experimental-index.ts
|
|
264
|
+
/**
|
|
265
|
+
* In-memory file system for browser builds.
|
|
266
|
+
*
|
|
267
|
+
* This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
|
|
268
|
+
* It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
|
|
269
|
+
*
|
|
270
|
+
* - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
|
|
271
|
+
* - `volume`: The underlying `Volume` instance that stores the filesystem state
|
|
272
|
+
*
|
|
273
|
+
* Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* import { memfs } from 'rolldown/experimental';
|
|
278
|
+
*
|
|
279
|
+
* // Write files to virtual filesystem before bundling
|
|
280
|
+
* memfs?.volume.fromJSON({
|
|
281
|
+
* '/src/index.js': 'export const foo = 42;',
|
|
282
|
+
* '/package.json': '{"name": "my-app"}'
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // Read files from the virtual filesystem
|
|
286
|
+
* const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
|
|
290
|
+
*/
|
|
291
|
+
const memfs = {
|
|
292
|
+
fs: binding.__fs,
|
|
293
|
+
volume: binding.__volume
|
|
294
|
+
};
|
|
295
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
296
|
+
const parse = parse$2;
|
|
297
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
298
|
+
const parseSync = parseSync$2;
|
|
299
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
300
|
+
const minify = minify$2;
|
|
301
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
302
|
+
const minifySync = minifySync$2;
|
|
303
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
304
|
+
const transform = transform$1;
|
|
305
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
306
|
+
const transformSync = transformSync$1;
|
|
307
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
308
|
+
const TsconfigCache = TsconfigCache$2;
|
|
309
|
+
//#endregion
|
|
310
|
+
export { BindingRebuildStrategy, DevEngine, ResolverFactory, TsconfigCache, bundleAnalyzerPlugin, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, oxcRuntimePlugin, parse, parseSync, resolveTsconfig, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWebWorkerPostPlugin };
|