@visulima/packem-rollup 1.0.0-alpha.77 → 1.0.0-alpha.78
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/CHANGELOG.md +8 -0
- package/dist/index.d.ts +329 -372
- package/dist/index.js +1 -1
- package/dist/packem_shared/browserslistToEsbuild-DeJ4xoII.js +1 -0
- package/dist/packem_shared/esbuildPlugin-CE9hQxBf.js +1 -0
- package/dist/packem_shared/index-NTDZLUEE.js +1 -0
- package/dist/packem_shared/swcPlugin-C-UrDd9t.js +1 -0
- package/dist/packem_shared/{types.d-KBgVO47q.d.ts → types.d-DxoG2D8r.d.ts} +11 -25
- package/dist/plugins/chunk-splitter/index.js +1 -1
- package/dist/plugins/cjs-interop.d.ts +1 -4
- package/dist/plugins/cjs-interop.js +2 -2
- package/dist/plugins/esbuild/index.d.ts +3 -3
- package/dist/plugins/esbuild/index.js +1 -1
- package/dist/plugins/json.d.ts +1 -1
- package/dist/plugins/json.js +1 -1
- package/dist/plugins/jsx-remove-attributes.d.ts +12 -17
- package/dist/plugins/jsx-remove-attributes.js +1 -1
- package/dist/plugins/preserve-directives.d.ts +1 -6
- package/dist/plugins/preserve-directives.js +4 -4
- package/dist/plugins/pure-new-expression-plugin.d.ts +12 -12
- package/dist/plugins/pure-new-expression-plugin.js +1 -1
- package/dist/plugins/sucrase/index.js +1 -1
- package/dist/plugins/swc/index.d.ts +1 -1
- package/dist/plugins/swc/index.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/browserslistToEsbuild-HD6SaWPt.js +0 -1
- package/dist/packem_shared/esbuildPlugin-D_vSjXWg.js +0 -1
- package/dist/packem_shared/index-Dq8IUFTs.js +0 -1
- package/dist/packem_shared/swcPlugin-BdHPQBN4.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as chunkSplitter } from "./plugins/chunk-splitter/index.js";
|
|
2
|
-
import { c as Options$3 } from "./packem_shared/types.d-
|
|
3
|
-
export { d as browserslistToEsbuild } from "./packem_shared/types.d-
|
|
2
|
+
import { c as Options$3 } from "./packem_shared/types.d-DxoG2D8r.js";
|
|
3
|
+
export { d as browserslistToEsbuild } from "./packem_shared/types.d-DxoG2D8r.js";
|
|
4
4
|
import { JSXRemoveAttributesPlugin } from "./plugins/jsx-remove-attributes.js";
|
|
5
5
|
export { jsxRemoveAttributes } from "./plugins/jsx-remove-attributes.js";
|
|
6
6
|
export { type PreserveDirectivesPluginOptions, preserveDirectivesPlugin } from "./plugins/preserve-directives.js";
|
|
@@ -46,32 +46,33 @@ interface BabelPluginConfig extends Omit<InputOptions, "exclude" | "filename" |
|
|
|
46
46
|
filename?: string;
|
|
47
47
|
include?: FilterPattern;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
* Optional logger used to surface diagnostics — e.g. why parallel mode fell back
|
|
50
|
+
* to in-process transforms (non-serializable option, missing worker script). When
|
|
51
|
+
* omitted, fallbacks happen silently (preserving prior behaviour).
|
|
52
|
+
*/
|
|
53
53
|
logger?: Pick<Console, "debug" | "warn">;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
* Run Babel transforms in parallel across a worker pool.
|
|
56
|
+
* `false` always transforms in-process; `true`/`undefined` auto-enables workers
|
|
57
|
+
* once the build crosses `parallelThreshold` matched files (so small builds never
|
|
58
|
+
* pay the worker startup cost); a number caps the worker count (default min(cpus, 4)).
|
|
59
|
+
* Parallel mode requires fully serializable Babel options — when a non-serializable
|
|
60
|
+
* option is present (e.g. a function plugin, or a `babel` config supplied as a
|
|
61
|
+
* function) the plugin silently falls back to in-process transforms.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
64
|
parallel?: boolean | number;
|
|
65
65
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
* Minimum number of matched files before the worker pool is created.
|
|
67
|
+
* @default 20
|
|
68
|
+
*/
|
|
69
69
|
parallelThreshold?: number;
|
|
70
70
|
sourceFileName?: string;
|
|
71
71
|
}
|
|
72
72
|
type OXCTransformPluginConfig = Omit<TransformOptions, "cwd" | "sourcemap" | "target" | "typescript"> & {
|
|
73
73
|
exclude?: FilterPattern;
|
|
74
|
-
include?: FilterPattern;
|
|
74
|
+
include?: FilterPattern;
|
|
75
|
+
/** Configure how TSX and JSX are transformed. */
|
|
75
76
|
jsx?: Omit<JsxOptions, "refresh"> | "preserve";
|
|
76
77
|
};
|
|
77
78
|
type OXCResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
|
|
@@ -85,76 +86,60 @@ type SingleTargetDesc = {
|
|
|
85
86
|
type MultipleTargetsDesc = SingleTargetDesc | SingleTargetDesc[] | string[] | string;
|
|
86
87
|
type CopyPluginOptions = {
|
|
87
88
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
* Copy items once. Useful in watch mode.
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
91
92
|
copyOnce?: boolean;
|
|
92
93
|
exactFileNames?: boolean;
|
|
93
94
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
* Remove the directory structure of copied files.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
97
98
|
flatten?: boolean;
|
|
98
99
|
targets: MultipleTargetsDesc;
|
|
99
100
|
};
|
|
100
101
|
type DataUriPluginOptions = {
|
|
101
102
|
exclude?: FilterPattern;
|
|
102
|
-
include?: FilterPattern;
|
|
103
|
+
include?: FilterPattern;
|
|
104
|
+
/** Encode spaces for use in srcset attribute */
|
|
103
105
|
srcset?: boolean;
|
|
104
106
|
};
|
|
105
|
-
/**
|
|
106
|
-
* Data URI plugin that converts files to data URIs for inline embedding.
|
|
107
|
-
*
|
|
108
|
-
* Supported query parameters:
|
|
109
|
-
*
|
|
110
|
-
* - `?data-uri` - Basic data URI conversion.
|
|
111
|
-
* - `?data-uri&encoding=css` - Use CSS-optimized SVG encoding.
|
|
112
|
-
* - `?data-uri&encoding=tiny` - Use tiny SVG encoding (default).
|
|
113
|
-
* - `?data-uri&srcset` - Encode spaces as %20 for srcset compatibility.
|
|
114
|
-
*
|
|
115
|
-
* Examples:
|
|
116
|
-
*
|
|
117
|
-
* - `./icon.svg?data-uri` - Tiny SVG encoding.
|
|
118
|
-
* - `./icon.svg?data-uri&encoding=css` - CSS-optimized SVG encoding.
|
|
119
|
-
* - `./icon.svg?data-uri&srcset` - Tiny SVG with srcset compatibility.
|
|
120
|
-
* - `./icon.svg?data-uri&encoding=css&srcset` - CSS encoding with srcset compatibility.
|
|
121
|
-
*/
|
|
122
107
|
interface DebarrelPluginOptions {
|
|
123
108
|
include?: FilterPattern;
|
|
124
109
|
possibleBarrelFiles?: (RegExp | string)[];
|
|
125
110
|
}
|
|
126
111
|
/**
|
|
127
|
-
* Collected duplicated-package information, keyed by package name, then version,
|
|
128
|
-
* then the resolved package directory, with the set of importers as the leaf value.
|
|
129
|
-
*
|
|
130
|
-
* ```plaintext
|
|
131
|
-
* Map {
|
|
132
|
-
* "axios" => Map {
|
|
133
|
-
* "1.4.0" => Map { "[dir]" => Set { "packages/pkg2/index.js" } },
|
|
134
|
-
* "0.27.2" => Map { "[dir]" => Set { "packages/pkg1/index.js" } }
|
|
135
|
-
* }
|
|
136
|
-
* }
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
112
|
+
* Collected duplicated-package information, keyed by package name, then version,
|
|
113
|
+
* then the resolved package directory, with the set of importers as the leaf value.
|
|
114
|
+
*
|
|
115
|
+
* ```plaintext
|
|
116
|
+
* Map {
|
|
117
|
+
* "axios" => Map {
|
|
118
|
+
* "1.4.0" => Map { "[dir]" => Set { "packages/pkg2/index.js" } },
|
|
119
|
+
* "0.27.2" => Map { "[dir]" => Set { "packages/pkg1/index.js" } }
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
139
124
|
type PackagesInfo = Map<string, Map<string, Map<string, Set<string>>>>;
|
|
140
125
|
interface DetectDuplicatedPluginOptions {
|
|
141
126
|
/** Build a custom message from the collected duplicates instead of the default report. */
|
|
142
127
|
customErrorMessage?: (packageToVersionsMap: PackagesInfo) => string;
|
|
143
128
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
* Whether to report duplicated deps that are pulled in transitively by another dep under node_modules.
|
|
130
|
+
* When `false`, only duplicates imported directly by your own source are reported.
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
148
133
|
deep?: boolean;
|
|
149
134
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
135
|
+
* Duplicated dependencies to ignore. Pass `*` as a version to ignore all versions, e.g. `{ axios: ["0.17.4", "1.4.0"] }`.
|
|
136
|
+
* @default {} (ignore nothing)
|
|
137
|
+
*/
|
|
153
138
|
ignore?: Record<string, string[]>;
|
|
154
139
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
140
|
+
* Make the build fail when duplicated deps exist.
|
|
141
|
+
* @default false
|
|
142
|
+
*/
|
|
158
143
|
throwErrorWhenDuplicated?: boolean;
|
|
159
144
|
}
|
|
160
145
|
interface EsmShimCjsSyntaxOptions {
|
|
@@ -163,64 +148,56 @@ interface EsmShimCjsSyntaxOptions {
|
|
|
163
148
|
}
|
|
164
149
|
type MaybeFalsy<T> = T | false | null | undefined;
|
|
165
150
|
/**
|
|
166
|
-
* User-facing configuration for externals classification, mirrored at
|
|
167
|
-
* `packem.config.ts` → `rollup.resolveExternals`.
|
|
168
|
-
*/
|
|
151
|
+
* User-facing configuration for externals classification, mirrored at
|
|
152
|
+
* `packem.config.ts` → `rollup.resolveExternals`.
|
|
153
|
+
*/
|
|
169
154
|
type ResolveExternalsPluginOptions = {
|
|
170
155
|
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
* Mark node built-in modules like `path`, `fs`... as external.
|
|
157
|
+
*
|
|
158
|
+
* Set to `false` to use shims/polyfills instead.
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
176
161
|
builtins?: boolean;
|
|
177
162
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
163
|
+
* `node:` prefix handling for imports of Node builtins:
|
|
164
|
+
* - `'add'` turns `'path'` into `'node:path'`
|
|
165
|
+
* - `'strip'` turns `'node:path'` into `'path'`
|
|
166
|
+
* - `'ignore'` leaves names as written
|
|
167
|
+
* @default "add"
|
|
168
|
+
*/
|
|
184
169
|
builtinsPrefix?: "add" | "ignore" | "strip";
|
|
185
170
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
* Mark `dependencies` as external.
|
|
172
|
+
* @default true
|
|
173
|
+
*/
|
|
189
174
|
deps?: boolean;
|
|
190
175
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
* Mark `devDependencies` as external.
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
194
179
|
devDeps?: boolean;
|
|
195
180
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
* Patterns whose matching specifiers are forced to be bundled,
|
|
182
|
+
* overriding all other rules (deps/peer/built-ins/etc.).
|
|
183
|
+
*
|
|
184
|
+
* Strings are matched as exact specifiers; RegExp values are tested
|
|
185
|
+
* against the import id. Falsy entries are ignored for convenient
|
|
186
|
+
* conditional configuration.
|
|
187
|
+
* @default [] (no specifier is forcibly bundled)
|
|
188
|
+
*/
|
|
204
189
|
exclude?: MaybeFalsy<RegExp | string>[];
|
|
205
190
|
/**
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
* Mark `optionalDependencies` as external.
|
|
192
|
+
* @default true
|
|
193
|
+
*/
|
|
209
194
|
optDeps?: boolean;
|
|
210
195
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
196
|
+
* Mark `peerDependencies` as external.
|
|
197
|
+
* @default true
|
|
198
|
+
*/
|
|
214
199
|
peerDeps?: boolean;
|
|
215
200
|
};
|
|
216
|
-
/**
|
|
217
|
-
* Minimal slice of build options consumed by `externalsPlugin`.
|
|
218
|
-
*
|
|
219
|
-
* The plugin lives in `@visulima/packem-rollup` so it can be reused outside
|
|
220
|
-
* of packem core, so it's parameterized over this shape rather than
|
|
221
|
-
* packem's `InternalBuildOptions`. Any options object that satisfies this
|
|
222
|
-
* structural type is accepted.
|
|
223
|
-
*/
|
|
224
201
|
interface LicenseOptions {
|
|
225
202
|
dependenciesMarker?: string;
|
|
226
203
|
dependenciesTemplate?: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
@@ -229,12 +206,12 @@ interface LicenseOptions {
|
|
|
229
206
|
path?: string;
|
|
230
207
|
}
|
|
231
208
|
/**
|
|
232
|
-
* Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
|
|
233
|
-
*
|
|
234
|
-
* BSD-3-Clause License
|
|
235
|
-
*
|
|
236
|
-
* Copyright (c) 2024 Google LLC
|
|
237
|
-
*/
|
|
209
|
+
* Ported from https://github.com/lit/lit/tree/main/packages/labs/rollup-plugin-minify-html-literals
|
|
210
|
+
*
|
|
211
|
+
* BSD-3-Clause License
|
|
212
|
+
*
|
|
213
|
+
* Copyright (c) 2024 Google LLC
|
|
214
|
+
*/
|
|
238
215
|
interface Template {
|
|
239
216
|
parts: TemplatePart[];
|
|
240
217
|
tag?: string;
|
|
@@ -259,164 +236,164 @@ interface ParseLiteralsOptions {
|
|
|
259
236
|
}
|
|
260
237
|
declare const parseLiterals: (source: string, options?: ParseLiteralsOptions) => Template[];
|
|
261
238
|
/**
|
|
262
|
-
* A strategy on how to minify HTML and optionally CSS.
|
|
263
|
-
* @template O minify HTML options
|
|
264
|
-
* @template C minify CSS options
|
|
265
|
-
*/
|
|
239
|
+
* A strategy on how to minify HTML and optionally CSS.
|
|
240
|
+
* @template O minify HTML options
|
|
241
|
+
* @template C minify CSS options
|
|
242
|
+
*/
|
|
266
243
|
interface Strategy<O = unknown, C = unknown> {
|
|
267
244
|
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
245
|
+
* Combines the parts' HTML text strings together into a single string using
|
|
246
|
+
* the provided placeholder. The placeholder indicates where a template
|
|
247
|
+
* expression occurs.
|
|
248
|
+
* @param parts the parts to combine
|
|
249
|
+
* @param placeholder the placeholder to use between parts
|
|
250
|
+
* @returns the combined parts' text strings
|
|
251
|
+
*/
|
|
275
252
|
combineHTMLStrings: (parts: TemplatePart[], placeholder: string) => string;
|
|
276
253
|
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
254
|
+
* Retrieve a placeholder for the given array of template parts. The
|
|
255
|
+
* placeholder returned should be the same if the function is invoked with the
|
|
256
|
+
* same array of parts.
|
|
257
|
+
*
|
|
258
|
+
* The placeholder should be an HTML-compliant string that is not present in
|
|
259
|
+
* any of the parts' text.
|
|
260
|
+
* @param parts the parts to get a placeholder for
|
|
261
|
+
* @returns the placeholder
|
|
262
|
+
*/
|
|
286
263
|
getPlaceholder: (parts: TemplatePart[]) => string;
|
|
287
264
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
265
|
+
* Minifies the provided CSS string.
|
|
266
|
+
* @param css the css to minfiy
|
|
267
|
+
* @param options css minify options
|
|
268
|
+
* @returns minified CSS string
|
|
269
|
+
*/
|
|
293
270
|
minifyCSS?: (css: string, options?: C) => string;
|
|
294
271
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
272
|
+
* Minfies the provided HTML string.
|
|
273
|
+
* @param html the html to minify
|
|
274
|
+
* @param options html minify options
|
|
275
|
+
* @returns minified HTML string
|
|
276
|
+
*/
|
|
300
277
|
minifyHTML: (html: string, options?: O) => string | Promise<string>;
|
|
301
278
|
/**
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
279
|
+
* Splits a minfied HTML string back into an array of strings from the
|
|
280
|
+
* provided placeholder. The returned array of strings should be the same
|
|
281
|
+
* length as the template parts that were combined to make the HTML string.
|
|
282
|
+
* @param html the html string to split
|
|
283
|
+
* @param placeholder the placeholder to split by
|
|
284
|
+
* @returns an array of html strings
|
|
285
|
+
*/
|
|
309
286
|
splitHTMLByPlaceholder: (html: string, placeholder: string) => string[];
|
|
310
287
|
}
|
|
311
288
|
/**
|
|
312
|
-
* The default <code>html-minifier</code> options, optimized for production
|
|
313
|
-
* minification.
|
|
314
|
-
*/
|
|
289
|
+
* The default <code>html-minifier</code> options, optimized for production
|
|
290
|
+
* minification.
|
|
291
|
+
*/
|
|
315
292
|
declare const defaultMinifyOptions: MinifierOptions;
|
|
316
293
|
/**
|
|
317
|
-
* Options for <code>minifyHTMLLiterals()</code>.
|
|
318
|
-
*/
|
|
294
|
+
* Options for <code>minifyHTMLLiterals()</code>.
|
|
295
|
+
*/
|
|
319
296
|
type Options$1 = DefaultOptions | CustomOptions;
|
|
320
297
|
/**
|
|
321
|
-
* Options for <code>minifyHTMLLiterals()</code>, using default html-minifier
|
|
322
|
-
* strategy.
|
|
323
|
-
*/
|
|
298
|
+
* Options for <code>minifyHTMLLiterals()</code>, using default html-minifier
|
|
299
|
+
* strategy.
|
|
300
|
+
*/
|
|
324
301
|
interface DefaultOptions extends BaseOptions {
|
|
325
302
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
303
|
+
* <code>html-minifier</code> options to use. Defaults to
|
|
304
|
+
* <code>defaultMinifyOptions</code>, for production-ready minification.
|
|
305
|
+
*/
|
|
329
306
|
minifyOptions?: Partial<typeof defaultMinifyOptions>;
|
|
330
307
|
}
|
|
331
308
|
/**
|
|
332
|
-
* Options for <code>minifyHTMLLiterals()</code>, using a custom strategy.
|
|
333
|
-
*/
|
|
309
|
+
* Options for <code>minifyHTMLLiterals()</code>, using a custom strategy.
|
|
310
|
+
*/
|
|
334
311
|
interface CustomOptions<S extends Strategy<any, any> = Strategy<any, any>> extends BaseOptions {
|
|
335
312
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
313
|
+
* HTML minification options.
|
|
314
|
+
*/
|
|
338
315
|
minifyOptions?: S extends Strategy<infer O> ? Partial<O> : never;
|
|
339
316
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
317
|
+
* Override the default strategy for how to minify HTML. The default is to
|
|
318
|
+
* use <code>html-minifier</code>.
|
|
319
|
+
*/
|
|
343
320
|
strategy: S;
|
|
344
321
|
}
|
|
345
322
|
/**
|
|
346
|
-
* Options for <code>minifyHTMLLiterals()</code>.
|
|
347
|
-
*/
|
|
323
|
+
* Options for <code>minifyHTMLLiterals()</code>.
|
|
324
|
+
*/
|
|
348
325
|
interface BaseOptions {
|
|
349
326
|
/**
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
327
|
+
* The name of the file. This is used to determine how to parse the source
|
|
328
|
+
* code and for source map filenames. It may be a base name, relative, or
|
|
329
|
+
* absolute path.
|
|
330
|
+
*/
|
|
354
331
|
fileName?: string;
|
|
355
332
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
333
|
+
* Override how source maps are generated. Set to false to disable source map
|
|
334
|
+
* generation.
|
|
335
|
+
* @param ms the MagicString instance with code modifications
|
|
336
|
+
* @param fileName the name or path of the file
|
|
337
|
+
* @returns a v3 SourceMap or undefined
|
|
338
|
+
*/
|
|
362
339
|
generateSourceMap?: ((ms: MagicStringLike, fileName: string) => SourceMap | undefined) | false;
|
|
363
340
|
/**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
341
|
+
* The MagicString-like constructor to use. MagicString is used to replace
|
|
342
|
+
* strings and generate source maps.
|
|
343
|
+
*
|
|
344
|
+
* Override if you want to set your own version of MagicString or change how
|
|
345
|
+
* strings are overridden. Use <code>generateSourceMap</code> if you want to
|
|
346
|
+
* change how source maps are created.
|
|
347
|
+
*/
|
|
371
348
|
MagicString?: new (source: string) => MagicStringLike;
|
|
372
349
|
/**
|
|
373
|
-
|
|
374
|
-
|
|
350
|
+
* Override how template literals are parsed from a source string.
|
|
351
|
+
*/
|
|
375
352
|
parseLiterals?: typeof parseLiterals;
|
|
376
353
|
/**
|
|
377
|
-
|
|
378
|
-
|
|
354
|
+
* Options for <code>parseLiterals()</code>.
|
|
355
|
+
*/
|
|
379
356
|
parseLiteralsOptions?: Partial<ParseLiteralsOptions>;
|
|
380
357
|
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
358
|
+
* Determines whether or not a template should be minified. The default is to
|
|
359
|
+
* minify all tagged template whose tag name contains "html" (case
|
|
360
|
+
* insensitive).
|
|
361
|
+
* @param template the template to check
|
|
362
|
+
* @returns true if the template should be minified
|
|
363
|
+
*/
|
|
387
364
|
shouldMinify?: (template: Template) => boolean;
|
|
388
365
|
/**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
366
|
+
* Determines whether or not a CSS template should be minified. The default is
|
|
367
|
+
* to minify all tagged template whose tag name contains "css" (case
|
|
368
|
+
* insensitive).
|
|
369
|
+
* @param template the template to check
|
|
370
|
+
* @returns true if the template should be minified
|
|
371
|
+
*/
|
|
395
372
|
shouldMinifyCSS?: (template: Template) => boolean;
|
|
396
373
|
/**
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
374
|
+
* Override custom validation or set to false to disable validation. This is
|
|
375
|
+
* only useful when implementing your own strategy that may return
|
|
376
|
+
* unexpected results.
|
|
377
|
+
*/
|
|
401
378
|
validate?: Validation | false;
|
|
402
379
|
}
|
|
403
380
|
/**
|
|
404
|
-
* A MagicString-like instance. <code>minify-html-literals</code> only uses a
|
|
405
|
-
* subset of the MagicString API to overwrite the source code and generate
|
|
406
|
-
* source maps.
|
|
407
|
-
*/
|
|
381
|
+
* A MagicString-like instance. <code>minify-html-literals</code> only uses a
|
|
382
|
+
* subset of the MagicString API to overwrite the source code and generate
|
|
383
|
+
* source maps.
|
|
384
|
+
*/
|
|
408
385
|
interface MagicStringLike {
|
|
409
386
|
generateMap: (options?: Partial<SourceMapOptions>) => SourceMap;
|
|
410
387
|
overwrite: (start: number, end: number, content: string) => unknown;
|
|
411
388
|
toString: () => string;
|
|
412
389
|
}
|
|
413
390
|
/**
|
|
414
|
-
* A v3 SourceMap.
|
|
415
|
-
*
|
|
416
|
-
* <code>magic-string> incorrectly declares the SourceMap type with a version
|
|
417
|
-
* string instead of a number, so <code>minify-html-literals</code> declares
|
|
418
|
-
* its own type.
|
|
419
|
-
*/
|
|
391
|
+
* A v3 SourceMap.
|
|
392
|
+
*
|
|
393
|
+
* <code>magic-string> incorrectly declares the SourceMap type with a version
|
|
394
|
+
* string instead of a number, so <code>minify-html-literals</code> declares
|
|
395
|
+
* its own type.
|
|
396
|
+
*/
|
|
420
397
|
interface SourceMap {
|
|
421
398
|
file?: string;
|
|
422
399
|
mappings: string;
|
|
@@ -428,120 +405,115 @@ interface SourceMap {
|
|
|
428
405
|
version: number;
|
|
429
406
|
}
|
|
430
407
|
/**
|
|
431
|
-
* Validation that is executed when minifying HTML to ensure there are no
|
|
432
|
-
* unexpected errors. This is to alleviate hard-to-troubleshoot errors such as
|
|
433
|
-
* undefined errors.
|
|
434
|
-
*/
|
|
408
|
+
* Validation that is executed when minifying HTML to ensure there are no
|
|
409
|
+
* unexpected errors. This is to alleviate hard-to-troubleshoot errors such as
|
|
410
|
+
* undefined errors.
|
|
411
|
+
*/
|
|
435
412
|
interface Validation {
|
|
436
413
|
/**
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
414
|
+
* Throws an error if <code>strategy.splitHTMLByPlaceholder()</code> does not
|
|
415
|
+
* return an HTML part string for each template part.
|
|
416
|
+
* @param parts the template parts that generated the strings
|
|
417
|
+
* @param htmlParts the split HTML strings
|
|
418
|
+
*/
|
|
442
419
|
ensureHTMLPartsValid: (parts: TemplatePart[], htmlParts: string[]) => void;
|
|
443
420
|
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
421
|
+
* Throws an error if <code>strategy.getPlaceholder()</code> does not return
|
|
422
|
+
* a valid placeholder string.
|
|
423
|
+
* @param placeholder the placeholder to check
|
|
424
|
+
*/
|
|
448
425
|
ensurePlaceholderValid: (placeholder: unknown) => void;
|
|
449
426
|
}
|
|
450
427
|
/**
|
|
451
|
-
* The result of a call to <code>minifyHTMLLiterals()</code>.
|
|
452
|
-
*/
|
|
428
|
+
* The result of a call to <code>minifyHTMLLiterals()</code>.
|
|
429
|
+
*/
|
|
453
430
|
interface Result {
|
|
454
431
|
/**
|
|
455
|
-
|
|
456
|
-
|
|
432
|
+
* The minified code.
|
|
433
|
+
*/
|
|
457
434
|
code: string;
|
|
458
435
|
/**
|
|
459
|
-
|
|
460
|
-
|
|
436
|
+
* Optional v3 SourceMap for the code.
|
|
437
|
+
*/
|
|
461
438
|
map: SourceMap | undefined;
|
|
462
439
|
}
|
|
463
440
|
/**
|
|
464
|
-
* Minifies all HTML template literals in the provided source string.
|
|
465
|
-
* @param source the source code
|
|
466
|
-
* @param options minification options
|
|
467
|
-
* @returns the minified code, or null if no minification occurred.
|
|
468
|
-
*/
|
|
441
|
+
* Minifies all HTML template literals in the provided source string.
|
|
442
|
+
* @param source the source code
|
|
443
|
+
* @param options minification options
|
|
444
|
+
* @returns the minified code, or null if no minification occurred.
|
|
445
|
+
*/
|
|
469
446
|
declare function minifyHTMLLiterals$1(source: string, options?: DefaultOptions): Promise<Result | null | undefined>;
|
|
470
447
|
/**
|
|
471
|
-
* Minifies all HTML template literals in the provided source string.
|
|
472
|
-
* @param source the source code
|
|
473
|
-
* @param options minification options
|
|
474
|
-
* @returns the minified code, or null if no minification occurred.
|
|
475
|
-
*/
|
|
448
|
+
* Minifies all HTML template literals in the provided source string.
|
|
449
|
+
* @param source the source code
|
|
450
|
+
* @param options minification options
|
|
451
|
+
* @returns the minified code, or null if no minification occurred.
|
|
452
|
+
*/
|
|
476
453
|
declare function minifyHTMLLiterals$1<S extends Strategy>(source: string, options?: CustomOptions<S>): Promise<Result | undefined>;
|
|
477
454
|
/**
|
|
478
|
-
* Plugin options.
|
|
479
|
-
*/
|
|
455
|
+
* Plugin options.
|
|
456
|
+
*/
|
|
480
457
|
interface MinifyHTMLLiteralsOptions {
|
|
481
458
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
459
|
+
* Pattern or array of patterns of files not to minify.
|
|
460
|
+
*/
|
|
484
461
|
exclude?: FilterPattern;
|
|
485
462
|
/**
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
463
|
+
* If true, any errors while parsing or minifying will abort the bundle
|
|
464
|
+
* process. Defaults to false, which will only show a warning.
|
|
465
|
+
*/
|
|
489
466
|
failOnError?: boolean;
|
|
490
467
|
/**
|
|
491
|
-
|
|
492
|
-
|
|
468
|
+
* Pattern or array of patterns of files to minify.
|
|
469
|
+
*/
|
|
493
470
|
include?: FilterPattern;
|
|
494
471
|
/**
|
|
495
|
-
|
|
496
|
-
|
|
472
|
+
* Override minify-html-literals function.
|
|
473
|
+
*/
|
|
497
474
|
minifyHTMLLiterals?: typeof minifyHTMLLiterals$1;
|
|
498
475
|
/**
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
476
|
+
* Minify options, see
|
|
477
|
+
* https://www.npmjs.com/package/minify-html-literals#options.
|
|
478
|
+
*/
|
|
502
479
|
options?: Partial<Options$1>;
|
|
503
480
|
}
|
|
504
481
|
interface NativeModulesOptions {
|
|
505
482
|
/**
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
483
|
+
* Custom subdirectory name for native modules within the output directory
|
|
484
|
+
* @default 'natives'
|
|
485
|
+
*/
|
|
509
486
|
nativesDirectory?: string;
|
|
510
487
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Handles native Node.js addons (.node files)
|
|
513
|
-
* - Stage 1 (resolve/load): Identifies .node files and generates runtime code.
|
|
514
|
-
* - Stage 2 (generateBundle): Copies the identified .node files to the output dir.
|
|
515
|
-
*/
|
|
516
488
|
interface RawLoaderOptions {
|
|
517
489
|
exclude?: FilterPattern;
|
|
518
490
|
include?: FilterPattern;
|
|
519
491
|
}
|
|
520
492
|
type Awaitable<T> = T | Promise<T>;
|
|
521
493
|
/**
|
|
522
|
-
* @returns A boolean or a promise that resolves to a boolean,
|
|
523
|
-
* or `undefined` to let the plugin decide automatically.
|
|
524
|
-
*/
|
|
494
|
+
* @returns A boolean or a promise that resolves to a boolean,
|
|
495
|
+
* or `undefined` to let the plugin decide automatically.
|
|
496
|
+
*/
|
|
525
497
|
type TransformFunction = (id: string, importer: string, rollupResolve: (id: string, importer?: string) => Promise<ResolvedId | null>) => Awaitable<boolean | undefined | void>;
|
|
526
498
|
interface Options {
|
|
527
499
|
/**
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
500
|
+
* Whether to transform Node.js built-in modules (e.g., `fs`, `path`)
|
|
501
|
+
* to `process.getBuiltinModule()` calls when supported, which has the best performance.
|
|
502
|
+
* Falls back to `createRequire()` for older Node.js versions, Bun, and Deno.
|
|
503
|
+
*
|
|
504
|
+
* Note: `process.getBuiltinModule` is available since Node.js 20.16.0 and 22.3.0.
|
|
505
|
+
* For older versions, the plugin uses `createRequire()` as fallback.
|
|
506
|
+
*/
|
|
535
507
|
builtinNodeModules?: boolean;
|
|
536
508
|
cwd?: string;
|
|
537
509
|
exclude?: FilterPattern;
|
|
538
510
|
include?: FilterPattern;
|
|
539
511
|
order?: "pre" | "post";
|
|
540
512
|
/**
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
513
|
+
* A function to determine whether a module should be transformed.
|
|
514
|
+
* Return `true` to force transformation, `false` to skip transformation,
|
|
515
|
+
* or `undefined` to let the plugin decide automatically.
|
|
516
|
+
*/
|
|
545
517
|
shouldTransform?: string[] | TransformFunction;
|
|
546
518
|
}
|
|
547
519
|
type ShebangOptions = {
|
|
@@ -554,101 +526,86 @@ interface SourcemapsPluginOptions {
|
|
|
554
526
|
}
|
|
555
527
|
interface UrlOptions {
|
|
556
528
|
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
529
|
+
* The destination dir to copy assets, usually used to rebase the assets according to HTML files.
|
|
530
|
+
* @type {string}
|
|
531
|
+
*/
|
|
560
532
|
destDir?: string;
|
|
561
533
|
/**
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
534
|
+
* If false, will prevent files being emitted by this plugin. This is useful for when you are using Rollup to emit both a client-side and server-side bundle.
|
|
535
|
+
* @type {boolean}
|
|
536
|
+
* @default true
|
|
537
|
+
*/
|
|
566
538
|
emitFiles: boolean;
|
|
567
539
|
/**
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
540
|
+
* A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
|
|
541
|
+
* should _ignore_.
|
|
542
|
+
*
|
|
543
|
+
* By default, no files are ignored.
|
|
544
|
+
* @type {FilterPattern}
|
|
545
|
+
*/
|
|
574
546
|
exclude?: FilterPattern;
|
|
575
547
|
/**
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
548
|
+
* If emitFiles is true, this option can be used to rename the emitted files. It accepts the following string replacements:
|
|
549
|
+
* [hash] - The hash value of the file's contents
|
|
550
|
+
* [name] - The name of the imported file (without its file extension)
|
|
551
|
+
* [extname] - The extension of the imported file (including the leading .)
|
|
552
|
+
* [dirname] - The parent directory name of the imported file (including trailing /)
|
|
553
|
+
* @type {string}
|
|
554
|
+
* @default [hash][extname]
|
|
555
|
+
*/
|
|
584
556
|
fileName: string;
|
|
585
557
|
/**
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
558
|
+
* A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
|
|
559
|
+
* should operate on.
|
|
560
|
+
* By default, the png,jpg,jpeg,gif,svg,webp files are targeted.
|
|
561
|
+
* @type {FilterPattern}
|
|
562
|
+
*/
|
|
591
563
|
include?: FilterPattern;
|
|
592
564
|
/**
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
565
|
+
* The file size limit for inline files.
|
|
566
|
+
* If a file exceeds this limit, it will be copied to the destination folder and the hashed filename will be provided instead.
|
|
567
|
+
* If limit is set to 0 all files will be copied.
|
|
568
|
+
* @type {number}
|
|
569
|
+
* @default 14336 (14kb)
|
|
570
|
+
*/
|
|
599
571
|
limit: number;
|
|
600
572
|
/**
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
573
|
+
* A string which will be added in front of filenames when they are not inlined but are copied.
|
|
574
|
+
* @type {string}
|
|
575
|
+
*/
|
|
604
576
|
publicPath?: string;
|
|
605
577
|
/**
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
578
|
+
* When using the [dirname] replacement in fileName, use this directory as the source directory from which to create the file path rather than the parent directory of the imported file. For example:
|
|
579
|
+
* @example
|
|
580
|
+
* ```js
|
|
581
|
+
* src/path/to/file.js
|
|
582
|
+
*
|
|
583
|
+
* import png from './image.png';
|
|
584
|
+
* rollup.config.js
|
|
585
|
+
*
|
|
586
|
+
* url({
|
|
587
|
+
* fileName: '[dirname][hash][extname]',
|
|
588
|
+
* sourceDir: path.join(__dirname, 'src')
|
|
589
|
+
* });
|
|
590
|
+
*
|
|
591
|
+
* Emitted File: path/to/image.png
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
622
594
|
sourceDir?: string;
|
|
623
595
|
}
|
|
624
596
|
type PatchTypesOptions = {
|
|
625
597
|
identifierReplacements?: Record<string, Record<string, string>>;
|
|
626
598
|
};
|
|
627
|
-
/**
|
|
628
|
-
* Patches the bundled types output before passing to the dts plugin.
|
|
629
|
-
*
|
|
630
|
-
* 1. Validate unallowed dependency imports.
|
|
631
|
-
* 2. Replace confusing type names.
|
|
632
|
-
* 3. Strip leftover internal types.
|
|
633
|
-
* 4. Clean unnecessary comments.
|
|
634
|
-
*/
|
|
635
599
|
type TsconfigPathsPluginOptions = {
|
|
636
600
|
resolveAbsolutePath?: boolean;
|
|
637
601
|
};
|
|
638
602
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*/
|
|
645
|
-
/**
|
|
646
|
-
* Legacy `@rollup/plugin-node-resolve` option keys. Module resolution is now
|
|
647
|
-
* handled by the oxc resolver, but these keys are still accepted and mapped onto
|
|
648
|
-
* the equivalent oxc-resolver options at build time so existing configs (and the
|
|
649
|
-
* svelte/solid presets) keep working. Prefer the native oxc keys
|
|
650
|
-
* (`conditionNames`, `aliasFields`, …) in new configs.
|
|
651
|
-
*/
|
|
603
|
+
* Legacy `@rollup/plugin-node-resolve` option keys. Module resolution is now
|
|
604
|
+
* handled by the oxc resolver, but these keys are still accepted and mapped onto
|
|
605
|
+
* the equivalent oxc-resolver options at build time so existing configs (and the
|
|
606
|
+
* svelte/solid presets) keep working. Prefer the native oxc keys
|
|
607
|
+
* (`conditionNames`, `aliasFields`, …) in new configs.
|
|
608
|
+
*/
|
|
652
609
|
interface LegacyNodeResolveOptions {
|
|
653
610
|
/** Node-resolve `allowExportsFolderMapping`; ignored by the oxc resolver (dropped at build time). */
|
|
654
611
|
allowExportsFolderMapping?: boolean;
|
|
@@ -657,24 +614,24 @@ interface LegacyNodeResolveOptions {
|
|
|
657
614
|
/** Node-resolve `exportConditions`; maps to (and is prepended onto) `conditionNames`. */
|
|
658
615
|
exportConditions?: string[];
|
|
659
616
|
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
617
|
+
* Node-resolve `preferBuiltins`. Node builtins are externalized by the externals
|
|
618
|
+
* plugin, so this is dropped before reaching the oxc resolver; it is retained as a
|
|
619
|
+
* config key only because the build runtime still sets it from `runtime`.
|
|
620
|
+
*/
|
|
664
621
|
preferBuiltins?: boolean;
|
|
665
622
|
}
|
|
666
623
|
/**
|
|
667
|
-
* Module-resolution options, passed to the oxc-resolver-backed resolve plugin.
|
|
668
|
-
* Accepts the native oxc-resolver options plus a few legacy node-resolve keys
|
|
669
|
-
* ({@link LegacyNodeResolveOptions}) that are mapped onto their oxc equivalents.
|
|
670
|
-
*/
|
|
624
|
+
* Module-resolution options, passed to the oxc-resolver-backed resolve plugin.
|
|
625
|
+
* Accepts the native oxc-resolver options plus a few legacy node-resolve keys
|
|
626
|
+
* ({@link LegacyNodeResolveOptions}) that are mapped onto their oxc equivalents.
|
|
627
|
+
*/
|
|
671
628
|
type ResolveOptions = LegacyNodeResolveOptions & OXCResolveOptions & {
|
|
672
629
|
/**
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
630
|
+
* Controls how unresolved imports are handled.
|
|
631
|
+
* - `"error"` (default): treat unresolved imports as errors, failing the build.
|
|
632
|
+
* - `"warn"`: emit a warning and continue.
|
|
633
|
+
* @default "error"
|
|
634
|
+
*/
|
|
678
635
|
unresolvedImportBehavior?: "error" | "warn";
|
|
679
636
|
};
|
|
680
637
|
interface PackemRollupOptions {
|
|
@@ -686,10 +643,10 @@ interface PackemRollupOptions {
|
|
|
686
643
|
dataUri?: DataUriPluginOptions | false;
|
|
687
644
|
debarrel?: DebarrelPluginOptions | false;
|
|
688
645
|
/**
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
646
|
+
* Detect dependencies that get bundled more than once (multiple versions, or
|
|
647
|
+
* the same version from multiple directories) and report them. Enabled by
|
|
648
|
+
* default; set to `false` to disable, or pass options to configure.
|
|
649
|
+
*/
|
|
693
650
|
detectDuplicated?: DetectDuplicatedPluginOptions | false;
|
|
694
651
|
dts?: Options$2;
|
|
695
652
|
dynamicVars?: RollupDynamicImportVariablesOptions | false;
|
|
@@ -734,4 +691,4 @@ type RollupPlugins = {
|
|
|
734
691
|
plugin: Plugin;
|
|
735
692
|
type?: "build" | "dts";
|
|
736
693
|
}[];
|
|
737
|
-
export {
|
|
694
|
+
export type { JSXRemoveAttributesPlugin, LegacyNodeResolveOptions, PackemRollupOptions, ResolveOptions, RollupPlugins };
|