@voidzero-dev/vite-plus-core 0.1.22 → 0.1.24

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 (94) hide show
  1. package/LICENSE +37 -26
  2. package/dist/pluginutils/filter/index.d.mts +194 -0
  3. package/dist/pluginutils/filter/index.mjs +2 -0
  4. package/dist/pluginutils/filter-B_mD-HGz.mjs +323 -0
  5. package/dist/pluginutils/index.d.mts +2 -0
  6. package/dist/pluginutils/index.mjs +2 -0
  7. package/dist/rolldown/cli.mjs +7 -7
  8. package/dist/rolldown/config.d.mts +1 -1
  9. package/dist/rolldown/config.mjs +3 -3
  10. package/dist/rolldown/experimental-index.d.mts +21 -4
  11. package/dist/rolldown/experimental-index.mjs +14 -9
  12. package/dist/rolldown/filter-index.d.mts +8 -9
  13. package/dist/rolldown/filter-index.mjs +2 -8
  14. package/dist/rolldown/get-log-filter.d.mts +3 -3
  15. package/dist/rolldown/index.d.mts +4 -4
  16. package/dist/rolldown/index.mjs +5 -5
  17. package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
  18. package/dist/rolldown/parallel-plugin.d.mts +1 -1
  19. package/dist/rolldown/parse-ast-index.d.mts +1 -1
  20. package/dist/rolldown/parse-ast-index.mjs +2 -2
  21. package/dist/rolldown/plugins-index.d.mts +3 -3
  22. package/dist/rolldown/plugins-index.mjs +2 -2
  23. package/dist/rolldown/shared/{binding-zH1vcmbM.d.mts → binding-BaCZTfMx.d.mts} +32 -3
  24. package/dist/rolldown/shared/{binding-ESkOU1xr.mjs → binding-CXquf8ay.mjs} +27 -26
  25. package/dist/rolldown/shared/{bindingify-input-options-wZdDRbfo.mjs → bindingify-input-options-D2ORek5s.mjs} +14 -14
  26. package/dist/rolldown/shared/{constructors-D6i2Tbyl.mjs → constructors-BiPdtLBB.mjs} +1 -1
  27. package/dist/rolldown/shared/{constructors-D0W3rNfA.d.mts → constructors-CbNaT434.d.mts} +2 -2
  28. package/dist/rolldown/shared/{define-config-5HJ1b9vG.d.mts → define-config-3BX_X2Am.d.mts} +70 -16
  29. package/dist/rolldown/shared/{error-BrnLyQ-g.mjs → error-BuvQYXuZ.mjs} +1 -1
  30. package/dist/rolldown/shared/{get-log-filter-semyr3Lj.d.mts → get-log-filter-BpNVNJ5-.d.mts} +1 -1
  31. package/dist/rolldown/shared/{load-config-BZFgt8GH.mjs → load-config-uvbpmLwO.mjs} +1 -1
  32. package/dist/rolldown/shared/{normalize-string-or-regex-dAjLOSbp.mjs → normalize-string-or-regex-CNPF6PU9.mjs} +2 -2
  33. package/dist/rolldown/shared/{parse-DFts7Hyl.mjs → parse-1VOPJ1Lj.mjs} +2 -2
  34. package/dist/rolldown/shared/{prompt-Bm9aMQjm.mjs → prompt-DV1XbtjC.mjs} +1 -1
  35. package/dist/rolldown/shared/{resolve-tsconfig-DCdBlPeK.mjs → resolve-tsconfig-CcfxWrib.mjs} +15 -4
  36. package/dist/rolldown/shared/{rolldown-Cs2eRf4R.mjs → rolldown-BZYLlfsv.mjs} +1 -1
  37. package/dist/rolldown/shared/{rolldown-build-CNhzgsn2.mjs → rolldown-build-CgMNHFY3.mjs} +54 -65
  38. package/dist/rolldown/shared/{transform-DgZ3paSD.d.mts → transform-7xCUVrpL.d.mts} +2 -2
  39. package/dist/rolldown/shared/{watch-De_8Tgeq.mjs → watch-BX_aH1Oh.mjs} +6 -6
  40. package/dist/rolldown/utils-index.d.mts +3 -3
  41. package/dist/rolldown/utils-index.mjs +5 -5
  42. package/dist/tsdown/{build-5FURNVr0-D2dbyiC6.js → build-BZshaq8i-C7uS6x65.js} +1173 -93
  43. package/dist/tsdown/{detect-DN3DXXYt-8gmDjZqp.js → detect-B97OSl92-CgjrIbmD.js} +1 -1
  44. package/dist/tsdown/{dist-DTzJRoOQ.js → dist-BHLOKn-2.js} +526 -224
  45. package/dist/tsdown/index-types.d.ts +30 -12
  46. package/dist/tsdown/index.js +3 -4
  47. package/dist/tsdown/main-nVIFtu2j.js +938 -0
  48. package/dist/tsdown/npm_cjs_chunk_range.cjs +11 -11
  49. package/dist/tsdown/npm_cjs_chunk_semver.cjs +6 -6
  50. package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +2 -2
  51. package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +1 -1
  52. package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +1 -1
  53. package/dist/tsdown/{resolver-DkvdaW3s-BeVUoOo-.js → resolver-DtsKFXi2-QB-x8j3e.js} +1 -1
  54. package/dist/tsdown/run.js +5 -6
  55. package/dist/tsdown/{tsc-Dr9kCkDm.js → tsc-WMktM0FW.js} +3 -3
  56. package/dist/tsdown/{tsc-context-CANQEB9U.js → tsc-context-DKufFI_s.js} +2 -2
  57. package/dist/vite/client/client.mjs +61 -27
  58. package/dist/vite/node/chunks/build.js +21 -21
  59. package/dist/vite/node/chunks/dist.js +1 -1
  60. package/dist/vite/node/chunks/dist2.js +136 -110
  61. package/dist/vite/node/chunks/lib.js +1 -1
  62. package/dist/vite/node/chunks/logger.js +36 -3
  63. package/dist/vite/node/chunks/node.js +490 -277
  64. package/dist/vite/node/chunks/postcss-import.js +11 -11
  65. package/dist/vite/node/cli.js +1 -2
  66. package/dist/vite/node/index.d.ts +29 -14
  67. package/dist/vite/node/module-runner.d.ts +1 -2
  68. package/dist/vite/node/module-runner.js +19 -18
  69. package/dist/vite/types/customEvent.d.ts +1 -1
  70. package/package.json +17 -23
  71. package/dist/pluginutils/filter/composable-filters.d.ts +0 -90
  72. package/dist/pluginutils/filter/composable-filters.js +0 -256
  73. package/dist/pluginutils/filter/filter-vite-plugins.d.ts +0 -28
  74. package/dist/pluginutils/filter/filter-vite-plugins.js +0 -75
  75. package/dist/pluginutils/filter/index.d.ts +0 -3
  76. package/dist/pluginutils/filter/index.js +0 -3
  77. package/dist/pluginutils/filter/simple-filters.d.ts +0 -71
  78. package/dist/pluginutils/filter/simple-filters.js +0 -70
  79. package/dist/pluginutils/index.d.ts +0 -1
  80. package/dist/pluginutils/index.js +0 -1
  81. package/dist/pluginutils/utils.d.ts +0 -2
  82. package/dist/pluginutils/utils.js +0 -17
  83. package/dist/tsdown/chunk-N93fKeF6.js +0 -34
  84. package/dist/tsdown/debug-CLlnG64L-BkAqwHVS.js +0 -16
  85. package/dist/tsdown/dist-Cv2Z0Bi_.js +0 -1012
  86. package/dist/tsdown/filename-DQnUJlio-D7-CzKqs.js +0 -29
  87. package/dist/tsdown/main-BNUO6D3N.js +0 -893
  88. package/dist/tsdown/node-B3Gdtau1.js +0 -268
  89. package/dist/vite/node/chunks/chunk.js +0 -35
  90. /package/dist/rolldown/shared/{define-config-DJOr6Iwt.mjs → define-config-Demdg3_4.mjs} +0 -0
  91. /package/dist/rolldown/shared/{logging-C6h4g8dA.d.mts → logging-BSNejiLS.d.mts} +0 -0
  92. /package/dist/rolldown/shared/{logs-D80CXhvg.mjs → logs-aMKUxRpj.mjs} +0 -0
  93. /package/dist/rolldown/shared/{misc-DJYbNKZX.mjs → misc-CoQm4NHO.mjs} +0 -0
  94. /package/dist/tsdown/{dist-JaOach5K.js → dist-CZtGyfn3.js} +0 -0
