@rolldown/browser 1.0.0-beta.55 → 1.0.0-beta.57

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 (39) hide show
  1. package/dist/cli.mjs +7 -7
  2. package/dist/config.d.mts +1 -1
  3. package/dist/config.mjs +6 -6
  4. package/dist/{constructors-DoEj0CTZ.js → constructors-hZ5LHCkF.js} +1 -1
  5. package/dist/experimental-index.browser.mjs +30 -3
  6. package/dist/experimental-index.d.mts +31 -4
  7. package/dist/experimental-index.mjs +32 -5
  8. package/dist/experimental-runtime-types.d.ts +1 -1
  9. package/dist/filter-index.d.mts +3 -3
  10. package/dist/filter-index.mjs +123 -2
  11. package/dist/index.browser.mjs +2 -2
  12. package/dist/index.d.mts +3 -3
  13. package/dist/index.mjs +6 -6
  14. package/dist/{normalize-string-or-regex-dwgRHUz6.js → normalize-string-or-regex-DewaIpuo.js} +5 -3
  15. package/dist/parallel-plugin-worker.mjs +3 -3
  16. package/dist/parallel-plugin.d.mts +2 -2
  17. package/dist/parse-ast-index.d.mts +1 -1
  18. package/dist/parse-ast-index.mjs +1 -1
  19. package/dist/plugins-index.browser.mjs +2 -2
  20. package/dist/plugins-index.d.mts +3 -3
  21. package/dist/plugins-index.mjs +2 -2
  22. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  23. package/dist/{rolldown-build-7uuCodq1.js → rolldown-build-32P3iU2U.js} +44 -12
  24. package/dist/shared/{binding-r9j8jqRV.d.mts → binding-CDyF6W3D.d.mts} +13 -10
  25. package/dist/shared/{bindingify-input-options-nvXYfbt3.mjs → bindingify-input-options-CwdDrVAR.mjs} +34 -6
  26. package/dist/shared/composable-filters-C5qA4jo-.mjs +206 -0
  27. package/dist/shared/{constructors-G-fr57ib.d.mts → constructors-B0L_9ar3.d.mts} +2 -2
  28. package/dist/shared/{constructors-oU7W7sz4.mjs → constructors-Ch7pGFBC.mjs} +1 -1
  29. package/dist/shared/{define-config-Bwwa5Tc_.d.mts → define-config-Bho_aQn8.d.mts} +11 -5
  30. package/dist/shared/{load-config-DumfiMa-.mjs → load-config-DUtgyO78.mjs} +1 -1
  31. package/dist/shared/{logs-By66Jt-E.mjs → logs-DEfpOy5A.mjs} +4 -2
  32. package/dist/shared/{normalize-string-or-regex-FzNsMab1.mjs → normalize-string-or-regex-Dt2VqAqy.mjs} +2 -2
  33. package/dist/shared/{parse-ast-index-BZ4FJxMm.mjs → parse-ast-index-DZPue_kI.mjs} +10 -7
  34. package/dist/shared/{rolldown-CTRsCETA.mjs → rolldown-D1ymUD73.mjs} +1 -1
  35. package/dist/shared/{rolldown-build-D8oOi181.mjs → rolldown-build-rs9zb03O.mjs} +7 -6
  36. package/dist/shared/{utils-CMDrspre.d.mts → utils-B3dcnHc8.d.mts} +1 -1
  37. package/dist/shared/{watch-DDjo8C9u.mjs → watch-CbHTfwHk.mjs} +4 -4
  38. package/package.json +1 -1
  39. package/dist/shared/composable-filters-G1eqjHFo.mjs +0 -122
package/dist/cli.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { n as onExit, t as watch } from "./shared/watch-DDjo8C9u.mjs";
1
+ import { n as onExit, t as watch } from "./shared/watch-CbHTfwHk.mjs";
2
2
  import { t as arraify } from "./shared/misc-BubmxcE3.mjs";
