@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731
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/LICENSE +41 -0
- package/dist/pluginutils/filter/composable-filters.d.ts +90 -0
- package/dist/pluginutils/filter/composable-filters.js +256 -0
- package/dist/pluginutils/filter/filter-vite-plugins.d.ts +28 -0
- package/dist/pluginutils/filter/filter-vite-plugins.js +75 -0
- package/dist/pluginutils/filter/index.d.ts +3 -0
- package/dist/pluginutils/filter/index.js +3 -0
- package/dist/pluginutils/filter/simple-filters.d.ts +71 -0
- package/dist/pluginutils/filter/simple-filters.js +70 -0
- package/dist/pluginutils/index.d.ts +1 -0
- package/dist/pluginutils/index.js +1 -0
- package/dist/pluginutils/utils.d.ts +2 -0
- package/dist/pluginutils/utils.js +17 -0
- package/dist/rolldown/cli-setup.d.mts +1 -0
- package/dist/rolldown/cli-setup.mjs +17 -0
- package/dist/rolldown/cli.d.mts +1 -0
- package/dist/rolldown/cli.mjs +608 -0
- package/dist/rolldown/config.d.mts +7 -0
- package/dist/rolldown/config.mjs +10 -0
- package/dist/rolldown/experimental-index.d.mts +194 -0
- package/dist/rolldown/experimental-index.mjs +291 -0
- package/dist/rolldown/experimental-runtime-types.d.ts +98 -0
- package/dist/rolldown/filter-index.d.mts +197 -0
- package/dist/rolldown/filter-index.mjs +369 -0
- package/dist/rolldown/get-log-filter.d.mts +7 -0
- package/dist/rolldown/get-log-filter.mjs +47 -0
- package/dist/rolldown/index.d.mts +4 -0
- package/dist/rolldown/index.mjs +57 -0
- package/dist/rolldown/parallel-plugin-worker.d.mts +1 -0
- package/dist/rolldown/parallel-plugin-worker.mjs +32 -0
- package/dist/rolldown/parallel-plugin.d.mts +14 -0
- package/dist/rolldown/parallel-plugin.mjs +7 -0
- package/dist/rolldown/parse-ast-index.d.mts +8 -0
- package/dist/rolldown/parse-ast-index.mjs +47 -0
- package/dist/rolldown/plugins-index.d.mts +30 -0
- package/dist/rolldown/plugins-index.mjs +40 -0
- package/dist/rolldown/shared/binding-D-XMzSaG.d.mts +1665 -0
- package/dist/rolldown/shared/binding-DuOSzYPt.mjs +587 -0
- package/dist/rolldown/shared/bindingify-input-options-Bu6nUTgS.mjs +2257 -0
- package/dist/rolldown/shared/constructors-DZVRHTli.mjs +61 -0
- package/dist/rolldown/shared/constructors-KD7LvxpN.d.mts +28 -0
- package/dist/rolldown/shared/define-config-BVG4QvnP.mjs +7 -0
- package/dist/rolldown/shared/define-config-U4pj0ZDn.d.mts +3616 -0
- package/dist/rolldown/shared/load-config-O1K_tT_z.mjs +114 -0
- package/dist/rolldown/shared/logging-CE90D8JR.d.mts +50 -0
- package/dist/rolldown/shared/logs-NH298mHo.mjs +183 -0
- package/dist/rolldown/shared/misc-CCZIsXVO.mjs +22 -0
- package/dist/rolldown/shared/normalize-string-or-regex-DeZqg15i.mjs +61 -0
- package/dist/rolldown/shared/parse-DLraxqjd.mjs +56 -0
- package/dist/rolldown/shared/prompt-DeISmFRp.mjs +847 -0
- package/dist/rolldown/shared/rolldown-O0UKbTKf.mjs +42 -0
- package/dist/rolldown/shared/rolldown-build-BIs7C4B_.mjs +3354 -0
- package/dist/rolldown/shared/watch-DQXGaDjx.mjs +379 -0
- package/dist/tsdown/build-l5WhXg4M-BBPqZr0m.js +4933 -0
- package/dist/tsdown/chunk-CdeBBKNj.js +44 -0
- package/dist/tsdown/debug-Cb_Nqpo4-BueIRvg1.js +18 -0
- package/dist/tsdown/detect-CCATtVj7-B86m8IqW.js +165 -0
- package/dist/tsdown/dist-BUOkzr_P.js +201 -0
- package/dist/tsdown/dist-BVMGwPdF.js +32363 -0
- package/dist/tsdown/dist-dc0X0G6b.js +742 -0
- package/dist/tsdown/filename-7rlgePeo.js +31 -0
- package/dist/tsdown/index-node-BjDys8jy--sqPE5mM.js +251 -0
- package/dist/tsdown/index-types.d.ts +2163 -0
- package/dist/tsdown/index.js +14 -0
- package/dist/tsdown/main-d9yZSQqW.js +926 -0
- package/dist/tsdown/node-Cb5OsnKg.js +271 -0
- package/dist/tsdown/npm_cjs_chunk_chunk.cjs +11 -0
- package/dist/tsdown/npm_cjs_chunk_range.cjs +484 -0
- package/dist/tsdown/npm_cjs_chunk_semver.cjs +362 -0
- package/dist/tsdown/npm_entry_picomatch.cjs +1676 -0
- package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +52 -0
- package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +23 -0
- package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +48 -0
- package/dist/tsdown/npm_entry_tree-kill.cjs +103 -0
- package/dist/tsdown/resolver-j7HY1N36-CIu_7LX6.js +20 -0
- package/dist/tsdown/run.js +537 -0
- package/dist/tsdown/tsc-context-BNYuT3cE.js +25 -0
- package/dist/tsdown/tsc-reo6aLWc.js +423 -0
- package/dist/vite/client/client.mjs +1140 -0
- package/dist/vite/client/env.mjs +19 -0
- package/dist/vite/client.d.ts +279 -0
- package/dist/vite/misc/false.d.ts +2 -0
- package/dist/vite/misc/false.js +1 -0
- package/dist/vite/misc/true.d.ts +2 -0
- package/dist/vite/misc/true.js +1 -0
- package/dist/vite/node/chunks/build2.js +5538 -0
- package/dist/vite/node/chunks/chunk.js +45 -0
- package/dist/vite/node/chunks/dist.js +6758 -0
- package/dist/vite/node/chunks/dist2.js +6651 -0
- package/dist/vite/node/chunks/fetchableEnvironments.js +41395 -0
- package/dist/vite/node/chunks/lib.js +377 -0
- package/dist/vite/node/chunks/logger.js +332 -0
- package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/dist/vite/node/chunks/postcss-import.js +479 -0
- package/dist/vite/node/cli.js +699 -0
- package/dist/vite/node/index.d.ts +3807 -0
- package/dist/vite/node/index.js +15 -0
- package/dist/vite/node/internal.d.ts +2 -0
- package/dist/vite/node/internal.js +3 -0
- package/dist/vite/node/module-runner.d.ts +311 -0
- package/dist/vite/node/module-runner.js +1159 -0
- package/dist/vite/types/customEvent.d.ts +52 -0
- package/dist/vite/types/hmrPayload.d.ts +80 -0
- package/dist/vite/types/hot.d.ts +39 -0
- package/dist/vite/types/import-meta.d.ts +5 -0
- package/dist/vite/types/importGlob.d.ts +89 -0
- package/dist/vite/types/importMeta.d.ts +30 -0
- package/dist/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/dist/vite/types/internal/esbuildOptions.d.ts +28 -0
- package/dist/vite/types/internal/lightningcssOptions.d.ts +18 -0
- package/dist/vite/types/internal/rollupTypeCompat.d.ts +24 -0
- package/dist/vite/types/internal/terserOptions.d.ts +11 -0
- package/dist/vite/types/metadata.d.ts +47 -0
- package/package.json +204 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
“Business Source License” is a trademark of MariaDB Corporation Ab.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Licensor: VoidZero Inc.
|
|
10
|
+
|
|
11
|
+
Licensed Work: The Licensed Work is (c) 2025 VoidZero Inc.
|
|
12
|
+
|
|
13
|
+
Additional Use Grant: TBA
|
|
14
|
+
|
|
15
|
+
Change Date: Four years from the date the Licensed Work is published
|
|
16
|
+
|
|
17
|
+
Change License: TBA
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Business Source License 1.1
|
|
22
|
+
|
|
23
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
24
|
+
|
|
25
|
+
Terms
|
|
26
|
+
|
|
27
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
|
28
|
+
|
|
29
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
|
30
|
+
|
|
31
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
|
32
|
+
|
|
33
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
|
34
|
+
|
|
35
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
|
36
|
+
|
|
37
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
|
38
|
+
|
|
39
|
+
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).
|
|
40
|
+
|
|
41
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
type StringOrRegExp = string | RegExp;
|
|
2
|
+
type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
|
|
3
|
+
export type FilterExpressionKind = FilterExpression['kind'];
|
|
4
|
+
export type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType | Code | Query;
|
|
5
|
+
export type TopLevelFilterExpression = Include | Exclude;
|
|
6
|
+
declare class And {
|
|
7
|
+
kind: 'and';
|
|
8
|
+
args: FilterExpression[];
|
|
9
|
+
constructor(...args: FilterExpression[]);
|
|
10
|
+
}
|
|
11
|
+
declare class Or {
|
|
12
|
+
kind: 'or';
|
|
13
|
+
args: FilterExpression[];
|
|
14
|
+
constructor(...args: FilterExpression[]);
|
|
15
|
+
}
|
|
16
|
+
declare class Not {
|
|
17
|
+
kind: 'not';
|
|
18
|
+
expr: FilterExpression;
|
|
19
|
+
constructor(expr: FilterExpression);
|
|
20
|
+
}
|
|
21
|
+
export interface QueryFilterObject {
|
|
22
|
+
[key: string]: StringOrRegExp | boolean;
|
|
23
|
+
}
|
|
24
|
+
interface IdParams {
|
|
25
|
+
cleanUrl?: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare class Id {
|
|
28
|
+
kind: 'id';
|
|
29
|
+
pattern: StringOrRegExp;
|
|
30
|
+
params: IdParams;
|
|
31
|
+
constructor(pattern: StringOrRegExp, params?: IdParams);
|
|
32
|
+
}
|
|
33
|
+
declare class ImporterId {
|
|
34
|
+
kind: 'importerId';
|
|
35
|
+
pattern: StringOrRegExp;
|
|
36
|
+
params: IdParams;
|
|
37
|
+
constructor(pattern: StringOrRegExp, params?: IdParams);
|
|
38
|
+
}
|
|
39
|
+
declare class ModuleType {
|
|
40
|
+
kind: 'moduleType';
|
|
41
|
+
pattern: PluginModuleType;
|
|
42
|
+
constructor(pattern: PluginModuleType);
|
|
43
|
+
}
|
|
44
|
+
declare class Code {
|
|
45
|
+
kind: 'code';
|
|
46
|
+
pattern: StringOrRegExp;
|
|
47
|
+
constructor(expr: StringOrRegExp);
|
|
48
|
+
}
|
|
49
|
+
declare class Query {
|
|
50
|
+
kind: 'query';
|
|
51
|
+
key: string;
|
|
52
|
+
pattern: StringOrRegExp | boolean;
|
|
53
|
+
constructor(key: string, pattern: StringOrRegExp | boolean);
|
|
54
|
+
}
|
|
55
|
+
declare class Include {
|
|
56
|
+
kind: 'include';
|
|
57
|
+
expr: FilterExpression;
|
|
58
|
+
constructor(expr: FilterExpression);
|
|
59
|
+
}
|
|
60
|
+
declare class Exclude {
|
|
61
|
+
kind: 'exclude';
|
|
62
|
+
expr: FilterExpression;
|
|
63
|
+
constructor(expr: FilterExpression);
|
|
64
|
+
}
|
|
65
|
+
export declare function and(...args: FilterExpression[]): And;
|
|
66
|
+
export declare function or(...args: FilterExpression[]): Or;
|
|
67
|
+
export declare function not(expr: FilterExpression): Not;
|
|
68
|
+
export declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
|
|
69
|
+
export declare function importerId(pattern: StringOrRegExp, params?: IdParams): ImporterId;
|
|
70
|
+
export declare function moduleType(pattern: PluginModuleType): ModuleType;
|
|
71
|
+
export declare function code(pattern: StringOrRegExp): Code;
|
|
72
|
+
export declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
|
|
73
|
+
export declare function include(expr: FilterExpression): Include;
|
|
74
|
+
export declare function exclude(expr: FilterExpression): Exclude;
|
|
75
|
+
/**
|
|
76
|
+
* convert a queryObject to FilterExpression like
|
|
77
|
+
* ```js
|
|
78
|
+
* and(query(k1, v1), query(k2, v2))
|
|
79
|
+
* ```
|
|
80
|
+
* @param queryFilterObject The query filter object needs to be matched.
|
|
81
|
+
* @returns a `And` FilterExpression
|
|
82
|
+
*/
|
|
83
|
+
export declare function queries(queryFilter: QueryFilterObject): And;
|
|
84
|
+
export declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string): boolean;
|
|
85
|
+
interface InterpreterCtx {
|
|
86
|
+
urlSearchParamsCache?: URLSearchParams;
|
|
87
|
+
}
|
|
88
|
+
export declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
|
|
89
|
+
export declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { cleanUrl, extractQueryWithoutFragment } from "../utils.js";
|
|
2
|
+
class And {
|
|
3
|
+
kind;
|
|
4
|
+
args;
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
if (args.length === 0) {
|
|
7
|
+
throw new Error('`And` expects at least one operand');
|
|
8
|
+
}
|
|
9
|
+
this.args = args;
|
|
10
|
+
this.kind = 'and';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class Or {
|
|
14
|
+
kind;
|
|
15
|
+
args;
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
if (args.length === 0) {
|
|
18
|
+
throw new Error('`Or` expects at least one operand');
|
|
19
|
+
}
|
|
20
|
+
this.args = args;
|
|
21
|
+
this.kind = 'or';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class Not {
|
|
25
|
+
kind;
|
|
26
|
+
expr;
|
|
27
|
+
constructor(expr) {
|
|
28
|
+
this.expr = expr;
|
|
29
|
+
this.kind = 'not';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class Id {
|
|
33
|
+
kind;
|
|
34
|
+
pattern;
|
|
35
|
+
params;
|
|
36
|
+
constructor(pattern, params) {
|
|
37
|
+
this.pattern = pattern;
|
|
38
|
+
this.kind = 'id';
|
|
39
|
+
this.params = params ?? {
|
|
40
|
+
cleanUrl: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class ImporterId {
|
|
45
|
+
kind;
|
|
46
|
+
pattern;
|
|
47
|
+
params;
|
|
48
|
+
constructor(pattern, params) {
|
|
49
|
+
this.pattern = pattern;
|
|
50
|
+
this.kind = 'importerId';
|
|
51
|
+
this.params = params ?? {
|
|
52
|
+
cleanUrl: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class ModuleType {
|
|
57
|
+
kind;
|
|
58
|
+
pattern;
|
|
59
|
+
constructor(pattern) {
|
|
60
|
+
this.pattern = pattern;
|
|
61
|
+
this.kind = 'moduleType';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class Code {
|
|
65
|
+
kind;
|
|
66
|
+
pattern;
|
|
67
|
+
constructor(expr) {
|
|
68
|
+
this.pattern = expr;
|
|
69
|
+
this.kind = 'code';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class Query {
|
|
73
|
+
kind;
|
|
74
|
+
key;
|
|
75
|
+
pattern;
|
|
76
|
+
constructor(key, pattern) {
|
|
77
|
+
this.pattern = pattern;
|
|
78
|
+
this.key = key;
|
|
79
|
+
this.kind = 'query';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class Include {
|
|
83
|
+
kind;
|
|
84
|
+
expr;
|
|
85
|
+
constructor(expr) {
|
|
86
|
+
this.expr = expr;
|
|
87
|
+
this.kind = 'include';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class Exclude {
|
|
91
|
+
kind;
|
|
92
|
+
expr;
|
|
93
|
+
constructor(expr) {
|
|
94
|
+
this.expr = expr;
|
|
95
|
+
this.kind = 'exclude';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function and(...args) {
|
|
99
|
+
return new And(...args);
|
|
100
|
+
}
|
|
101
|
+
export function or(...args) {
|
|
102
|
+
return new Or(...args);
|
|
103
|
+
}
|
|
104
|
+
export function not(expr) {
|
|
105
|
+
return new Not(expr);
|
|
106
|
+
}
|
|
107
|
+
export function id(pattern, params) {
|
|
108
|
+
return new Id(pattern, params);
|
|
109
|
+
}
|
|
110
|
+
export function importerId(pattern, params) {
|
|
111
|
+
return new ImporterId(pattern, params);
|
|
112
|
+
}
|
|
113
|
+
export function moduleType(pattern) {
|
|
114
|
+
return new ModuleType(pattern);
|
|
115
|
+
}
|
|
116
|
+
export function code(pattern) {
|
|
117
|
+
return new Code(pattern);
|
|
118
|
+
}
|
|
119
|
+
/*
|
|
120
|
+
* There are three kinds of conditions are supported:
|
|
121
|
+
* 1. `boolean`: if the value is `true`, the key must exist and be truthy. if the value is `false`, the key must not exist or be falsy.
|
|
122
|
+
* 2. `string`: the key must exist and be equal to the value.
|
|
123
|
+
* 3. `RegExp`: the key must exist and match the value.
|
|
124
|
+
*/
|
|
125
|
+
export function query(key, pattern) {
|
|
126
|
+
return new Query(key, pattern);
|
|
127
|
+
}
|
|
128
|
+
export function include(expr) {
|
|
129
|
+
return new Include(expr);
|
|
130
|
+
}
|
|
131
|
+
export function exclude(expr) {
|
|
132
|
+
return new Exclude(expr);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* convert a queryObject to FilterExpression like
|
|
136
|
+
* ```js
|
|
137
|
+
* and(query(k1, v1), query(k2, v2))
|
|
138
|
+
* ```
|
|
139
|
+
* @param queryFilterObject The query filter object needs to be matched.
|
|
140
|
+
* @returns a `And` FilterExpression
|
|
141
|
+
*/
|
|
142
|
+
export function queries(queryFilter) {
|
|
143
|
+
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
|
144
|
+
return new Query(key, value);
|
|
145
|
+
});
|
|
146
|
+
return and(...arr);
|
|
147
|
+
}
|
|
148
|
+
export function interpreter(exprs, code, id, moduleType, importerId) {
|
|
149
|
+
let arr = [];
|
|
150
|
+
if (Array.isArray(exprs)) {
|
|
151
|
+
arr = exprs;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
arr = [exprs];
|
|
155
|
+
}
|
|
156
|
+
return interpreterImpl(arr, code, id, moduleType, importerId);
|
|
157
|
+
}
|
|
158
|
+
export function interpreterImpl(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
159
|
+
let hasInclude = false;
|
|
160
|
+
for (const e of expr) {
|
|
161
|
+
switch (e.kind) {
|
|
162
|
+
case 'include': {
|
|
163
|
+
hasInclude = true;
|
|
164
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 'exclude': {
|
|
170
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return !hasInclude;
|
|
178
|
+
}
|
|
179
|
+
export function exprInterpreter(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
180
|
+
switch (expr.kind) {
|
|
181
|
+
case 'and': {
|
|
182
|
+
return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
183
|
+
}
|
|
184
|
+
case 'or': {
|
|
185
|
+
return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
186
|
+
}
|
|
187
|
+
case 'not': {
|
|
188
|
+
return !exprInterpreter(expr.expr, code, id, moduleType, importerId, ctx);
|
|
189
|
+
}
|
|
190
|
+
case 'id': {
|
|
191
|
+
if (id === undefined) {
|
|
192
|
+
throw new Error('`id` is required for `id` expression');
|
|
193
|
+
}
|
|
194
|
+
let idToMatch = id;
|
|
195
|
+
if (expr.params.cleanUrl) {
|
|
196
|
+
idToMatch = cleanUrl(idToMatch);
|
|
197
|
+
}
|
|
198
|
+
return typeof expr.pattern === 'string'
|
|
199
|
+
? idToMatch === expr.pattern
|
|
200
|
+
: expr.pattern.test(idToMatch);
|
|
201
|
+
}
|
|
202
|
+
case 'importerId': {
|
|
203
|
+
if (importerId === undefined) {
|
|
204
|
+
return false; // Entry files have no importer, so no match
|
|
205
|
+
}
|
|
206
|
+
let importerIdToMatch = importerId;
|
|
207
|
+
if (expr.params.cleanUrl) {
|
|
208
|
+
importerIdToMatch = cleanUrl(importerIdToMatch);
|
|
209
|
+
}
|
|
210
|
+
return typeof expr.pattern === 'string'
|
|
211
|
+
? importerIdToMatch === expr.pattern
|
|
212
|
+
: expr.pattern.test(importerIdToMatch);
|
|
213
|
+
}
|
|
214
|
+
case 'moduleType': {
|
|
215
|
+
if (moduleType === undefined) {
|
|
216
|
+
throw new Error('`moduleType` is required for `moduleType` expression');
|
|
217
|
+
}
|
|
218
|
+
return moduleType === expr.pattern;
|
|
219
|
+
}
|
|
220
|
+
case 'code': {
|
|
221
|
+
if (code === undefined) {
|
|
222
|
+
throw new Error('`code` is required for `code` expression');
|
|
223
|
+
}
|
|
224
|
+
return typeof expr.pattern === 'string'
|
|
225
|
+
? code.includes(expr.pattern)
|
|
226
|
+
: expr.pattern.test(code);
|
|
227
|
+
}
|
|
228
|
+
case 'query': {
|
|
229
|
+
if (id === undefined) {
|
|
230
|
+
throw new Error('`id` is required for `Query` expression');
|
|
231
|
+
}
|
|
232
|
+
if (!ctx.urlSearchParamsCache) {
|
|
233
|
+
let queryString = extractQueryWithoutFragment(id);
|
|
234
|
+
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
|
235
|
+
}
|
|
236
|
+
let urlParams = ctx.urlSearchParamsCache;
|
|
237
|
+
if (typeof expr.pattern === 'boolean') {
|
|
238
|
+
if (expr.pattern) {
|
|
239
|
+
return urlParams.has(expr.key);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
return !urlParams.has(expr.key);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else if (typeof expr.pattern === 'string') {
|
|
246
|
+
return urlParams.get(expr.key) === expr.pattern;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return expr.pattern.test(urlParams.get(expr.key) ?? '');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
default: {
|
|
253
|
+
throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out Vite plugins that have `apply: 'serve'` set.
|
|
3
|
+
*
|
|
4
|
+
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
|
5
|
+
* are intended only for Vite's dev server and should be excluded from the build process.
|
|
6
|
+
*
|
|
7
|
+
* @param plugins - Array of plugins (can include nested arrays)
|
|
8
|
+
* @returns Filtered array with serve-only plugins removed
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineConfig } from 'rolldown';
|
|
13
|
+
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
|
14
|
+
* import viteReact from '@vitejs/plugin-react';
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* plugins: filterVitePlugins([
|
|
18
|
+
* viteReact(),
|
|
19
|
+
* {
|
|
20
|
+
* name: 'dev-only',
|
|
21
|
+
* apply: 'serve', // This will be filtered out
|
|
22
|
+
* // ...
|
|
23
|
+
* }
|
|
24
|
+
* ])
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out Vite plugins that have `apply: 'serve'` set.
|
|
3
|
+
*
|
|
4
|
+
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
|
5
|
+
* are intended only for Vite's dev server and should be excluded from the build process.
|
|
6
|
+
*
|
|
7
|
+
* @param plugins - Array of plugins (can include nested arrays)
|
|
8
|
+
* @returns Filtered array with serve-only plugins removed
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineConfig } from 'rolldown';
|
|
13
|
+
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
|
14
|
+
* import viteReact from '@vitejs/plugin-react';
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* plugins: filterVitePlugins([
|
|
18
|
+
* viteReact(),
|
|
19
|
+
* {
|
|
20
|
+
* name: 'dev-only',
|
|
21
|
+
* apply: 'serve', // This will be filtered out
|
|
22
|
+
* // ...
|
|
23
|
+
* }
|
|
24
|
+
* ])
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function filterVitePlugins(plugins) {
|
|
29
|
+
if (!plugins) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const plugin of pluginArray) {
|
|
35
|
+
// Skip falsy values
|
|
36
|
+
if (!plugin) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Handle nested arrays recursively
|
|
40
|
+
if (Array.isArray(plugin)) {
|
|
41
|
+
result.push(...filterVitePlugins(plugin));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// Check if plugin has apply property
|
|
45
|
+
const pluginWithApply = plugin;
|
|
46
|
+
if ('apply' in pluginWithApply) {
|
|
47
|
+
const applyValue = pluginWithApply.apply;
|
|
48
|
+
// If apply is a function, call it with build mode
|
|
49
|
+
if (typeof applyValue === 'function') {
|
|
50
|
+
try {
|
|
51
|
+
const shouldApply = applyValue({}, // config object
|
|
52
|
+
{ command: 'build', mode: 'production' });
|
|
53
|
+
if (shouldApply) {
|
|
54
|
+
result.push(plugin);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// If function throws, include the plugin to be safe
|
|
59
|
+
result.push(plugin);
|
|
60
|
+
}
|
|
61
|
+
} // If apply is 'serve', skip this plugin
|
|
62
|
+
else if (applyValue === 'serve') {
|
|
63
|
+
continue;
|
|
64
|
+
} // If apply is 'build' or anything else, include it
|
|
65
|
+
else {
|
|
66
|
+
result.push(plugin);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// No apply property, include the plugin
|
|
71
|
+
result.push(plugin);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a RegExp that matches the exact string specified.
|
|
3
|
+
*
|
|
4
|
+
* This is useful for plugin hook filters.
|
|
5
|
+
*
|
|
6
|
+
* @param str the string to match.
|
|
7
|
+
* @param flags flags for the RegExp.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { exactRegex } from '@rolldown/pluginutils';
|
|
12
|
+
* const plugin = {
|
|
13
|
+
* name: 'plugin',
|
|
14
|
+
* resolveId: {
|
|
15
|
+
* filter: { id: exactRegex('foo') },
|
|
16
|
+
* handler(id) {} // will only be called for `foo`
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function exactRegex(str: string, flags?: string): RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a RegExp that matches a value that has the specified prefix.
|
|
24
|
+
*
|
|
25
|
+
* This is useful for plugin hook filters.
|
|
26
|
+
*
|
|
27
|
+
* @param str the string to match.
|
|
28
|
+
* @param flags flags for the RegExp.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
33
|
+
* const plugin = {
|
|
34
|
+
* name: 'plugin',
|
|
35
|
+
* resolveId: {
|
|
36
|
+
* filter: { id: prefixRegex('foo') },
|
|
37
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function prefixRegex(str: string, flags?: string): RegExp;
|
|
43
|
+
type WidenString<T> = T extends string ? string : T;
|
|
44
|
+
/**
|
|
45
|
+
* Converts a id filter to match with an id with a query.
|
|
46
|
+
*
|
|
47
|
+
* @param input the id filters to convert.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
|
|
52
|
+
* const plugin = {
|
|
53
|
+
* name: 'plugin',
|
|
54
|
+
* transform: {
|
|
55
|
+
* filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
|
|
56
|
+
* // The handler will be called for IDs like:
|
|
57
|
+
* // - foo.js
|
|
58
|
+
* // - foo.js?foo
|
|
59
|
+
* // - foo.txt?foo.js
|
|
60
|
+
* // - foo.ts
|
|
61
|
+
* // - foo.ts?foo
|
|
62
|
+
* // - foo.txt?foo.ts
|
|
63
|
+
* handler(code, id) {}
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
|
|
69
|
+
export declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
|
|
70
|
+
export declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a RegExp that matches the exact string specified.
|
|
3
|
+
*
|
|
4
|
+
* This is useful for plugin hook filters.
|
|
5
|
+
*
|
|
6
|
+
* @param str the string to match.
|
|
7
|
+
* @param flags flags for the RegExp.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { exactRegex } from '@rolldown/pluginutils';
|
|
12
|
+
* const plugin = {
|
|
13
|
+
* name: 'plugin',
|
|
14
|
+
* resolveId: {
|
|
15
|
+
* filter: { id: exactRegex('foo') },
|
|
16
|
+
* handler(id) {} // will only be called for `foo`
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function exactRegex(str, flags) {
|
|
22
|
+
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a RegExp that matches a value that has the specified prefix.
|
|
26
|
+
*
|
|
27
|
+
* This is useful for plugin hook filters.
|
|
28
|
+
*
|
|
29
|
+
* @param str the string to match.
|
|
30
|
+
* @param flags flags for the RegExp.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
35
|
+
* const plugin = {
|
|
36
|
+
* name: 'plugin',
|
|
37
|
+
* resolveId: {
|
|
38
|
+
* filter: { id: prefixRegex('foo') },
|
|
39
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function prefixRegex(str, flags) {
|
|
45
|
+
return new RegExp(`^${escapeRegex(str)}`, flags);
|
|
46
|
+
}
|
|
47
|
+
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
|
48
|
+
function escapeRegex(str) {
|
|
49
|
+
return str.replace(escapeRegexRE, '\\$&');
|
|
50
|
+
}
|
|
51
|
+
export function makeIdFiltersToMatchWithQuery(input) {
|
|
52
|
+
if (!Array.isArray(input)) {
|
|
53
|
+
return makeIdFilterToMatchWithQuery(
|
|
54
|
+
// Array.isArray cannot narrow the type
|
|
55
|
+
// https://github.com/microsoft/TypeScript/issues/17002
|
|
56
|
+
input);
|
|
57
|
+
}
|
|
58
|
+
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
|
59
|
+
}
|
|
60
|
+
function makeIdFilterToMatchWithQuery(input) {
|
|
61
|
+
if (typeof input === 'string') {
|
|
62
|
+
return `${input}{?*,}`;
|
|
63
|
+
}
|
|
64
|
+
return makeRegexIdFilterToMatchWithQuery(input);
|
|
65
|
+
}
|
|
66
|
+
function makeRegexIdFilterToMatchWithQuery(input) {
|
|
67
|
+
return new RegExp(
|
|
68
|
+
// replace `$` with `(?:\?.*)?$` (ignore `\$`)
|
|
69
|
+
input.source.replace(/(?<!\\)\$/g, '(?:\\?.*)?$'), input.flags);
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './filter/index.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./filter/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const postfixRE = /[?#].*$/;
|
|
2
|
+
export function cleanUrl(url) {
|
|
3
|
+
return url.replace(postfixRE, '');
|
|
4
|
+
}
|
|
5
|
+
export function extractQueryWithoutFragment(url) {
|
|
6
|
+
const questionMarkIndex = url.indexOf('?');
|
|
7
|
+
if (questionMarkIndex === -1) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const fragmentIndex = url.indexOf('#', questionMarkIndex); // Search for # after ?
|
|
11
|
+
if (fragmentIndex === -1) {
|
|
12
|
+
return url.substring(questionMarkIndex);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return url.substring(questionMarkIndex, fragmentIndex);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./shared/binding-DuOSzYPt.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/setup-index.ts
|
|
4
|
+
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
5
|
+
let isWatchMode = false;
|
|
6
|
+
for (let i = 0; i < process.argv.length; i++) {
|
|
7
|
+
const arg = process.argv[i];
|
|
8
|
+
if (arg === "--watch" || arg === "-w") {
|
|
9
|
+
isWatchMode = true;
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (isWatchMode) (0, import_binding.createTokioRuntime)(32);
|
|
14
|
+
else (0, import_binding.createTokioRuntime)(4);
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { };
|