@rolldown/browser 1.0.0-rc.1 → 1.0.0-rc.11
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 +705 -1101
- package/dist/config.d.mts +9 -4
- package/dist/config.mjs +4 -13
- package/dist/{shared/constructors-BTW-c3jX.mjs → constructors-LtcP0f-6.js} +14 -7
- package/dist/error-nyELQq9T.js +157 -0
- package/dist/experimental-index.browser.mjs +74 -15
- package/dist/experimental-index.d.mts +128 -56
- package/dist/experimental-index.mjs +76 -17
- package/dist/filter-index.d.mts +1 -1
- package/dist/filter-index.mjs +25 -6
- package/dist/get-log-filter.d.mts +3 -7
- package/dist/get-log-filter.mjs +23 -3
- package/dist/index.browser.mjs +70 -75
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +6 -12
- package/dist/{normalize-string-or-regex-CL-PJZI7.js → normalize-string-or-regex-Db8ibFkp.js} +25 -23
- package/dist/parallel-plugin-worker.mjs +3 -7
- package/dist/parallel-plugin.d.mts +4 -4
- package/dist/parallel-plugin.mjs +1 -2
- package/dist/parse-ast-index.d.mts +27 -3
- package/dist/parse-ast-index.mjs +60 -3
- package/dist/plugins-index.browser.mjs +8 -7
- package/dist/plugins-index.d.mts +7 -4
- package/dist/plugins-index.mjs +8 -7
- package/dist/resolve-tsconfig-CkWJwi9L.js +112 -0
- package/dist/rolldown-binding.wasi-browser.js +6 -1
- package/dist/rolldown-binding.wasi.cjs +6 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/{rolldown-build-C4tDS_XC.js → rolldown-build-BPQtF2AA.js} +1063 -745
- package/dist/shared/{bindingify-input-options-Bp2kpiI8.mjs → bindingify-input-options-CSSx7s5e.mjs} +124 -165
- package/dist/shared/{composable-filters-CIxSuZSM.mjs → composable-filters-B2ByPP8y.mjs} +1 -4
- package/dist/{constructors-B8gqcrFr.js → shared/constructors-BGLoUvKR.mjs} +14 -7
- package/dist/shared/{constructors-5bt5oBhE.d.mts → constructors-BVnf_fH1.d.mts} +13 -4
- package/dist/shared/define-config-Cr6054d_.d.mts +3869 -0
- package/dist/shared/{define-config-Dlptvz3X.mjs → define-config-DJOr6Iwt.mjs} +1 -2
- package/dist/shared/error-CQ6njWsV.mjs +86 -0
- package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
- package/dist/shared/{load-config-BBZgIUGN.mjs → load-config-CXtSVabV.mjs} +11 -5
- package/dist/shared/{logging-Nvu645a7.d.mts → logging-C6h4g8dA.d.mts} +6 -6
- package/dist/shared/{logs-B2CASPcx.mjs → logs-D80CXhvg.mjs} +6 -9
- package/dist/shared/{normalize-string-or-regex-DIwprzLy.mjs → normalize-string-or-regex-D0o84ejN.mjs} +21 -16
- package/dist/shared/parse-B_jvq8dU.mjs +73 -0
- package/dist/shared/{prompt-B6NrDD1-.mjs → prompt-BYQIwEjg.mjs} +4 -6
- package/dist/shared/resolve-tsconfig-Cwoo4h_o.mjs +112 -0
- package/dist/shared/{rolldown-C0_W0QdY.mjs → rolldown-D-bh1N9N.mjs} +2 -4
- package/dist/shared/rolldown-build-Bysdmf-9.mjs +3320 -0
- package/dist/shared/transform-DEgNAQOQ.d.mts +149 -0
- package/dist/shared/{types-CIYK49jr.d.mts → types-K2r0mx6Y.d.mts} +11 -9
- package/dist/shared/{watch-eIop0yN6.mjs → watch-V9eI6ua1.mjs} +71 -76
- package/dist/utils-index.browser.mjs +2414 -0
- package/dist/utils-index.d.mts +1673 -0
- package/dist/utils-index.mjs +2414 -0
- package/package.json +1 -1
- package/dist/cli-setup.d.mts +0 -1
- package/dist/cli-setup.mjs +0 -16
- package/dist/shared/define-config-CDlEOpr1.d.mts +0 -3531
- package/dist/shared/parse-ast-index-2ahkCVK6.mjs +0 -98
- package/dist/shared/rolldown-build-DLuUhuNw.mjs +0 -2368
- /package/dist/shared/{utils-CqMTwlsR.d.mts → utils-6wxe_LMG.d.mts} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-D0o84ejN.mjs";
|
|
2
|
+
import { o as transformToRollupOutput } from "./shared/bindingify-input-options-CSSx7s5e.mjs";
|
|
3
|
+
import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-Bysdmf-9.mjs";
|
|
4
|
+
import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-CQ6njWsV.mjs";
|
|
5
|
+
import { n as parseSync$2, t as parse$2 } from "./shared/parse-B_jvq8dU.mjs";
|
|
6
|
+
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 "./shared/constructors-BGLoUvKR.mjs";
|
|
7
|
+
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 "./shared/resolve-tsconfig-Cwoo4h_o.mjs";
|
|
8
|
+
import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, isolatedDeclarationSync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi.cjs";
|
|
7
9
|
import { pathToFileURL } from "node:url";
|
|
8
|
-
|
|
9
10
|
//#region src/api/dev/dev-engine.ts
|
|
10
11
|
var DevEngine = class DevEngine {
|
|
11
12
|
#inner;
|
|
@@ -97,11 +98,9 @@ var DevEngine = class DevEngine {
|
|
|
97
98
|
return this.#inner.compileEntry(moduleId, clientId);
|
|
98
99
|
}
|
|
99
100
|
};
|
|
100
|
-
|
|
101
101
|
//#endregion
|
|
102
102
|
//#region src/api/dev/index.ts
|
|
103
103
|
const dev = (...args) => DevEngine.create(...args);
|
|
104
|
-
|
|
105
104
|
//#endregion
|
|
106
105
|
//#region src/types/external-memory-handle.ts
|
|
107
106
|
const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
|
|
@@ -142,7 +141,6 @@ const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
|
|
|
142
141
|
function freeExternalMemory(handle, keepDataAlive = false) {
|
|
143
142
|
return handle[symbolForExternalMemoryHandle](keepDataAlive);
|
|
144
143
|
}
|
|
145
|
-
|
|
146
144
|
//#endregion
|
|
147
145
|
//#region src/api/experimental.ts
|
|
148
146
|
/**
|
|
@@ -183,7 +181,6 @@ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
|
|
|
183
181
|
}
|
|
184
182
|
return cleanupPromise;
|
|
185
183
|
};
|
|
186
|
-
|
|
187
184
|
//#endregion
|
|
188
185
|
//#region src/plugin/parallel-plugin.ts
|
|
189
186
|
function defineParallelPlugin(pluginPath) {
|
|
@@ -194,13 +191,64 @@ function defineParallelPlugin(pluginPath) {
|
|
|
194
191
|
} };
|
|
195
192
|
};
|
|
196
193
|
}
|
|
197
|
-
|
|
198
194
|
//#endregion
|
|
199
195
|
//#region src/builtin-plugin/alias-plugin.ts
|
|
200
196
|
function viteAliasPlugin(config) {
|
|
201
197
|
return new BuiltinPlugin("builtin:vite-alias", config);
|
|
202
198
|
}
|
|
203
|
-
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/builtin-plugin/bundle-analyzer-plugin.ts
|
|
201
|
+
/**
|
|
202
|
+
* A plugin that analyzes bundle composition and generates detailed reports.
|
|
203
|
+
*
|
|
204
|
+
* The plugin outputs a file containing detailed information about:
|
|
205
|
+
* - All chunks and their relationships
|
|
206
|
+
* - Modules bundled in each chunk
|
|
207
|
+
* - Import dependencies between chunks
|
|
208
|
+
* - Reachable modules from each entry point
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```js
|
|
212
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
213
|
+
*
|
|
214
|
+
* export default {
|
|
215
|
+
* plugins: [
|
|
216
|
+
* bundleAnalyzerPlugin()
|
|
217
|
+
* ]
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* **Custom filename**
|
|
223
|
+
* ```js
|
|
224
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
225
|
+
*
|
|
226
|
+
* export default {
|
|
227
|
+
* plugins: [
|
|
228
|
+
* bundleAnalyzerPlugin({
|
|
229
|
+
* fileName: 'bundle-analysis.json'
|
|
230
|
+
* })
|
|
231
|
+
* ]
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* **LLM-friendly markdown output**
|
|
237
|
+
* ```js
|
|
238
|
+
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
|
|
239
|
+
*
|
|
240
|
+
* export default {
|
|
241
|
+
* plugins: [
|
|
242
|
+
* bundleAnalyzerPlugin({
|
|
243
|
+
* format: 'md'
|
|
244
|
+
* })
|
|
245
|
+
* ]
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
function bundleAnalyzerPlugin(config) {
|
|
250
|
+
return new BuiltinPlugin("builtin:bundle-analyzer", config);
|
|
251
|
+
}
|
|
204
252
|
//#endregion
|
|
205
253
|
//#region src/builtin-plugin/transform-plugin.ts
|
|
206
254
|
function viteTransformPlugin(config) {
|
|
@@ -213,13 +261,11 @@ function viteTransformPlugin(config) {
|
|
|
213
261
|
yarnPnp: typeof process === "object" && !!process.versions?.pnp
|
|
214
262
|
});
|
|
215
263
|
}
|
|
216
|
-
|
|
217
264
|
//#endregion
|
|
218
265
|
//#region src/builtin-plugin/vite-manifest-plugin.ts
|
|
219
266
|
function viteManifestPlugin(config) {
|
|
220
267
|
return new BuiltinPlugin("builtin:vite-manifest", config);
|
|
221
268
|
}
|
|
222
|
-
|
|
223
269
|
//#endregion
|
|
224
270
|
//#region src/experimental-index.ts
|
|
225
271
|
/**
|
|
@@ -250,6 +296,19 @@ function viteManifestPlugin(config) {
|
|
|
250
296
|
* @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
|
|
251
297
|
*/
|
|
252
298
|
const memfs = void 0;
|
|
253
|
-
|
|
299
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
300
|
+
const parse = parse$2;
|
|
301
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
302
|
+
const parseSync = parseSync$2;
|
|
303
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
304
|
+
const minify = minify$2;
|
|
305
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
306
|
+
const minifySync = minifySync$2;
|
|
307
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
308
|
+
const transform = transform$1;
|
|
309
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
310
|
+
const transformSync = transformSync$1;
|
|
311
|
+
/** @deprecated Use from `rolldown/utils` instead. */
|
|
312
|
+
const TsconfigCache = TsconfigCache$2;
|
|
254
313
|
//#endregion
|
|
255
|
-
export { BindingRebuildStrategy, DevEngine, ResolverFactory,
|
|
314
|
+
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 };
|
package/dist/filter-index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as exprInterpreter, F as QueryFilterObject, G as interpreterImpl, H as importerId, I as TopLevelFilterExpression, J as or, K as moduleType, L as and, M as withFilter, N as FilterExpression, P as FilterExpressionKind, R as code, U as include, V as id, W as interpreter, X as query, Y as queries, q as not, z as exclude } from "./shared/define-config-Cr6054d_.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../pluginutils/dist/filter/filter-vite-plugins.d.ts
|
|
4
4
|
/**
|
package/dist/filter-index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as id, c as interpreter, d as not, f as or, g as isPromiseLike, h as arraify, i as exprInterpreter, l as interpreterImpl, m as query, n as code, o as importerId, p as queries, r as exclude, s as include, t as and, u as moduleType } from "./shared/composable-filters-
|
|
2
|
-
|
|
1
|
+
import { a as id, c as interpreter, d as not, f as or, g as isPromiseLike, h as arraify, i as exprInterpreter, l as interpreterImpl, m as query, n as code, o as importerId, p as queries, r as exclude, s as include, t as and, u as moduleType } from "./shared/composable-filters-B2ByPP8y.mjs";
|
|
3
2
|
//#region ../pluginutils/dist/filter/filter-vite-plugins.js
|
|
4
3
|
/**
|
|
5
4
|
* Filters out Vite plugins that have `apply: 'serve'` set.
|
|
@@ -55,7 +54,6 @@ function filterVitePlugins(plugins) {
|
|
|
55
54
|
}
|
|
56
55
|
return result;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
57
|
//#endregion
|
|
60
58
|
//#region ../pluginutils/dist/filter/simple-filters.js
|
|
61
59
|
/**
|
|
@@ -119,7 +117,6 @@ function makeIdFilterToMatchWithQuery(input) {
|
|
|
119
117
|
function makeRegexIdFilterToMatchWithQuery(input) {
|
|
120
118
|
return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
|
|
121
119
|
}
|
|
122
|
-
|
|
123
120
|
//#endregion
|
|
124
121
|
//#region src/plugin/with-filter.ts
|
|
125
122
|
function withFilterImpl(pluginOption, filterObjectList) {
|
|
@@ -147,6 +144,29 @@ function withFilterImpl(pluginOption, filterObjectList) {
|
|
|
147
144
|
});
|
|
148
145
|
return plugin;
|
|
149
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* A helper function to add plugin hook filters to a plugin or an array of plugins.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* import yaml from '@rollup/plugin-yaml';
|
|
153
|
+
* import { defineConfig } from 'rolldown';
|
|
154
|
+
* import { withFilter } from 'rolldown/filter';
|
|
155
|
+
*
|
|
156
|
+
* export default defineConfig({
|
|
157
|
+
* plugins: [
|
|
158
|
+
* // Run the transform hook of the `yaml` plugin
|
|
159
|
+
* // only for modules which end in `.yaml`
|
|
160
|
+
* withFilter(
|
|
161
|
+
* yaml({}),
|
|
162
|
+
* { transform: { id: /\.yaml$/ } },
|
|
163
|
+
* ),
|
|
164
|
+
* ],
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @category Config
|
|
169
|
+
*/
|
|
150
170
|
function withFilter(pluginOption, filterObject) {
|
|
151
171
|
return withFilterImpl(pluginOption, arraify(filterObject));
|
|
152
172
|
}
|
|
@@ -159,6 +179,5 @@ function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
|
|
|
159
179
|
}
|
|
160
180
|
return -1;
|
|
161
181
|
}
|
|
162
|
-
|
|
163
182
|
//#endregion
|
|
164
|
-
export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
|
|
183
|
+
export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { a as RolldownLog } from "./shared/logging-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
|
|
5
|
-
declare const getLogFilter: GetLogFilter;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { GetLogFilter, type RolldownLog, type RolldownLog as RollupLog, getLogFilter as default };
|
|
1
|
+
import { a as RolldownLog } from "./shared/logging-C6h4g8dA.mjs";
|
|
2
|
+
import { n as getLogFilter, t as GetLogFilter } from "./shared/get-log-filter-semyr3Lj.mjs";
|
|
3
|
+
export { GetLogFilter, RolldownLog, RolldownLog as RollupLog, getLogFilter as default };
|
package/dist/get-log-filter.mjs
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
//#region src/get-log-filter.ts
|
|
2
|
+
/**
|
|
3
|
+
* A helper function to generate log filters using the same syntax as the CLI.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { defineConfig } from 'rolldown';
|
|
8
|
+
* import { getLogFilter } from 'rolldown/getLogFilter';
|
|
9
|
+
*
|
|
10
|
+
* const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* input: 'main.js',
|
|
14
|
+
* onLog(level, log, handler) {
|
|
15
|
+
* if (logFilter(log)) {
|
|
16
|
+
* handler(level, log);
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @category Config
|
|
23
|
+
*/
|
|
2
24
|
const getLogFilter = (filters) => {
|
|
3
25
|
if (filters.length === 0) return () => true;
|
|
4
26
|
const normalizedFilters = filters.map((filter) => filter.split("&").map((subFilter) => {
|
|
@@ -42,7 +64,5 @@ const testFilter = (log, key, parts) => {
|
|
|
42
64
|
}
|
|
43
65
|
return value.endsWith(parts[lastPartIndex]);
|
|
44
66
|
};
|
|
45
|
-
var get_log_filter_default = getLogFilter;
|
|
46
|
-
|
|
47
67
|
//#endregion
|
|
48
|
-
export {
|
|
68
|
+
export { getLogFilter as default };
|
package/dist/index.browser.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { d as logMultipleWatcherOption } from "./normalize-string-or-regex-Db8ibFkp.js";
|
|
2
|
+
import { a as validateOption, c as arraify, l as RUNTIME_MODULE_ID, n as createBundlerOptions, o as PluginDriver, r as RolldownMagicString, s as LOG_LEVEL_WARN, t as RolldownBuild, u as VERSION } from "./rolldown-build-BPQtF2AA.js";
|
|
3
|
+
import { t as aggregateBindingErrorsIntoJsError } from "./error-nyELQq9T.js";
|
|
4
|
+
import { BindingWatcher, shutdownAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
|
|
5
5
|
//#region src/api/rolldown/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* The API compatible with Rollup's `rollup` function.
|
|
@@ -39,7 +39,6 @@ const rolldown = async (input) => {
|
|
|
39
39
|
validateOption("input", input);
|
|
40
40
|
return new RolldownBuild(await PluginDriver.callOptionsHook(input));
|
|
41
41
|
};
|
|
42
|
-
|
|
43
42
|
//#endregion
|
|
44
43
|
//#region src/api/build.ts
|
|
45
44
|
/**
|
|
@@ -74,15 +73,10 @@ async function build(options) {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
|
|
78
76
|
//#endregion
|
|
79
77
|
//#region src/api/watch/watch-emitter.ts
|
|
80
78
|
var WatcherEmitter = class {
|
|
81
79
|
listeners = /* @__PURE__ */ new Map();
|
|
82
|
-
timer;
|
|
83
|
-
constructor() {
|
|
84
|
-
this.timer = setInterval(() => {}, 1e9);
|
|
85
|
-
}
|
|
86
80
|
on(event, listener) {
|
|
87
81
|
const listeners = this.listeners.get(event);
|
|
88
82
|
if (listeners) listeners.push(listener);
|
|
@@ -98,58 +92,55 @@ var WatcherEmitter = class {
|
|
|
98
92
|
return this;
|
|
99
93
|
}
|
|
100
94
|
clear(event) {
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
async onEvent(event) {
|
|
104
|
-
const listeners = this.listeners.get(event.eventKind());
|
|
105
|
-
if (listeners) switch (event.eventKind()) {
|
|
106
|
-
case "close":
|
|
107
|
-
case "restart":
|
|
108
|
-
for (const listener of listeners) await listener();
|
|
109
|
-
break;
|
|
110
|
-
case "event":
|
|
111
|
-
for (const listener of listeners) {
|
|
112
|
-
const code = event.bundleEventKind();
|
|
113
|
-
switch (code) {
|
|
114
|
-
case "BUNDLE_END":
|
|
115
|
-
const { duration, output, result } = event.bundleEndData();
|
|
116
|
-
await listener({
|
|
117
|
-
code: "BUNDLE_END",
|
|
118
|
-
duration,
|
|
119
|
-
output: [output],
|
|
120
|
-
result
|
|
121
|
-
});
|
|
122
|
-
break;
|
|
123
|
-
case "ERROR":
|
|
124
|
-
const data = event.bundleErrorData();
|
|
125
|
-
await listener({
|
|
126
|
-
code: "ERROR",
|
|
127
|
-
error: aggregateBindingErrorsIntoJsError(data.error),
|
|
128
|
-
result: data.result
|
|
129
|
-
});
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
await listener({ code });
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
case "change":
|
|
138
|
-
for (const listener of listeners) {
|
|
139
|
-
const { path, kind } = event.watchChangeData();
|
|
140
|
-
await listener(path, { event: kind });
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
default: throw new Error(`Unknown event: ${event}`);
|
|
144
|
-
}
|
|
95
|
+
this.listeners.delete(event);
|
|
145
96
|
}
|
|
146
|
-
|
|
147
|
-
|
|
97
|
+
/** Async emit — sequential dispatch so side effects from earlier handlers
|
|
98
|
+
* (e.g. `event.result.close()` triggering `closeBundle`) are visible to later handlers. */
|
|
99
|
+
async emit(event, ...args) {
|
|
100
|
+
const handlers = this.listeners.get(event);
|
|
101
|
+
if (handlers?.length) for (const h of handlers) await h(...args);
|
|
148
102
|
}
|
|
103
|
+
async close() {}
|
|
149
104
|
};
|
|
150
|
-
|
|
151
105
|
//#endregion
|
|
152
106
|
//#region src/api/watch/watcher.ts
|
|
107
|
+
function createEventCallback(emitter) {
|
|
108
|
+
return async (event) => {
|
|
109
|
+
switch (event.eventKind()) {
|
|
110
|
+
case "event": {
|
|
111
|
+
const code = event.bundleEventKind();
|
|
112
|
+
if (code === "BUNDLE_END") {
|
|
113
|
+
const { duration, output, result } = event.bundleEndData();
|
|
114
|
+
await emitter.emit("event", {
|
|
115
|
+
code: "BUNDLE_END",
|
|
116
|
+
duration,
|
|
117
|
+
output: [output],
|
|
118
|
+
result
|
|
119
|
+
});
|
|
120
|
+
} else if (code === "ERROR") {
|
|
121
|
+
const data = event.bundleErrorData();
|
|
122
|
+
await emitter.emit("event", {
|
|
123
|
+
code: "ERROR",
|
|
124
|
+
error: aggregateBindingErrorsIntoJsError(data.error),
|
|
125
|
+
result: data.result
|
|
126
|
+
});
|
|
127
|
+
} else await emitter.emit("event", { code });
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "change": {
|
|
131
|
+
const { path, kind } = event.watchChangeData();
|
|
132
|
+
await emitter.emit("change", path, { event: kind });
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "restart":
|
|
136
|
+
await emitter.emit("restart");
|
|
137
|
+
break;
|
|
138
|
+
case "close":
|
|
139
|
+
await emitter.emit("close");
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
153
144
|
var Watcher = class {
|
|
154
145
|
closed;
|
|
155
146
|
inner;
|
|
@@ -165,6 +156,7 @@ var Watcher = class {
|
|
|
165
156
|
originClose();
|
|
166
157
|
};
|
|
167
158
|
this.stopWorkers = stopWorkers;
|
|
159
|
+
process.nextTick(() => this.run());
|
|
168
160
|
}
|
|
169
161
|
async close() {
|
|
170
162
|
if (this.closed) return;
|
|
@@ -173,8 +165,9 @@ var Watcher = class {
|
|
|
173
165
|
await this.inner.close();
|
|
174
166
|
shutdownAsyncRuntime();
|
|
175
167
|
}
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
async run() {
|
|
169
|
+
await this.inner.run();
|
|
170
|
+
this.inner.waitForClose();
|
|
178
171
|
}
|
|
179
172
|
};
|
|
180
173
|
async function createWatcher(emitter, input) {
|
|
@@ -182,20 +175,24 @@ async function createWatcher(emitter, input) {
|
|
|
182
175
|
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
183
176
|
return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
|
|
184
177
|
})).flat());
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
warnMultiplePollingOptions(bundlerOptions);
|
|
179
|
+
const callback = createEventCallback(emitter);
|
|
180
|
+
new Watcher(emitter, new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), callback), bundlerOptions.map((option) => option.stopWorkers));
|
|
187
181
|
}
|
|
188
|
-
function
|
|
189
|
-
let
|
|
190
|
-
for (const option of bundlerOptions)
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
182
|
+
function warnMultiplePollingOptions(bundlerOptions) {
|
|
183
|
+
let found = false;
|
|
184
|
+
for (const option of bundlerOptions) {
|
|
185
|
+
const watch = option.inputOptions.watch;
|
|
186
|
+
const watcher = watch && typeof watch === "object" ? watch.watcher ?? watch.notify : void 0;
|
|
187
|
+
if (watcher && (watcher.usePolling != null || watcher.pollInterval != null)) {
|
|
188
|
+
if (found) {
|
|
189
|
+
option.onLog(LOG_LEVEL_WARN, logMultipleWatcherOption());
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
found = true;
|
|
193
|
+
}
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
|
-
|
|
199
196
|
//#endregion
|
|
200
197
|
//#region src/api/watch/index.ts
|
|
201
198
|
/**
|
|
@@ -227,17 +224,15 @@ function getValidNotifyOption(bundlerOptions) {
|
|
|
227
224
|
* @experimental
|
|
228
225
|
* @category Programmatic APIs
|
|
229
226
|
*/
|
|
230
|
-
|
|
227
|
+
function watch(input) {
|
|
231
228
|
const emitter = new WatcherEmitter();
|
|
232
229
|
createWatcher(emitter, input);
|
|
233
230
|
return emitter;
|
|
234
|
-
}
|
|
235
|
-
|
|
231
|
+
}
|
|
236
232
|
//#endregion
|
|
237
233
|
//#region src/utils/define-config.ts
|
|
238
234
|
function defineConfig(config) {
|
|
239
235
|
return config;
|
|
240
236
|
}
|
|
241
|
-
|
|
242
237
|
//#endregion
|
|
243
|
-
export {
|
|
238
|
+
export { RUNTIME_MODULE_ID, RolldownMagicString, VERSION, build, defineConfig, rolldown, watch };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { o as PartialNull } from "./shared/utils-
|
|
4
|
-
export { AddonFunction, AdvancedChunksGroup, AdvancedChunksOptions, AsyncPluginHooks,
|
|
1
|
+
import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-C6h4g8dA.mjs";
|
|
2
|
+
import { $ as VERSION, $t as MinifyOptions, A as SourceDescription, At as WarningHandlerWithDefault, Bt as build, C as PartialResolvedId, Ct as RolldownFsModule, D as ResolvedId, Dt as TransformOptions, E as ResolveIdResult, Et as NormalizedInputOptions, Ft as RolldownWatcherWatcherEventMap, Gt as ChunkingContext, Ht as AdvancedChunksGroup, It as WatchOptions, Jt as CodeSplittingOptions, Kt as CodeSplittingGroup, Lt as rolldown, Mt as watch, Nt as RolldownWatcher, O as RolldownPlugin, Ot as ChecksOptions, Pt as RolldownWatcherEvent, Q as RUNTIME_MODULE_ID, Qt as GlobalsFunction, Rt as RolldownBuild, S as ParallelPluginHooks, St as RolldownFileStats, T as ResolveIdExtraOptions, Tt as NormalizedOutputOptions, Ut as AdvancedChunksOptions, Vt as AddonFunction, Wt as ChunkFileNamesFunction, Xt as GeneratedCodeOptions, Yt as CommentsOptions, Z as PreRenderedChunk, Zt as GeneratedCodePreset, _ as ImportKind, _t as GeneralHookFilter, a as ExternalOption, an as RenderedChunk, at as TransformPluginContext, b as ModuleType, bt as BufferEncoding, c as InputOptions, cn as SourceMap, ct as EmittedFile, d as WatcherFileWatcherOptions, dn as SourcemapIgnoreListOption, dt as PluginContext, en as ModuleFormat, et as BundleError, f as WatcherOptions, ft as PluginContextResolveOptions, g as HookFilterExtension, gt as PluginContextMeta, h as FunctionPluginHooks, ht as MinimalPluginContext, i as RolldownOptions, in as OutputChunk, it as TreeshakingOptions, j as TransformResult, jt as RolldownMagicString, k as RolldownPluginOption, kt as LoggingFunction, l as ModuleTypes, lt as EmittedPrebuiltChunk, m as CustomPluginOptions, n as RolldownOptionsFunction, nn as PreRenderedAsset, nt as SourceMapInput, o as ExternalOptionFunction, on as RenderedModule, ot as EmittedAsset, p as AsyncPluginHooks, pt as DefineParallelPluginResult, qt as CodeSplittingNameFunction, r as defineConfig, rn as OutputAsset, rt as OutputBundle, s as InputOption, sn as RolldownOutput, st as EmittedChunk, t as ConfigExport, tn as OutputOptions, tt as ExistingRawSourceMap, u as OptimizationOptions, un as ModuleInfo, ut as GetModuleInfo, v as LoadResult, vt as HookFilter, w as Plugin, wt as InternalModuleFormat, x as ObjectHook, xt as RolldownDirectoryEntry, y as ModuleOptions, yt as ModuleTypeFilter, zt as BuildOptions } from "./shared/define-config-Cr6054d_.mjs";
|
|
3
|
+
import { o as PartialNull } from "./shared/utils-6wxe_LMG.mjs";
|
|
4
|
+
export { AddonFunction, AdvancedChunksGroup, AdvancedChunksOptions, AsyncPluginHooks, BufferEncoding, BuildOptions, BundleError, ChecksOptions, ChunkFileNamesFunction, ChunkingContext, CodeSplittingGroup, CodeSplittingNameFunction, CodeSplittingOptions, CommentsOptions, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedChunk, EmittedFile, EmittedPrebuiltChunk, ExistingRawSourceMap, ExternalOption, ExternalOptionFunction, FunctionPluginHooks, GeneralHookFilter, GeneratedCodeOptions, GeneratedCodePreset, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PluginContextResolveOptions, PreRenderedAsset, PreRenderedChunk, RUNTIME_MODULE_ID, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownError, RolldownError as RollupError, RolldownFileStats, RolldownFsModule, RolldownLog, RolldownLog as RollupLog, RolldownLogWithString, RolldownLogWithString as RollupLogWithString, RolldownMagicString, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RolldownWatcherWatcherEventMap, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformOptions, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherFileWatcherOptions, WatcherOptions, build, defineConfig, rolldown, watch };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { n as onExit, t as watch } from "./shared/watch-
|
|
2
|
-
import "./shared/
|
|
3
|
-
import {
|
|
4
|
-
import "./shared/
|
|
5
|
-
import "./shared/parse-ast-index-2ahkCVK6.mjs";
|
|
6
|
-
import { t as rolldown } from "./shared/rolldown-C0_W0QdY.mjs";
|
|
7
|
-
import { t as defineConfig } from "./shared/define-config-Dlptvz3X.mjs";
|
|
1
|
+
import { n as onExit, t as watch } from "./shared/watch-V9eI6ua1.mjs";
|
|
2
|
+
import { a as RolldownMagicString, b as RUNTIME_MODULE_ID, x as VERSION } from "./shared/bindingify-input-options-CSSx7s5e.mjs";
|
|
3
|
+
import { t as rolldown } from "./shared/rolldown-D-bh1N9N.mjs";
|
|
4
|
+
import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
|
|
8
5
|
import { isMainThread } from "node:worker_threads";
|
|
9
|
-
import {
|
|
10
|
-
|
|
6
|
+
import { initTraceSubscriber } from "./rolldown-binding.wasi.cjs";
|
|
11
7
|
//#region src/setup.ts
|
|
12
8
|
if (isMainThread) {
|
|
13
9
|
const subscriberGuard = initTraceSubscriber();
|
|
@@ -15,7 +11,6 @@ if (isMainThread) {
|
|
|
15
11
|
subscriberGuard?.close();
|
|
16
12
|
});
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
//#endregion
|
|
20
15
|
//#region src/api/build.ts
|
|
21
16
|
/**
|
|
@@ -50,6 +45,5 @@ async function build(options) {
|
|
|
50
45
|
}
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
|
-
|
|
54
48
|
//#endregion
|
|
55
|
-
export {
|
|
49
|
+
export { RUNTIME_MODULE_ID, RolldownMagicString, VERSION, build, defineConfig, rolldown, watch };
|
package/dist/{normalize-string-or-regex-CL-PJZI7.js → normalize-string-or-regex-Db8ibFkp.js}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/code-frame.ts
|
|
4
3
|
function spaces(index) {
|
|
5
4
|
let result = "";
|
|
@@ -37,7 +36,6 @@ function getCodeFrame(source, line, column) {
|
|
|
37
36
|
return `${lineNumber}: ${displayedLine}`;
|
|
38
37
|
}).join("\n");
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
//#endregion
|
|
42
40
|
//#region src/log/locate-character/index.js
|
|
43
41
|
/** @typedef {import('./types').Location} Location */
|
|
@@ -98,10 +96,9 @@ function getLocator(source, options = {}) {
|
|
|
98
96
|
function locate(source, search, options) {
|
|
99
97
|
return getLocator(source, options)(search, options && options.startIndex);
|
|
100
98
|
}
|
|
101
|
-
|
|
102
99
|
//#endregion
|
|
103
100
|
//#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",
|
|
101
|
+
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", MULTIPLE_WATCHER_OPTION = "MULTIPLE_WATCHER_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
|
|
105
102
|
function logParseError(message, id, pos) {
|
|
106
103
|
return {
|
|
107
104
|
code: PARSE_ERROR,
|
|
@@ -128,10 +125,10 @@ function logCycleLoading(pluginName, moduleId) {
|
|
|
128
125
|
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
129
126
|
};
|
|
130
127
|
}
|
|
131
|
-
function
|
|
128
|
+
function logMultipleWatcherOption() {
|
|
132
129
|
return {
|
|
133
|
-
code:
|
|
134
|
-
message: `Found
|
|
130
|
+
code: MULTIPLE_WATCHER_OPTION,
|
|
131
|
+
message: `Found multiple watcher options at watch options, using first one to start watcher.`
|
|
135
132
|
};
|
|
136
133
|
}
|
|
137
134
|
function logNoFileSystemInBrowser(method) {
|
|
@@ -156,7 +153,7 @@ function error(base) {
|
|
|
156
153
|
if (!(base instanceof Error)) {
|
|
157
154
|
base = Object.assign(new Error(base.message), base);
|
|
158
155
|
Object.defineProperty(base, "name", {
|
|
159
|
-
value: "
|
|
156
|
+
value: "RolldownError",
|
|
160
157
|
writable: true
|
|
161
158
|
});
|
|
162
159
|
}
|
|
@@ -186,7 +183,6 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
186
183
|
properties.frame = getCodeFrame(source, line, column);
|
|
187
184
|
}
|
|
188
185
|
}
|
|
189
|
-
|
|
190
186
|
//#endregion
|
|
191
187
|
//#region src/builtin-plugin/utils.ts
|
|
192
188
|
var BuiltinPlugin = class {
|
|
@@ -200,17 +196,25 @@ var BuiltinPlugin = class {
|
|
|
200
196
|
function makeBuiltinPluginCallable(plugin) {
|
|
201
197
|
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
202
198
|
const wrappedPlugin = plugin;
|
|
203
|
-
for (const key in callablePlugin)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
199
|
+
for (const key in callablePlugin) {
|
|
200
|
+
const wrappedHook = async function(...args) {
|
|
201
|
+
try {
|
|
202
|
+
return await callablePlugin[key](...args);
|
|
203
|
+
} catch (e) {
|
|
204
|
+
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
|
|
205
|
+
return error(logPluginError(e, plugin.name, {
|
|
206
|
+
hook: key,
|
|
207
|
+
id: key === "transform" ? args[2] : void 0
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const order = callablePlugin.getOrder(key);
|
|
212
|
+
if (order == void 0) wrappedPlugin[key] = wrappedHook;
|
|
213
|
+
else wrappedPlugin[key] = {
|
|
214
|
+
handler: wrappedHook,
|
|
215
|
+
order
|
|
216
|
+
};
|
|
217
|
+
}
|
|
214
218
|
return wrappedPlugin;
|
|
215
219
|
}
|
|
216
220
|
function bindingifyBuiltInPlugin(plugin) {
|
|
@@ -231,7 +235,6 @@ function bindingifyManifestPlugin(plugin, pluginContextData) {
|
|
|
231
235
|
}
|
|
232
236
|
};
|
|
233
237
|
}
|
|
234
|
-
|
|
235
238
|
//#endregion
|
|
236
239
|
//#region src/utils/normalize-string-or-regex.ts
|
|
237
240
|
function normalizedStringOrRegex(pattern) {
|
|
@@ -242,6 +245,5 @@ function normalizedStringOrRegex(pattern) {
|
|
|
242
245
|
function isReadonlyArray(input) {
|
|
243
246
|
return Array.isArray(input);
|
|
244
247
|
}
|
|
245
|
-
|
|
246
248
|
//#endregion
|
|
247
|
-
export { makeBuiltinPluginCallable as a, logCycleLoading as c,
|
|
249
|
+
export { makeBuiltinPluginCallable as a, logCycleLoading as c, logMultipleWatcherOption as d, logNoFileSystemInBrowser as f, getCodeFrame as g, locate as h, bindingifyManifestPlugin as i, logInputHookInOutputPlugin as l, logPluginError as m, BuiltinPlugin as n, augmentCodeLocation as o, logParseError as p, bindingifyBuiltInPlugin as r, error as s, normalizedStringOrRegex as t, logInvalidLogPosition as u };
|