package/LICENSE CHANGED
@@ -152,13 +152,13 @@ Repository: https://github.com/lukeed/polka
152
152
 
153
153
  ---------------------------------------
154
154
 
155
- ## @rolldown/pluginutils, rolldown
155
+ ## @rolldown/pluginutils
156
156
  License: MIT
157
- Repositories: https://github.com/rolldown/rolldown, https://github.com/rolldown/rolldown
157
+ Repository: https://github.com/rolldown/plugins
158
158
 
159
159
  > MIT License
160
160
  >
161
- > Copyright (c) 2024-present VoidZero Inc. & Contributors
161
+ > Copyright (c) 2026-present, rolldown/plugins repository contributors
162
162
  >
163
163
  > Permission is hereby granted, free of charge, to any person obtaining a copy
164
164
  > of this software and associated documentation files (the "Software"), to deal
@@ -177,10 +177,6 @@ Repositories: https://github.com/rolldown/rolldown, https://github.com/rolldown/
177
177
  > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
178
178
  > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
179
179
  > SOFTWARE.
180
- >
181
- > end of terms and conditions
182
- >
183
- > The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
184
180
 
185
181
  ---------------------------------------
186
182
 
@@ -1516,7 +1512,7 @@ Repository: https://github.com/isaacs/node-which
1516
1512
  ## launch-editor, launch-editor-middleware