3
- import { b as description, x as version } from "./shared/normalize-string-or-regex-FzNsMab1.mjs";
4
- import { a as getOutputCliKeys, c as styleText$1, i as getInputCliKeys, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/rolldown-build-D8oOi181.mjs";
5
- import "./shared/bindingify-input-options-nvXYfbt3.mjs";
6
- import "./shared/parse-ast-index-BZ4FJxMm.mjs";
7
- import { t as rolldown } from "./shared/rolldown-CTRsCETA.mjs";
8
- import { t as loadConfig } from "./shared/load-config-DumfiMa-.mjs";
3
+ import { b as description, x as version } from "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
4
+ import { a as getOutputCliKeys, c as styleText$1, i as getInputCliKeys, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/rolldown-build-rs9zb03O.mjs";
5
+ import "./shared/bindingify-input-options-CwdDrVAR.mjs";
6
+ import "./shared/parse-ast-index-DZPue_kI.mjs";
7
+ import { t as rolldown } from "./shared/rolldown-D1ymUD73.mjs";
8
+ import { t as loadConfig } from "./shared/load-config-DUtgyO78.mjs";
9
9
  import path, { sep } from "node:path";
10
10
  import { formatWithOptions, parseArgs } from "node:util";
11
11
  import process$1 from "node:process";
package/dist/config.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ConfigExport, t as defineConfig } from "./shared/define-config-Bwwa5Tc_.mjs";
1
+ import { n as ConfigExport, t as defineConfig } from "./shared/define-config-Bho_aQn8.mjs";
2
2
 
3
3
  //#region src/utils/load-config.d.ts
4
4
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
package/dist/config.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { x as version } from "./shared/normalize-string-or-regex-FzNsMab1.mjs";
2
- import "./shared/rolldown-build-D8oOi181.mjs";
3
- import "./shared/bindingify-input-options-nvXYfbt3.mjs";
4
- import "./shared/parse-ast-index-BZ4FJxMm.mjs";
5
- import "./shared/rolldown-CTRsCETA.mjs";
1
+ import { x as version } from "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
2
+ import "./shared/rolldown-build-rs9zb03O.mjs";
3
+ import "./shared/bindingify-input-options-CwdDrVAR.mjs";
4
+ import "./shared/parse-ast-index-DZPue_kI.mjs";
5
+ import "./shared/rolldown-D1ymUD73.mjs";
6
6
  import { t as defineConfig } from "./shared/define-config-BF4P-Pum.mjs";
7
- import { t as loadConfig } from "./shared/load-config-DumfiMa-.mjs";
7
+ import { t as loadConfig } from "./shared/load-config-DUtgyO78.mjs";
8
8
 
9
9
  //#region src/config.ts
10
10
  const VERSION = version;
@@ -1,4 +1,4 @@
1
- import { n as BuiltinPlugin, s as makeBuiltinPluginCallable, t as normalizedStringOrRegex } from "./normalize-string-or-regex-dwgRHUz6.js";
1
+ import { n as BuiltinPlugin, s as makeBuiltinPluginCallable, t as normalizedStringOrRegex } from "./normalize-string-or-regex-DewaIpuo.js";
2
2
 
3
3
  //#region src/builtin-plugin/constructors.ts
4
4
  function viteModulePreloadPolyfillPlugin(config) {
@@ -1,6 +1,6 @@
1
- import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./normalize-string-or-regex-dwgRHUz6.js";
2
- import { a as unwrapBindingResult, c as validateOption, i as normalizeBindingResult, l as PluginDriver, n as createBundlerOptions, o as parse, s as parseSync, t as RolldownBuild } from "./rolldown-build-7uuCodq1.js";
3
- import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./constructors-DoEj0CTZ.js";
1
+ import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./normalize-string-or-regex-DewaIpuo.js";
2
+ import { a as unwrapBindingResult, c as validateOption, i as normalizeBindingResult, l as PluginDriver, n as createBundlerOptions, o as parse, s as parseSync, t as RolldownBuild } from "./rolldown-build-32P3iU2U.js";
3
+ import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./constructors-hZ5LHCkF.js";
4
4
  import * as binding from "./rolldown-binding.wasi-browser.js";
5
5
  import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, createTokioRuntime, isolatedDeclaration, isolatedDeclarationSync, minify, minifySync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime, transform, transformSync } from "./rolldown-binding.wasi-browser.js";
6
6
 
@@ -234,6 +234,33 @@ function viteManifestPlugin(config) {
234
234
 
235
235
  //#endregion
236
236
  //#region src/experimental-index.ts
237
+ /**
238
+ * In-memory file system for browser builds.
239
+ *
240
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
241
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
242
+ *
243
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
244
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
245
+ *
246
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * import { memfs } from 'rolldown/experimental';
251
+ *
252
+ * // Write files to virtual filesystem before bundling
253
+ * memfs?.volume.fromJSON({
254
+ * '/src/index.js': 'export const foo = 42;',
255
+ * '/package.json': '{"name": "my-app"}'
256
+ * });
257
+ *
258
+ * // Read files from the virtual filesystem
259
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
260
+ * ```
261
+ *
262
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
263
+ */
237
264
  const memfs = {
238
265
  fs: binding.__fs,
239
266
  volume: binding.__volume
@@ -1,7 +1,7 @@
1
- import { $ as transformSync, B as ParserOptions, C as BindingViteManifestPluginConfig, G as TransformResult, H as ResolveResult, I as MinifyOptions, J as isolatedDeclarationSync, K as createTokioRuntime, L as MinifyResult, N as IsolatedDeclarationsOptions, O as BindingViteTransformPluginConfig, P as IsolatedDeclarationsResult, Q as transform, R as NapiResolveOptions, U as ResolverFactory, W as TransformOptions, X as minifySync, Y as minify, Z as moduleRunnerTransform, _ as BindingViteCssPostPluginConfig, b as BindingViteHtmlPluginConfig, c as BindingRebuildStrategy, f as BindingUrlResolver, g as BindingViteCssPluginConfig, m as BindingViteAssetPluginConfig, n as BindingBundleState, q as isolatedDeclaration, r as BindingClientHmrUpdate, z as ParseResult } from "./shared/binding-r9j8jqRV.mjs";
2
- import { Et as freeExternalMemory, M as SourceMapInput, P as OutputBundle, U as defineParallelPlugin, W as MinimalPluginContext, et as NormalizedOutputOptions, o as InputOptions, vt as OutputOptions, wt as RolldownOutput, xt as OutputChunk } from "./shared/define-config-Bwwa5Tc_.mjs";
3
- import { t as BuiltinPlugin } from "./shared/utils-CMDrspre.mjs";
4
- import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-G-fr57ib.mjs";
1
+ import { $ as transformSync, B as ParserOptions, C as BindingViteManifestPluginConfig, G as TransformResult, H as ResolveResult, I as MinifyOptions, J as isolatedDeclarationSync, K as createTokioRuntime, L as MinifyResult, N as IsolatedDeclarationsOptions, O as BindingViteTransformPluginConfig, P as IsolatedDeclarationsResult, Q as transform, R as NapiResolveOptions, U as ResolverFactory, W as TransformOptions, X as minifySync, Y as minify, Z as moduleRunnerTransform, _ as BindingViteCssPostPluginConfig, b as BindingViteHtmlPluginConfig, c as BindingRebuildStrategy, f as BindingUrlResolver, g as BindingViteCssPluginConfig, m as BindingViteAssetPluginConfig, n as BindingBundleState, q as isolatedDeclaration, r as BindingClientHmrUpdate, z as ParseResult } from "./shared/binding-CDyF6W3D.mjs";
2
+ import { Et as freeExternalMemory, M as SourceMapInput, P as OutputBundle, U as defineParallelPlugin, W as MinimalPluginContext, et as NormalizedOutputOptions, o as InputOptions, vt as OutputOptions, wt as RolldownOutput, xt as OutputChunk } from "./shared/define-config-Bho_aQn8.mjs";
3
+ import { t as BuiltinPlugin } from "./shared/utils-B3dcnHc8.mjs";
4
+ import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-B0L_9ar3.mjs";
5
5
 
6
6
  //#region src/api/dev/dev-options.d.ts
7
7
  type DevOnHmrUpdates = (result: Error | {
@@ -193,6 +193,33 @@ type ViteManifestPluginConfig = Omit<BindingViteManifestPluginConfig, "isLegacy"
193
193
  declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPlugin;
194
194
  //#endregion
195
195
  //#region src/experimental-index.d.ts
196
+ /**
197
+ * In-memory file system for browser builds.
198
+ *
199
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
200
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
201
+ *
202
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
203
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
204
+ *
205
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * import { memfs } from 'rolldown/experimental';
210
+ *
211
+ * // Write files to virtual filesystem before bundling
212
+ * memfs?.volume.fromJSON({
213
+ * '/src/index.js': 'export const foo = 42;',
214
+ * '/package.json': '{"name": "my-app"}'
215
+ * });
216
+ *
217
+ * // Read files from the virtual filesystem
218
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
219
+ * ```
220
+ *
221
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
222
+ */
196
223
  declare const memfs: {
197
224
  fs: any;
198
225
  volume: any;
@@ -1,8 +1,8 @@
1
- import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./shared/normalize-string-or-regex-FzNsMab1.mjs";
2
- import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build-D8oOi181.mjs";
3
- import { o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-nvXYfbt3.mjs";
4
- import { i as parseSync, r as parse } from "./shared/parse-ast-index-BZ4FJxMm.mjs";
5
- import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-oU7W7sz4.mjs";
1
+ import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
2
+ import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build-rs9zb03O.mjs";
3
+ import { o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-CwdDrVAR.mjs";
4
+ import { i as parseSync, r as parse } from "./shared/parse-ast-index-DZPue_kI.mjs";
5
+ import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-Ch7pGFBC.mjs";
6
6
  import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, createTokioRuntime, isolatedDeclaration, isolatedDeclarationSync, minify, minifySync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime, transform, transformSync } from "./rolldown-binding.wasi.cjs";
7
7
  import { pathToFileURL } from "node:url";
8
8
 
@@ -241,6 +241,33 @@ function viteManifestPlugin(config) {
241
241
 
242
242
  //#endregion
243
243
  //#region src/experimental-index.ts
244
+ /**
245
+ * In-memory file system for browser builds.
246
+ *
247
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
248
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
249
+ *
250
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
251
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
252
+ *
253
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * import { memfs } from 'rolldown/experimental';
258
+ *
259
+ * // Write files to virtual filesystem before bundling
260
+ * memfs?.volume.fromJSON({
261
+ * '/src/index.js': 'export const foo = 42;',
262
+ * '/package.json': '{"name": "my-app"}'
263
+ * });
264
+ *
265
+ * // Read files from the virtual filesystem
266
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
267
+ * ```
268
+ *
269
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
270
+ */
244
271
  const memfs = void 0;
245
272
 
246
273
  //#endregion
@@ -54,7 +54,7 @@ export class DevRuntime {
54
54
  /** @internal */
55
55
  __toCommonJS: any;
56
56
  /** @internal */
57
- __export: any;
57
+ __exportAll: any;
58
58
  /** @internal */
59
59
  __toDynamicImportESM: any;
60
60
  /** @internal */
@@ -1,3 +1,3 @@
1
- import { k as withFilter } from "./shared/define-config-Bwwa5Tc_.mjs";
2
- import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
3
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
1
+ import { k as withFilter } from "./shared/define-config-Bho_aQn8.mjs";
2
+ export * from "@rolldown/pluginutils/filter";
3
+ export { withFilter };
@@ -1,6 +1,127 @@
1
1
  import { n as isPromiseLike, t as arraify } from "./shared/misc-BubmxcE3.mjs";
2
- import { a as include, c as or, i as id, l as queries, n as code, o as moduleType, r as exclude, s as not, t as and, u as query } from "./shared/composable-filters-G1eqjHFo.mjs";
2
+ import { a as id, c as interpreter, d as not, f as or, 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-C5qA4jo-.mjs";
3
3
 
4
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.js
5
+ /**
6
+ * Filters out Vite plugins that have `apply: 'serve'` set.
7
+ *
8
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
9
+ * are intended only for Vite's dev server and should be excluded from the build process.
10
+ *
11
+ * @param plugins - Array of plugins (can include nested arrays)
12
+ * @returns Filtered array with serve-only plugins removed
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { defineConfig } from 'rolldown';
17
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
18
+ * import viteReact from '@vitejs/plugin-react';
19
+ *
20
+ * export default defineConfig({
21
+ * plugins: filterVitePlugins([
22
+ * viteReact(),
23
+ * {
24
+ * name: 'dev-only',
25
+ * apply: 'serve', // This will be filtered out
26
+ * // ...
27
+ * }
28
+ * ])
29
+ * });
30
+ * ```
31
+ */
32
+ function filterVitePlugins(plugins) {
33
+ if (!plugins) return [];
34
+ const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
35
+ const result = [];
36
+ for (const plugin of pluginArray) {
37
+ if (!plugin) continue;
38
+ if (Array.isArray(plugin)) {
39
+ result.push(...filterVitePlugins(plugin));
40
+ continue;
41
+ }
42
+ const pluginWithApply = plugin;
43
+ if ("apply" in pluginWithApply) {
44
+ const applyValue = pluginWithApply.apply;
45
+ if (typeof applyValue === "function") try {
46
+ if (applyValue({}, {
47
+ command: "build",
48
+ mode: "production"
49
+ })) result.push(plugin);
50
+ } catch {
51
+ result.push(plugin);
52
+ }
53
+ else if (applyValue === "serve") continue;
54
+ else result.push(plugin);
55
+ } else result.push(plugin);
56
+ }
57
+ return result;
58
+ }
59
+
60
+ //#endregion
61
+ //#region ../pluginutils/dist/filter/simple-filters.js
62
+ /**
63
+ * Constructs a RegExp that matches the exact string specified.
64
+ *
65
+ * This is useful for plugin hook filters.
66
+ *
67
+ * @param str the string to match.
68
+ * @param flags flags for the RegExp.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { exactRegex } from '@rolldown/pluginutils';
73
+ * const plugin = {
74
+ * name: 'plugin',
75
+ * resolveId: {
76
+ * filter: { id: exactRegex('foo') },
77
+ * handler(id) {} // will only be called for `foo`
78
+ * }
79
+ * }
80
+ * ```
81
+ */
82
+ function exactRegex(str, flags) {
83
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
84
+ }
85
+ /**
86
+ * Constructs a RegExp that matches a value that has the specified prefix.
87
+ *
88
+ * This is useful for plugin hook filters.
89
+ *
90
+ * @param str the string to match.
91
+ * @param flags flags for the RegExp.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { prefixRegex } from '@rolldown/pluginutils';
96
+ * const plugin = {
97
+ * name: 'plugin',
98
+ * resolveId: {
99
+ * filter: { id: prefixRegex('foo') },
100
+ * handler(id) {} // will only be called for IDs starting with `foo`
101
+ * }
102
+ * }
103
+ * ```
104
+ */
105
+ function prefixRegex(str, flags) {
106
+ return new RegExp(`^${escapeRegex(str)}`, flags);
107
+ }
108
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
109
+ function escapeRegex(str) {
110
+ return str.replace(escapeRegexRE, "\\$&");
111
+ }
112
+ function makeIdFiltersToMatchWithQuery(input) {
113
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
114
+ return input.map((i) => makeIdFilterToMatchWithQuery(i));
115
+ }
116
+ function makeIdFilterToMatchWithQuery(input) {
117
+ if (typeof input === "string") return `${input}{?*,}`;
118
+ return makeRegexIdFilterToMatchWithQuery(input);
119
+ }
120
+ function makeRegexIdFilterToMatchWithQuery(input) {
121
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
122
+ }
123
+
124
+ //#endregion
4
125
  //#region src/plugin/with-filter.ts
5
126
  function withFilterImpl(pluginOption, filterObjectList) {
6
127
  if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
@@ -41,4 +162,4 @@ function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
41
162
  }
42
163
 
43
164
  //#endregion
44
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
165
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
@@ -1,5 +1,5 @@
1
- import { E as arraify, P as logMultiplyNotifyOption, w as LOG_LEVEL_WARN, y as VERSION } from "./normalize-string-or-regex-dwgRHUz6.js";
2
- import { c as validateOption, l as PluginDriver, n as createBundlerOptions, r as aggregateBindingErrorsIntoJsError, t as RolldownBuild } from "./rolldown-build-7uuCodq1.js";
1
+ import { E as arraify, P as logMultiplyNotifyOption, w as LOG_LEVEL_WARN, y as VERSION } from "./normalize-string-or-regex-DewaIpuo.js";
2
+ import { c as validateOption, l as PluginDriver, n as createBundlerOptions, r as aggregateBindingErrorsIntoJsError, t as RolldownBuild } from "./rolldown-build-32P3iU2U.js";
3
3
  import { BindingMagicString, BindingWatcher, shutdownAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
4
4
 
5
5
  //#region src/api/rolldown/index.ts
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-BpAvp7KV.mjs";
2
- import { V as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-r9j8jqRV.mjs";
3
- import { $ as InternalModuleFormat, A as VERSION, B as GetModuleInfo, C as ResolveIdResult, Ct as RenderedModule, D as SourceDescription, Dt as ModuleInfo, E as RolldownPluginOption, F as TreeshakingOptions, G as PluginContextMeta, H as DefineParallelPluginResult, I as TransformPluginContext, J as ModuleTypeFilter, K as GeneralHookFilter, L as EmittedAsset, M as SourceMapInput, N as RolldownOptionsFunction, O as TransformResult, Ot as SourcemapIgnoreListOption, P as OutputBundle, Q as RolldownFsModule, R as EmittedFile, S as ResolveIdExtraOptions, St as RenderedChunk, T as RolldownPlugin, Tt as SourceMap, V as PluginContext, W as MinimalPluginContext, X as RolldownDirectoryEntry, Y as BufferEncoding, Z as RolldownFileStats, _ as ModuleType, _t as ModuleFormat, a as InputOption, at as WatchOptions, b as PartialResolvedId, bt as OutputAsset, c as OptimizationOptions, ct as BuildOptions, d as CustomPluginOptions, dt as ChunkFileNamesFunction, et as NormalizedOutputOptions, f as FunctionPluginHooks, ft as ChunkingContext, g as ModuleOptions, gt as MinifyOptions, h as LoadResult, ht as GlobalsFunction, i as ExternalOption, it as RolldownWatcherEvent, j as ExistingRawSourceMap, l as WatcherOptions, lt as build, m as ImportKind, mt as GeneratedCodePreset, n as ConfigExport, nt as watch, o as InputOptions, ot as rolldown, p as HookFilterExtension, pt as GeneratedCodeOptions, q as HookFilter, r as RolldownOptions, rt as RolldownWatcher, s as ModuleTypes, st as RolldownBuild, t as defineConfig, tt as NormalizedInputOptions, u as AsyncPluginHooks, ut as AddonFunction, v as ObjectHook, vt as OutputOptions, w as ResolvedId, wt as RolldownOutput, x as Plugin, xt as OutputChunk, y as ParallelPluginHooks, yt as PreRenderedAsset, z as EmittedPrebuiltChunk } from "./shared/define-config-Bwwa5Tc_.mjs";
4
- import { i as WarningHandlerWithDefault, l as PartialNull, n as LoggingFunction } from "./shared/utils-CMDrspre.mjs";
2
+ import { V as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-CDyF6W3D.mjs";
3
+ import { $ as InternalModuleFormat, A as VERSION, B as GetModuleInfo, C as ResolveIdResult, Ct as RenderedModule, D as SourceDescription, Dt as ModuleInfo, E as RolldownPluginOption, F as TreeshakingOptions, G as PluginContextMeta, H as DefineParallelPluginResult, I as TransformPluginContext, J as ModuleTypeFilter, K as GeneralHookFilter, L as EmittedAsset, M as SourceMapInput, N as RolldownOptionsFunction, O as TransformResult, Ot as SourcemapIgnoreListOption, P as OutputBundle, Q as RolldownFsModule, R as EmittedFile, S as ResolveIdExtraOptions, St as RenderedChunk, T as RolldownPlugin, Tt as SourceMap, V as PluginContext, W as MinimalPluginContext, X as RolldownDirectoryEntry, Y as BufferEncoding, Z as RolldownFileStats, _ as ModuleType, _t as ModuleFormat, a as InputOption, at as WatchOptions, b as PartialResolvedId, bt as OutputAsset, c as OptimizationOptions, ct as BuildOptions, d as CustomPluginOptions, dt as ChunkFileNamesFunction, et as NormalizedOutputOptions, f as FunctionPluginHooks, ft as ChunkingContext, g as ModuleOptions, gt as MinifyOptions, h as LoadResult, ht as GlobalsFunction, i as ExternalOption, it as RolldownWatcherEvent, j as ExistingRawSourceMap, l as WatcherOptions, lt as build, m as ImportKind, mt as GeneratedCodePreset, n as ConfigExport, nt as watch, o as InputOptions, ot as rolldown, p as HookFilterExtension, pt as GeneratedCodeOptions, q as HookFilter, r as RolldownOptions, rt as RolldownWatcher, s as ModuleTypes, st as RolldownBuild, t as defineConfig, tt as NormalizedInputOptions, u as AsyncPluginHooks, ut as AddonFunction, v as ObjectHook, vt as OutputOptions, w as ResolvedId, wt as RolldownOutput, x as Plugin, xt as OutputChunk, y as ParallelPluginHooks, yt as PreRenderedAsset, z as EmittedPrebuiltChunk } from "./shared/define-config-Bho_aQn8.mjs";
4
+ import { i as WarningHandlerWithDefault, l as PartialNull, n as LoggingFunction } from "./shared/utils-B3dcnHc8.mjs";
5
5
  export { AddonFunction, AsyncPluginHooks, BindingMagicString, BufferEncoding, BuildOptions, ChunkFileNamesFunction, ChunkingContext, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, EmittedPrebuiltChunk, ExistingRawSourceMap, ExternalOption, 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, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { n as onExit, t as watch } from "./shared/watch-DDjo8C9u.mjs";
2
- import { y as VERSION } from "./shared/normalize-string-or-regex-FzNsMab1.mjs";
3
- import "./shared/rolldown-build-D8oOi181.mjs";
4
- import "./shared/bindingify-input-options-nvXYfbt3.mjs";
5
- import "./shared/parse-ast-index-BZ4FJxMm.mjs";
6
- import { t as rolldown } from "./shared/rolldown-CTRsCETA.mjs";
1
+ import { n as onExit, t as watch } from "./shared/watch-CbHTfwHk.mjs";
2
+ import { y as VERSION } from "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
3
+ import "./shared/rolldown-build-rs9zb03O.mjs";
4
+ import "./shared/bindingify-input-options-CwdDrVAR.mjs";
5
+ import "./shared/parse-ast-index-DZPue_kI.mjs";
6
+ import { t as rolldown } from "./shared/rolldown-D1ymUD73.mjs";
7
7
  import { t as defineConfig } from "./shared/define-config-BF4P-Pum.mjs";
8
8
  import { isMainThread } from "node:worker_threads";
9
9
  import { BindingMagicString, initTraceSubscriber } from "./rolldown-binding.wasi.cjs";
@@ -102,10 +102,12 @@ function locate(source, search, options) {
102
102
  //#endregion
103
103
  //#region src/log/logs.ts
104
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) {
105
+ function logParseError(message, id, pos) {
106
106
  return {
107
107
  code: PARSE_ERROR,
108
- message
108
+ id,
109
+ message,
110
+ pos
109
111
  };
110
112
  }
111
113
  function logInvalidLogPosition(pluginName) {
@@ -234,7 +236,7 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
234
236
 
235
237
  //#endregion
236
238
  //#region package.json
237
- var version = "1.0.0-beta.55";
239
+ var version = "1.0.0-beta.57";
238
240
 
239
241
  //#endregion
240
242
  //#region src/version.ts
@@ -1,6 +1,6 @@
1
- import "./shared/normalize-string-or-regex-FzNsMab1.mjs";
2
- import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-nvXYfbt3.mjs";
3
- import "./shared/parse-ast-index-BZ4FJxMm.mjs";
1
+ import "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
2
+ import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-CwdDrVAR.mjs";
3
+ import "./shared/parse-ast-index-DZPue_kI.mjs";
4
4
  import { parentPort, workerData } from "node:worker_threads";
5
5
  import { registerPlugins } from "./rolldown-binding.wasi.cjs";
6
6
 
@@ -1,5 +1,5 @@
1
- import { x as Plugin } from "./shared/define-config-Bwwa5Tc_.mjs";
2
- import { s as MaybePromise } from "./shared/utils-CMDrspre.mjs";
1
+ import { x as Plugin } from "./shared/define-config-Bho_aQn8.mjs";
2
+ import { s as MaybePromise } from "./shared/utils-B3dcnHc8.mjs";
3
3
 
4
4
  //#region src/plugin/parallel-plugin-implementation.d.ts
5
5
  type ParallelPluginImplementation = Plugin;
@@ -1,4 +1,4 @@
1
- import { B as ParserOptions, z as ParseResult } from "./shared/binding-r9j8jqRV.mjs";
1
+ import { B as ParserOptions, z as ParseResult } from "./shared/binding-CDyF6W3D.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
 
4
4
  //#region src/parse-ast-index.d.ts
@@ -1,3 +1,3 @@
1
- import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-BZ4FJxMm.mjs";
1
+ import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-DZPue_kI.mjs";
2
2
 
3
3
  export { parseAst, parseAstAsync };
@@ -1,5 +1,5 @@
1
- import { n as BuiltinPlugin, s as makeBuiltinPluginCallable } from "./normalize-string-or-regex-dwgRHUz6.js";
2
- import { t as esmExternalRequirePlugin } from "./constructors-DoEj0CTZ.js";
1
+ import { n as BuiltinPlugin, s as makeBuiltinPluginCallable } from "./normalize-string-or-regex-DewaIpuo.js";
2
+ import { t as esmExternalRequirePlugin } from "./constructors-hZ5LHCkF.js";
3
3
 
4
4
  //#region src/builtin-plugin/replace-plugin.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
- import { u as BindingReplacePluginConfig } from "./shared/binding-r9j8jqRV.mjs";
2
- import { t as BuiltinPlugin } from "./shared/utils-CMDrspre.mjs";
3
- import { t as esmExternalRequirePlugin } from "./shared/constructors-G-fr57ib.mjs";
1
+ import { u as BindingReplacePluginConfig } from "./shared/binding-CDyF6W3D.mjs";
2
+ import { t as BuiltinPlugin } from "./shared/utils-B3dcnHc8.mjs";
3
+ import { t as esmExternalRequirePlugin } from "./shared/constructors-B0L_9ar3.mjs";
4
4
 
5
5
  //#region src/builtin-plugin/replace-plugin.d.ts
6
6
 
@@ -1,5 +1,5 @@
1
- import { n as BuiltinPlugin, s as makeBuiltinPluginCallable } from "./shared/normalize-string-or-regex-FzNsMab1.mjs";
2
- import { t as esmExternalRequirePlugin } from "./shared/constructors-oU7W7sz4.mjs";
1
+ import { n as BuiltinPlugin, s as makeBuiltinPluginCallable } from "./shared/normalize-string-or-regex-Dt2VqAqy.mjs";
2
+ import { t as esmExternalRequirePlugin } from "./shared/constructors-Ch7pGFBC.mjs";
3
3
 
4
4
  //#region src/builtin-plugin/replace-plugin.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as augmentCodeLocation, C as LOG_LEVEL_INFO, D as unimplemented, E as arraify, F as logNoFileSystemInBrowser, I as logParseError, L as logPluginError, M as logCycleLoading, N as logInputHookInOutputPlugin, O as unreachable, R as locate, S as LOG_LEVEL_ERROR, T as logLevelPriority, _ as PlainObjectLike, a as bindingifyManifestPlugin, b as normalizeLog, c as collectChangedBundle, d as bindingifySourcemap$1, f as transformRenderedChunk, g as lazyProp, h as transformAssetSource, i as bindingifyCSSPostPlugin, j as error, k as unsupported, l as transformToOutputBundle, m as bindingAssetSource, n as BuiltinPlugin, o as bindingifyViteHtmlPlugin, p as __decorate, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput, v as MinimalPluginContextImpl, w as LOG_LEVEL_WARN, x as LOG_LEVEL_DEBUG, y as VERSION, z as getCodeFrame } from "./normalize-string-or-regex-dwgRHUz6.js";
1
+ import { A as augmentCodeLocation, C as LOG_LEVEL_INFO, D as unimplemented, E as arraify, F as logNoFileSystemInBrowser, I as logParseError, L as logPluginError, M as logCycleLoading, N as logInputHookInOutputPlugin, O as unreachable, R as locate, S as LOG_LEVEL_ERROR, T as logLevelPriority, _ as PlainObjectLike, a as bindingifyManifestPlugin, b as normalizeLog, c as collectChangedBundle, d as bindingifySourcemap$1, f as transformRenderedChunk, g as lazyProp, h as transformAssetSource, i as bindingifyCSSPostPlugin, j as error, k as unsupported, l as transformToOutputBundle, m as bindingAssetSource, n as BuiltinPlugin, o as bindingifyViteHtmlPlugin, p as __decorate, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput, v as MinimalPluginContextImpl, w as LOG_LEVEL_WARN, x as LOG_LEVEL_DEBUG, y as VERSION, z as getCodeFrame } from "./normalize-string-or-regex-DewaIpuo.js";
2
2
  import { BindingAttachDebugInfo, BindingBundler, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, parse, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
3
3
 
4
4
  //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
@@ -1974,13 +1974,14 @@ const ChecksOptionsSchema = strictObject({
1974
1974
  eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
1975
1975
  missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
1976
1976
  missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
1977
- mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
1977
+ mixedExports: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed exports")),
1978
1978
  unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
1979
1979
  unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
1980
1980
  filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
1981
1981
  commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
1982
1982
  importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
1983
1983
  emptyImportMeta: pipe(optional(boolean()), description("Whether to emit warning when detecting empty import meta")),
1984
+ cannotCallNamespace: pipe(optional(boolean()), description("Whether to emit warning when detecting cannot call namespace")),
1984
1985
  configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict")),
1985
1986
  preferBuiltinFeature: pipe(optional(boolean()), description("Whether to emit warning when detecting prefer builtin feature")),
1986
1987
  couldNotCleanDirectory: pipe(optional(boolean()), description("Whether to emit warning when detecting could not clean directory")),
@@ -2064,10 +2065,10 @@ const OnLogSchema = pipe(vFunction(), args(tuple([
2064
2065
  ])));
2065
2066
  const OnwarnSchema = pipe(vFunction(), args(tuple([RollupLogSchema, pipe(vFunction(), args(tuple([union([RollupLogWithStringSchema, pipe(vFunction(), returns(RollupLogWithStringSchema))])])))])));
2066
2067
  const DevModeSchema = union([boolean(), strictObject({
2067
- new: optional(boolean()),
2068
2068
  port: optional(number()),
2069
2069
  host: optional(string()),
2070
- implement: optional(string())
2070
+ implement: optional(string()),
2071
+ lazy: optional(boolean())
2071
2072
  })]);
2072
2073
  const InputOptionsSchema = strictObject({
2073
2074
  input: optional(InputOptionSchema),
@@ -2405,12 +2406,13 @@ function parseSync$1(filename, sourceText, options) {
2405
2406
 
2406
2407
  //#endregion
2407
2408
  //#region src/parse-ast-index.ts
2408
- function wrap(result, sourceText) {
2409
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
2409
+ function wrap(result, filename, sourceText) {
2410
+ if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
2410
2411
  return result.program;
2411
2412
  }
2412
- function normalizeParseError(sourceText, errors) {
2413
+ function normalizeParseError(filename, sourceText, errors) {
2413
2414
  let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
2415
+ const pos = errors[0]?.labels?.[0]?.start;
2414
2416
  for (let i = 0; i < errors.length; i++) {
2415
2417
  if (i >= 5) {
2416
2418
  message += "\n...";
@@ -2423,7 +2425,9 @@ function normalizeParseError(sourceText, errors) {
2423
2425
  return getCodeFrame(sourceText, location.line, location.column);
2424
2426
  }).filter(Boolean).join("\n");
2425
2427
  }
2426
- return error(logParseError(message));
2428
+ const log = logParseError(message, filename, pos);
2429
+ if (pos !== void 0 && filename) augmentCodeLocation(log, pos, sourceText, filename);
2430
+ return error(log);
2427
2431
  }
2428
2432
  const defaultParserOptions = {
2429
2433
  lang: "js",
@@ -2433,7 +2437,7 @@ function parseAst(sourceText, options, filename) {
2433
2437
  return wrap(parseSync$1(filename ?? "file.js", sourceText, {
2434
2438
  ...defaultParserOptions,
2435
2439
  ...options
2436
- }), sourceText);
2440
+ }), filename, sourceText);
2437
2441
  }
2438
2442
 
2439
2443
  //#endregion
@@ -2543,7 +2547,7 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2543
2547
  }
2544
2548
 
2545
2549
  //#endregion
2546
- //#region ../pluginutils/dist/composable-filters.js
2550
+ //#region ../pluginutils/dist/filter/composable-filters.js
2547
2551
  var And = class {
2548
2552
  kind;
2549
2553
  args;
@@ -2703,6 +2707,20 @@ function bindingifyFilterExpr(expr) {
2703
2707
  bindingifyFilterExprImpl(expr, list);
2704
2708
  return list;
2705
2709
  }
2710
+ function containsImporterId(expr) {
2711
+ switch (expr.kind) {
2712
+ case "and":
2713
+ case "or": return expr.args.some(containsImporterId);
2714
+ case "not":
2715
+ case "include":
2716
+ case "exclude": return containsImporterId(expr.expr);
2717
+ case "importerId": return true;
2718
+ default: return false;
2719
+ }
2720
+ }
2721
+ function assertNoImporterId(filterExprs, hookName) {
2722
+ if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
2723
+ }
2706
2724
  function bindingifyFilterExprImpl(expr, list) {
2707
2725
  switch (expr.kind) {
2708
2726
  case "and": {
@@ -2734,6 +2752,13 @@ function bindingifyFilterExprImpl(expr, list) {
2734
2752
  });
2735
2753
  if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
2736
2754
  break;
2755
+ case "importerId":
2756
+ list.push({
2757
+ kind: "ImporterId",
2758
+ payload: expr.pattern
2759
+ });
2760
+ if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
2761
+ break;
2737
2762
  case "moduleType":
2738
2763
  list.push({
2739
2764
  kind: "ModuleType",
@@ -2774,19 +2799,26 @@ function bindingifyResolveIdFilter(filterOption) {
2774
2799
  }
2775
2800
  function bindingifyLoadFilter(filterOption) {
2776
2801
  if (!filterOption) return;
2777
- if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
2802
+ if (Array.isArray(filterOption)) {
2803
+ assertNoImporterId(filterOption, "load");
2804
+ return { value: filterOption.map(bindingifyFilterExpr) };
2805
+ }
2778
2806
  return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
2779
2807
  }
2780
2808
  function bindingifyTransformFilter(filterOption) {
2781
2809
  if (!filterOption) return;
2782
2810
  let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
2811
+ assertNoImporterId(filterExprs, "transform");
2783
2812
  let ret = [];
2784
2813
  if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
2785
2814
  return { value: ret.length > 0 ? ret : void 0 };
2786
2815
  }
2787
2816
  function bindingifyRenderChunkFilter(filterOption) {
2788
2817
  if (!filterOption) return;
2789
- if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
2818
+ if (Array.isArray(filterOption)) {
2819
+ assertNoImporterId(filterOption, "renderChunk");
2820
+ return { value: filterOption.map(bindingifyFilterExpr) };
2821
+ }
2790
2822
  return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
2791
2823
  }
2792
2824