1517
1513
  License: MIT
1518
1514
  By: Evan You
1519
- Repositories: https://github.com/yyx990803/launch-editor, https://github.com/yyx990803/launch-editor
1515
+ Repositories: https://github.com/vitejs/launch-editor, https://github.com/vitejs/launch-editor
1520
1516
 
1521
1517
  > The MIT License (MIT)
1522
1518
  >
@@ -2459,6 +2455,38 @@ Repositories: https://github.com/lukeed/resolve.exports, https://github.com/luke
2459
2455
 
2460
2456
  ---------------------------------------
2461
2457
 
2458
+ ## rolldown
2459
+ License: MIT
2460
+ Repository: https://github.com/rolldown/rolldown
2461
+
2462
+ > MIT License
2463
+ >
2464
+ > Copyright (c) 2024-present VoidZero Inc. & Contributors
2465
+ >
2466
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
2467
+ > of this software and associated documentation files (the "Software"), to deal
2468
+ > in the Software without restriction, including without limitation the rights
2469
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2470
+ > copies of the Software, and to permit persons to whom the Software is
2471
+ > furnished to do so, subject to the following conditions:
2472
+ >
2473
+ > The above copyright notice and this permission notice shall be included in all
2474
+ > copies or substantial portions of the Software.
2475
+ >
2476
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2477
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2478
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2479
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2480
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2481
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2482
+ > SOFTWARE.
2483
+ >
2484
+ > end of terms and conditions
2485
+ >
2486
+ > The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
2487
+
2488
+ ---------------------------------------
2489
+
2462
2490
  ## shebang-command
2463
2491
  License: MIT
2464
2492
  By: Kevin Mårtensson
@@ -2870,23 +2898,6 @@ Repository: https://github.com/jaredhanson/utils-merge
2870
2898
 
2871
2899
  ---------------------------------------
2872
2900
 
2873
- ## valibot
2874
- License: MIT
2875
- By: Fabian Hiller
2876
- Repository: https://github.com/open-circle/valibot
2877
-
2878
- > MIT License
2879
- >
2880
- > Copyright (c) Fabian Hiller
2881
- >
2882
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2883
- >
2884
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2885
- >
2886
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2887
-
2888
- ---------------------------------------
2889
-
2890
2901
  ## vary
2891
2902
  License: MIT
2892
2903
  By: Douglas Christopher Wilson <doug@somethingdoug.com>
@@ -4141,7 +4152,7 @@ Repository: https://github.com/vitejs/vite
4141
4152
  > ## launch-editor, launch-editor-middleware
4142
4153
  > License: MIT
4143
4154
  > By: Evan You
4144
- > Repositories: https://github.com/yyx990803/launch-editor, https://github.com/yyx990803/launch-editor
4155
+ > Repositories: https://github.com/vitejs/launch-editor, https://github.com/vitejs/launch-editor
4145
4156
  >
4146
4157
  > > The MIT License (MIT)
4147
4158
  > >
@@ -0,0 +1,194 @@
1
+ //#region src/filter/composable-filters.d.ts
2
+ type StringOrRegExp = string | RegExp;
3
+ type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
4
+ type FilterExpressionKind = FilterExpression['kind'];
5
+ type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType | Code | Query;
6
+ type TopLevelFilterExpression = Include | Exclude;
7
+ declare class And {
8
+ kind: 'and';
9
+ args: FilterExpression[];
10
+ constructor(...args: FilterExpression[]);
11
+ }
12
+ declare class Or {
13
+ kind: 'or';
14
+ args: FilterExpression[];
15
+ constructor(...args: FilterExpression[]);
16
+ }
17
+ declare class Not {
18
+ kind: 'not';
19
+ expr: FilterExpression;
20
+ constructor(expr: FilterExpression);
21
+ }
22
+ interface QueryFilterObject {
23
+ [key: string]: StringOrRegExp | boolean;
24
+ }
25
+ interface IdParams {
26
+ cleanUrl?: boolean;
27
+ }
28
+ declare class Id {
29
+ kind: 'id';
30
+ pattern: StringOrRegExp;
31
+ params: IdParams;
32
+ constructor(pattern: StringOrRegExp, params?: IdParams);
33
+ }
34
+ declare class ImporterId {
35
+ kind: 'importerId';
36
+ pattern: StringOrRegExp;
37
+ params: IdParams;
38
+ constructor(pattern: StringOrRegExp, params?: IdParams);
39
+ }
40
+ declare class ModuleType {
41
+ kind: 'moduleType';
42
+ pattern: PluginModuleType;
43
+ constructor(pattern: PluginModuleType);
44
+ }
45
+ declare class Code {
46
+ kind: 'code';
47
+ pattern: StringOrRegExp;
48
+ constructor(expr: StringOrRegExp);
49
+ }
50
+ declare class Query {
51
+ kind: 'query';
52
+ key: string;
53
+ pattern: StringOrRegExp | boolean;
54
+ constructor(key: string, pattern: StringOrRegExp | boolean);
55
+ }
56
+ declare class Include {
57
+ kind: 'include';
58
+ expr: FilterExpression;
59
+ constructor(expr: FilterExpression);
60
+ }
61
+ declare class Exclude {
62
+ kind: 'exclude';
63
+ expr: FilterExpression;
64
+ constructor(expr: FilterExpression);
65
+ }
66
+ declare function and(...args: FilterExpression[]): And;
67
+ declare function or(...args: FilterExpression[]): Or;
68
+ declare function not(expr: FilterExpression): Not;
69
+ declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
70
+ declare function importerId(pattern: StringOrRegExp, params?: IdParams): ImporterId;
71
+ declare function moduleType(pattern: PluginModuleType): ModuleType;
72
+ declare function code(pattern: StringOrRegExp): Code;
73
+ declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
74
+ declare function include(expr: FilterExpression): Include;
75
+ declare function exclude(expr: FilterExpression): Exclude;
76
+ /**
77
+ * convert a queryObject to FilterExpression like
78
+ * ```js
79
+ * and(query(k1, v1), query(k2, v2))
80
+ * ```
81
+ * @param queryFilterObject The query filter object needs to be matched.
82
+ * @returns a `And` FilterExpression
83
+ */
84
+ declare function queries(queryFilter: QueryFilterObject): And;
85
+ declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string): boolean;
86
+ interface InterpreterCtx {
87
+ urlSearchParamsCache?: URLSearchParams;
88
+ }
89
+ declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
90
+ declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
91
+ //#endregion
92
+ //#region src/filter/filter-vite-plugins.d.ts
93
+ /**
94
+ * Filters out Vite plugins that have `apply: 'serve'` set.
95
+ *
96
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
97
+ * are intended only for Vite's dev server and should be excluded from the build process.
98
+ *
99
+ * @param plugins - Array of plugins (can include nested arrays)
100
+ * @returns Filtered array with serve-only plugins removed
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { defineConfig } from 'rolldown';
105
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
106
+ * import viteReact from '@vitejs/plugin-react';
107
+ *
108
+ * export default defineConfig({
109
+ * plugins: filterVitePlugins([
110
+ * viteReact(),
111
+ * {
112
+ * name: 'dev-only',
113
+ * apply: 'serve', // This will be filtered out
114
+ * // ...
115
+ * }
116
+ * ])
117
+ * });
118
+ * ```
119
+ */
120
+ declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
121
+ //#endregion
122
+ //#region src/filter/simple-filters.d.ts
123
+ /**
124
+ * Constructs a RegExp that matches the exact string specified.
125
+ *
126
+ * This is useful for plugin hook filters.
127
+ *
128
+ * @param str the string to match.
129
+ * @param flags flags for the RegExp.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * import { exactRegex } from '@rolldown/pluginutils';
134
+ * const plugin = {
135
+ * name: 'plugin',
136
+ * resolveId: {
137
+ * filter: { id: exactRegex('foo') },
138
+ * handler(id) {} // will only be called for `foo`
139
+ * }
140
+ * }
141
+ * ```
142
+ */
143
+ declare function exactRegex(str: string, flags?: string): RegExp;
144
+ /**
145
+ * Constructs a RegExp that matches a value that has the specified prefix.
146
+ *
147
+ * This is useful for plugin hook filters.
148
+ *
149
+ * @param str the string to match.
150
+ * @param flags flags for the RegExp.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * import { prefixRegex } from '@rolldown/pluginutils';
155
+ * const plugin = {
156
+ * name: 'plugin',
157
+ * resolveId: {
158
+ * filter: { id: prefixRegex('foo') },
159
+ * handler(id) {} // will only be called for IDs starting with `foo`
160
+ * }
161
+ * }
162
+ * ```
163
+ */
164
+ declare function prefixRegex(str: string, flags?: string): RegExp;
165
+ type WidenString<T> = T extends string ? string : T;
166
+ /**
167
+ * Converts a id filter to match with an id with a query.
168
+ *
169
+ * @param input the id filters to convert.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
174
+ * const plugin = {
175
+ * name: 'plugin',
176
+ * transform: {
177
+ * filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
178
+ * // The handler will be called for IDs like:
179
+ * // - foo.js
180
+ * // - foo.js?foo
181
+ * // - foo.txt?foo.js
182
+ * // - foo.ts
183
+ * // - foo.ts?foo
184
+ * // - foo.txt?foo.ts
185
+ * handler(code, id) {}
186
+ * }
187
+ * }
188
+ * ```
189
+ */
190
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
191
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
192
+ declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
193
+ //#endregion
194
+ export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
@@ -0,0 +1,2 @@
1
+ import { _ as queries, a as and, c as exprInterpreter, d as include, f as interpreter, g as or, h as not, i as filterVitePlugins, l as id, m as moduleType, n as makeIdFiltersToMatchWithQuery, o as code, p as interpreterImpl, r as prefixRegex, s as exclude, t as exactRegex, u as importerId, v as query } from "../filter-B_mD-HGz.mjs";
2
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
@@ -0,0 +1,323 @@
1
+ //#region src/utils.ts
2
+ const postfixRE = /[?#].*$/;
3
+ function cleanUrl(url) {
4
+ return url.replace(postfixRE, "");
5
+ }
6
+ function extractQueryWithoutFragment(url) {
7
+ const questionMarkIndex = url.indexOf("?");
8
+ if (questionMarkIndex === -1) return "";
9
+ const fragmentIndex = url.indexOf("#", questionMarkIndex);
10
+ if (fragmentIndex === -1) return url.substring(questionMarkIndex);
11
+ else return url.substring(questionMarkIndex, fragmentIndex);
12
+ }
13
+ //#endregion
14
+ //#region src/filter/composable-filters.ts
15
+ var And = class {
16
+ kind;
17
+ args;
18
+ constructor(...args) {
19
+ if (args.length === 0) throw new Error("`And` expects at least one operand");
20
+ this.args = args;
21
+ this.kind = "and";
22
+ }
23
+ };
24
+ var Or = class {
25
+ kind;
26
+ args;
27
+ constructor(...args) {
28
+ if (args.length === 0) throw new Error("`Or` expects at least one operand");
29
+ this.args = args;
30
+ this.kind = "or";
31
+ }
32
+ };
33
+ var Not = class {
34
+ kind;
35
+ expr;
36
+ constructor(expr) {
37
+ this.expr = expr;
38
+ this.kind = "not";
39
+ }
40
+ };
41
+ var Id = class {
42
+ kind;
43
+ pattern;
44
+ params;
45
+ constructor(pattern, params) {
46
+ this.pattern = pattern;
47
+ this.kind = "id";
48
+ this.params = params ?? { cleanUrl: false };
49
+ }
50
+ };
51
+ var ImporterId = class {
52
+ kind;
53
+ pattern;
54
+ params;
55
+ constructor(pattern, params) {
56
+ this.pattern = pattern;
57
+ this.kind = "importerId";
58
+ this.params = params ?? { cleanUrl: false };
59
+ }
60
+ };
61
+ var ModuleType = class {
62
+ kind;
63
+ pattern;
64
+ constructor(pattern) {
65
+ this.pattern = pattern;
66
+ this.kind = "moduleType";
67
+ }
68
+ };
69
+ var Code = class {
70
+ kind;
71
+ pattern;
72
+ constructor(expr) {
73
+ this.pattern = expr;
74
+ this.kind = "code";
75
+ }
76
+ };
77
+ var Query = class {
78
+ kind;
79
+ key;
80
+ pattern;
81
+ constructor(key, pattern) {
82
+ this.pattern = pattern;
83
+ this.key = key;
84
+ this.kind = "query";
85
+ }
86
+ };
87
+ var Include = class {
88
+ kind;
89
+ expr;
90
+ constructor(expr) {
91
+ this.expr = expr;
92
+ this.kind = "include";
93
+ }
94
+ };
95
+ var Exclude = class {
96
+ kind;
97
+ expr;
98
+ constructor(expr) {
99
+ this.expr = expr;
100
+ this.kind = "exclude";
101
+ }
102
+ };
103
+ function and(...args) {
104
+ return new And(...args);
105
+ }
106
+ function or(...args) {
107
+ return new Or(...args);
108
+ }
109
+ function not(expr) {
110
+ return new Not(expr);
111
+ }
112
+ function id(pattern, params) {
113
+ return new Id(pattern, params);
114
+ }
115
+ function importerId(pattern, params) {
116
+ return new ImporterId(pattern, params);
117
+ }
118
+ function moduleType(pattern) {
119
+ return new ModuleType(pattern);
120
+ }
121
+ function code(pattern) {
122
+ return new Code(pattern);
123
+ }
124
+ function query(key, pattern) {
125
+ return new Query(key, pattern);
126
+ }
127
+ function include(expr) {
128
+ return new Include(expr);
129
+ }
130
+ function exclude(expr) {
131
+ return new Exclude(expr);
132
+ }
133
+ /**
134
+ * convert a queryObject to FilterExpression like
135
+ * ```js
136
+ * and(query(k1, v1), query(k2, v2))
137
+ * ```
138
+ * @param queryFilterObject The query filter object needs to be matched.
139
+ * @returns a `And` FilterExpression
140
+ */
141
+ function queries(queryFilter) {
142
+ return and(...Object.entries(queryFilter).map(([key, value]) => {
143
+ return new Query(key, value);
144
+ }));
145
+ }
146
+ function interpreter(exprs, code, id, moduleType, importerId) {
147
+ let arr = [];
148
+ if (Array.isArray(exprs)) arr = exprs;
149
+ else arr = [exprs];
150
+ return interpreterImpl(arr, code, id, moduleType, importerId);
151
+ }
152
+ function interpreterImpl(expr, code, id, moduleType, importerId, ctx = {}) {
153
+ let hasInclude = false;
154
+ for (const e of expr) switch (e.kind) {
155
+ case "include":
156
+ hasInclude = true;
157
+ if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return true;
158
+ break;
159
+ case "exclude":
160
+ if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return false;
161
+ break;
162
+ }
163
+ return !hasInclude;
164
+ }
165
+ function exprInterpreter(expr, code, id, moduleType, importerId, ctx = {}) {
166
+ switch (expr.kind) {
167
+ case "and": return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
168
+ case "or": return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
169
+ case "not": return !exprInterpreter(expr.expr, code, id, moduleType, importerId, ctx);
170
+ case "id": {
171
+ if (id === void 0) throw new Error("`id` is required for `id` expression");
172
+ let idToMatch = id;
173
+ if (expr.params.cleanUrl) idToMatch = cleanUrl(idToMatch);
174
+ return typeof expr.pattern === "string" ? idToMatch === expr.pattern : expr.pattern.test(idToMatch);
175
+ }
176
+ case "importerId": {
177
+ if (importerId === void 0) return false;
178
+ let importerIdToMatch = importerId;
179
+ if (expr.params.cleanUrl) importerIdToMatch = cleanUrl(importerIdToMatch);
180
+ return typeof expr.pattern === "string" ? importerIdToMatch === expr.pattern : expr.pattern.test(importerIdToMatch);
181
+ }
182
+ case "moduleType":
183
+ if (moduleType === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
184
+ return moduleType === expr.pattern;
185
+ case "code":
186
+ if (code === void 0) throw new Error("`code` is required for `code` expression");
187
+ return typeof expr.pattern === "string" ? code.includes(expr.pattern) : expr.pattern.test(code);
188
+ case "query": {
189
+ if (id === void 0) throw new Error("`id` is required for `Query` expression");
190
+ if (!ctx.urlSearchParamsCache) {
191
+ let queryString = extractQueryWithoutFragment(id);
192
+ ctx.urlSearchParamsCache = new URLSearchParams(queryString);
193
+ }
194
+ let urlParams = ctx.urlSearchParamsCache;
195
+ if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
196
+ else return !urlParams.has(expr.key);
197
+ else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
198
+ else return expr.pattern.test(urlParams.get(expr.key) ?? "");
199
+ }
200
+ default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
201
+ }
202
+ }
203
+ //#endregion
204
+ //#region src/filter/filter-vite-plugins.ts
205
+ /**
206
+ * Filters out Vite plugins that have `apply: 'serve'` set.
207
+ *
208
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
209
+ * are intended only for Vite's dev server and should be excluded from the build process.
210
+ *
211
+ * @param plugins - Array of plugins (can include nested arrays)
212
+ * @returns Filtered array with serve-only plugins removed
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * import { defineConfig } from 'rolldown';
217
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
218
+ * import viteReact from '@vitejs/plugin-react';
219
+ *
220
+ * export default defineConfig({
221
+ * plugins: filterVitePlugins([
222
+ * viteReact(),
223
+ * {
224
+ * name: 'dev-only',
225
+ * apply: 'serve', // This will be filtered out
226
+ * // ...
227
+ * }
228
+ * ])
229
+ * });
230
+ * ```
231
+ */
232
+ function filterVitePlugins(plugins) {
233
+ if (!plugins) return [];
234
+ const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
235
+ const result = [];
236
+ for (const plugin of pluginArray) {
237
+ if (!plugin) continue;
238
+ if (Array.isArray(plugin)) {
239
+ result.push(...filterVitePlugins(plugin));
240
+ continue;
241
+ }
242
+ const pluginWithApply = plugin;
243
+ if ("apply" in pluginWithApply) {
244
+ const applyValue = pluginWithApply.apply;
245
+ if (typeof applyValue === "function") try {
246
+ if (applyValue({}, {
247
+ command: "build",
248
+ mode: "production"
249
+ })) result.push(plugin);
250
+ } catch {
251
+ result.push(plugin);
252
+ }
253
+ else if (applyValue === "serve") continue;
254
+ else result.push(plugin);
255
+ } else result.push(plugin);
256
+ }
257
+ return result;
258
+ }
259
+ //#endregion
260
+ //#region src/filter/simple-filters.ts
261
+ /**
262
+ * Constructs a RegExp that matches the exact string specified.
263
+ *
264
+ * This is useful for plugin hook filters.
265
+ *
266
+ * @param str the string to match.
267
+ * @param flags flags for the RegExp.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * import { exactRegex } from '@rolldown/pluginutils';
272
+ * const plugin = {
273
+ * name: 'plugin',
274
+ * resolveId: {
275
+ * filter: { id: exactRegex('foo') },
276
+ * handler(id) {} // will only be called for `foo`
277
+ * }
278
+ * }
279
+ * ```
280
+ */
281
+ function exactRegex(str, flags) {
282
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
283
+ }
284
+ /**
285
+ * Constructs a RegExp that matches a value that has the specified prefix.
286
+ *
287
+ * This is useful for plugin hook filters.
288
+ *
289
+ * @param str the string to match.
290
+ * @param flags flags for the RegExp.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * import { prefixRegex } from '@rolldown/pluginutils';
295
+ * const plugin = {
296
+ * name: 'plugin',
297
+ * resolveId: {
298
+ * filter: { id: prefixRegex('foo') },
299
+ * handler(id) {} // will only be called for IDs starting with `foo`
300
+ * }
301
+ * }
302
+ * ```
303
+ */
304
+ function prefixRegex(str, flags) {
305
+ return new RegExp(`^${escapeRegex(str)}`, flags);
306
+ }
307
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
308
+ function escapeRegex(str) {
309
+ return str.replace(escapeRegexRE, "\\$&");
310
+ }
311
+ function makeIdFiltersToMatchWithQuery(input) {
312
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
313
+ return input.map((i) => makeIdFilterToMatchWithQuery(i));
314
+ }
315
+ function makeIdFilterToMatchWithQuery(input) {
316
+ if (typeof input === "string") return `${input}{?*,}`;
317
+ return makeRegexIdFilterToMatchWithQuery(input);
318
+ }
319
+ function makeRegexIdFilterToMatchWithQuery(input) {
320
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
321
+ }
322
+ //#endregion
323
+ export { queries as _, and as a, exprInterpreter as c, include as d, interpreter as f, or as g, not as h, filterVitePlugins as i, id as l, moduleType as m, makeIdFiltersToMatchWithQuery as n, code as o, interpreterImpl as p, prefixRegex as r, exclude as s, exactRegex as t, importerId as u, query as v };
@@ -0,0 +1,2 @@
1
+ import { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query } from "./filter/index.mjs";
2
+ export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
@@ -0,0 +1,2 @@
1
+ import { _ as queries, a as and, c as exprInterpreter, d as include, f as interpreter, g as or, h as not, i as filterVitePlugins, l as id, m as moduleType, n as makeIdFiltersToMatchWithQuery, o as code, p as interpreterImpl, r as prefixRegex, s as exclude, t as exactRegex, u as importerId, v as query } from "./filter-B_mD-HGz.mjs";
2
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
@@ -1,9 +1,9 @@
1
- import { n as onExit, t as watch } from "./shared/watch-De_8Tgeq.mjs";
2
- import { C as version, S as description } from "./shared/bindingify-input-options-wZdDRbfo.mjs";
3
- import { t as arraify } from "./shared/misc-DJYbNKZX.mjs";
4
- import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CNhzgsn2.mjs";
5
- import { t as rolldown } from "./shared/rolldown-Cs2eRf4R.mjs";
6
- import { t as loadConfig } from "./shared/load-config-BZFgt8GH.mjs";
1
+ import { n as onExit, t as watch } from "./shared/watch-BX_aH1Oh.mjs";
2
+ import { C as version, S as description } from "./shared/bindingify-input-options-D2ORek5s.mjs";
3
+ import { t as arraify } from "./shared/misc-CoQm4NHO.mjs";
4
+ import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CgMNHFY3.mjs";
5
+ import { t as rolldown } from "./shared/rolldown-BZYLlfsv.mjs";
6
+ import { t as loadConfig } from "./shared/load-config-uvbpmLwO.mjs";
7
7
  import path from "node:path";
8
8
  import process$1 from "node:process";
9
9
  import { performance } from "node:perf_hooks";
@@ -847,7 +847,7 @@ function getClearScreenFunction(options) {
847
847
  };
848
848
  }
849
849
  //#endregion
850
- //#region \0@oxc-project+runtime@0.129.0/helpers/usingCtx.js
850
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/usingCtx.js
851
851
  function _usingCtx() {
852
852
  var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
853
853
  var n = Error();
@@ -1,4 +1,4 @@
1
- import { F as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-5HJ1b9vG.mjs";
1
+ import { I as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-3BX_X2Am.mjs";
2
2
 
3
3
  //#region src/utils/load-config.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { x as VERSION } from "./shared/bindingify-input-options-wZdDRbfo.mjs";
2
- import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
3
- import { t as loadConfig } from "./shared/load-config-BZFgt8GH.mjs";
1
+ import { x as VERSION } from "./shared/bindingify-input-options-D2ORek5s.mjs";
2
+ import { t as defineConfig } from "./shared/define-config-Demdg3_4.mjs";
3
+ import { t as loadConfig } from "./shared/load-config-uvbpmLwO.mjs";
4
4
  export { VERSION, defineConfig, loadConfig };