@vizejs/rspack-plugin 0.425.1 → 0.426.0
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/README.md +32 -445
- package/dist/compiler-Bvvgv3Cz.mjs +88 -0
- package/dist/{index-BSrDeFdh.d.mts → index-Cg474czL.d.mts} +49 -20
- package/dist/index.d.mts +27 -12
- package/dist/index.mjs +1 -1
- package/dist/loader/index.d.mts +2 -2
- package/dist/loader/index.mjs +1 -1
- package/dist/loader/jsx-loader.d.mts +2 -2
- package/dist/loader/jsx-loader.mjs +1 -1
- package/dist/loader/scope-loader.mjs +1 -1
- package/dist/loader/style-loader.d.mts +1 -1
- package/dist/loader/style-loader.mjs +1 -1
- package/dist/loader-Cw4_LSPf.mjs +1 -0
- package/dist/utils-ByWFOFCe.mjs +1 -0
- package/package.json +10 -4
- package/dist/compiler-CUPTljp_.mjs +0 -42
- package/dist/loader-3I9d5PUe.mjs +0 -1
- package/dist/utils-CWJUzLH_.mjs +0 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ High-performance Rspack plugin for Vue SFC compilation powered by [Vize](https:/
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
14
|
- ⚡ **Blazing Fast** - Powered by Rust-based `@vizejs/native` compiler
|
|
15
|
-
- 🔄 **HMR
|
|
15
|
+
- 🔄 **SFC HMR** - State-preserving style/template updates for compatible Vue 3 VDOM components; script updates reload the component
|
|
16
16
|
- 🎨 **CSS Processing** - Support for both Rspack native CSS (`experiments.css` in Rspack 1.x, default capability in Rspack 2.x) and CssExtractRspackPlugin
|
|
17
17
|
- 📦 **CSS Modules** - First-class CSS Modules support with per-module HMR
|
|
18
18
|
- 🔗 **`<style src>` Support** - Resolves external style files with watch dependency tracking
|
|
@@ -33,7 +33,7 @@ vp install -D @vizejs/rspack-plugin @rspack/core
|
|
|
33
33
|
|
|
34
34
|
> [!IMPORTANT]
|
|
35
35
|
> **Rspack 2.x**: native CSS is the default — you don't need to set `experiments.css` or `css: { native: true }`. (`experiments.css` is deprecated in 2.x but still works; the recommended path is to declare CSS rules with `type: "css/auto"`, which VizePlugin does for you.) Set `css: { native: false }` only to opt out and use a JS-based style pipeline (e.g. `CssExtractRspackPlugin` / `style-loader`).
|
|
36
|
-
> **Rspack 1.x**: native CSS is off by default. Set `experiments: { css: true }`
|
|
36
|
+
> **Rspack 1.x**: native CSS is off by default. Set `experiments: { css: true }` to enable it. The plugin option alone does not enable the Rspack 1.x experiment.
|
|
37
37
|
|
|
38
38
|
### Simple Mode (Recommended)
|
|
39
39
|
|
|
@@ -61,7 +61,6 @@ export default {
|
|
|
61
61
|
|
|
62
62
|
plugins: [
|
|
63
63
|
new VizePlugin({
|
|
64
|
-
isProduction,
|
|
65
64
|
// Native CSS is the default on Rspack 2.x.
|
|
66
65
|
// On Rspack 1.x, pass css: { native: true } and set experiments: { css: true }.
|
|
67
66
|
// Pass css: { native: false } to opt out of native CSS.
|
|
@@ -101,11 +100,7 @@ export default {
|
|
|
101
100
|
],
|
|
102
101
|
},
|
|
103
102
|
|
|
104
|
-
plugins: [
|
|
105
|
-
new VizePlugin({
|
|
106
|
-
isProduction,
|
|
107
|
-
}),
|
|
108
|
-
],
|
|
103
|
+
plugins: [new VizePlugin()],
|
|
109
104
|
|
|
110
105
|
resolve: {
|
|
111
106
|
alias: {
|
|
@@ -155,9 +150,7 @@ export default {
|
|
|
155
150
|
},
|
|
156
151
|
|
|
157
152
|
plugins: [
|
|
158
|
-
new VizePlugin({
|
|
159
|
-
isProduction,
|
|
160
|
-
}),
|
|
153
|
+
new VizePlugin({ css: { native: false } }),
|
|
161
154
|
|
|
162
155
|
...(isProduction
|
|
163
156
|
? [
|
|
@@ -177,440 +170,34 @@ export default {
|
|
|
177
170
|
};
|
|
178
171
|
```
|
|
179
172
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
`
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
{
|
|
209
|
-
test: /\.vue$/,
|
|
210
|
-
oneOf: [
|
|
211
|
-
{ resourceQuery: /type=style/, use: [/* style pipeline */] },
|
|
212
|
-
{ use: [/* main vize loader */] },
|
|
213
|
-
],
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
<details>
|
|
218
|
-
<summary>Native CSS with manual oneOf</summary>
|
|
219
|
-
|
|
220
|
-
```javascript
|
|
221
|
-
// rspack.config.mjs
|
|
222
|
-
import { VizePlugin } from "@vizejs/rspack-plugin";
|
|
223
|
-
import path from "node:path";
|
|
224
|
-
|
|
225
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
226
|
-
|
|
227
|
-
export default {
|
|
228
|
-
mode: isProduction ? "production" : "development",
|
|
229
|
-
|
|
230
|
-
// Rspack 2.x: native CSS is on by default.
|
|
231
|
-
// Rspack 1.x only, to enable native CSS: experiments: { css: true },
|
|
232
|
-
|
|
233
|
-
module: {
|
|
234
|
-
rules: [
|
|
235
|
-
{
|
|
236
|
-
test: /\.vue$/,
|
|
237
|
-
oneOf: [
|
|
238
|
-
// CSS Modules (<style module>)
|
|
239
|
-
{
|
|
240
|
-
resourceQuery: /vue&type=style.*module/,
|
|
241
|
-
type: "css/module",
|
|
242
|
-
use: [
|
|
243
|
-
{ loader: "@vizejs/rspack-plugin/scope-loader" },
|
|
244
|
-
{ loader: "@vizejs/rspack-plugin/style-loader" },
|
|
245
|
-
],
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
// SCSS (<style lang="scss">)
|
|
249
|
-
{
|
|
250
|
-
resourceQuery: /vue&type=style.*lang=scss/,
|
|
251
|
-
type: "css/auto",
|
|
252
|
-
use: [
|
|
253
|
-
{ loader: "@vizejs/rspack-plugin/scope-loader" },
|
|
254
|
-
"sass-loader",
|
|
255
|
-
{ loader: "@vizejs/rspack-plugin/style-loader" },
|
|
256
|
-
],
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
// Regular CSS (<style>)
|
|
260
|
-
{
|
|
261
|
-
resourceQuery: /vue&type=style/,
|
|
262
|
-
type: "css/auto",
|
|
263
|
-
use: [
|
|
264
|
-
{ loader: "@vizejs/rspack-plugin/scope-loader" },
|
|
265
|
-
{ loader: "@vizejs/rspack-plugin/style-loader" },
|
|
266
|
-
],
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
// Main .vue file (compile SFC → JS)
|
|
270
|
-
{
|
|
271
|
-
use: [
|
|
272
|
-
{
|
|
273
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
plugins: [
|
|
283
|
-
new VizePlugin({
|
|
284
|
-
isProduction,
|
|
285
|
-
autoRules: false,
|
|
286
|
-
css: { native: true },
|
|
287
|
-
}),
|
|
288
|
-
],
|
|
289
|
-
|
|
290
|
-
resolve: {
|
|
291
|
-
alias: {
|
|
292
|
-
"@": path.resolve(import.meta.dirname, "src"),
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
</details>
|
|
299
|
-
|
|
300
|
-
<details>
|
|
301
|
-
<summary>CssExtractRspackPlugin with manual oneOf</summary>
|
|
302
|
-
|
|
303
|
-
```javascript
|
|
304
|
-
// rspack.config.mjs
|
|
305
|
-
import { rspack } from "@rspack/core";
|
|
306
|
-
import { VizePlugin } from "@vizejs/rspack-plugin";
|
|
307
|
-
import path from "node:path";
|
|
308
|
-
|
|
309
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
310
|
-
|
|
311
|
-
export default {
|
|
312
|
-
mode: isProduction ? "production" : "development",
|
|
313
|
-
|
|
314
|
-
module: {
|
|
315
|
-
rules: [
|
|
316
|
-
{
|
|
317
|
-
test: /\.vue$/,
|
|
318
|
-
oneOf: [
|
|
319
|
-
// SCSS style blocks
|
|
320
|
-
{
|
|
321
|
-
resourceQuery: /vue&type=style.*lang=scss/,
|
|
322
|
-
type: "javascript/auto",
|
|
323
|
-
use: [
|
|
324
|
-
isProduction ? rspack.CssExtractRspackPlugin.loader : "style-loader",
|
|
325
|
-
"css-loader",
|
|
326
|
-
{ loader: "@vizejs/rspack-plugin/scope-loader" },
|
|
327
|
-
"sass-loader",
|
|
328
|
-
{ loader: "@vizejs/rspack-plugin/style-loader" },
|
|
329
|
-
],
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
// Regular CSS style blocks
|
|
333
|
-
{
|
|
334
|
-
resourceQuery: /vue&type=style/,
|
|
335
|
-
type: "javascript/auto",
|
|
336
|
-
use: [
|
|
337
|
-
isProduction ? rspack.CssExtractRspackPlugin.loader : "style-loader",
|
|
338
|
-
{
|
|
339
|
-
loader: "css-loader",
|
|
340
|
-
options: {
|
|
341
|
-
modules: {
|
|
342
|
-
auto: (_resourcePath, resourceQuery) =>
|
|
343
|
-
typeof resourceQuery === "string" && resourceQuery.includes("module="),
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
{ loader: "@vizejs/rspack-plugin/scope-loader" },
|
|
348
|
-
{ loader: "@vizejs/rspack-plugin/style-loader" },
|
|
349
|
-
],
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
// Main .vue file
|
|
353
|
-
{
|
|
354
|
-
use: [
|
|
355
|
-
{
|
|
356
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
// Regular CSS files (non-Vue)
|
|
364
|
-
{
|
|
365
|
-
test: /\.css$/,
|
|
366
|
-
type: "javascript/auto",
|
|
367
|
-
use: [isProduction ? rspack.CssExtractRspackPlugin.loader : "style-loader", "css-loader"],
|
|
368
|
-
},
|
|
369
|
-
|
|
370
|
-
// Regular SCSS files (non-Vue)
|
|
371
|
-
{
|
|
372
|
-
test: /\.scss$/,
|
|
373
|
-
type: "javascript/auto",
|
|
374
|
-
use: [
|
|
375
|
-
isProduction ? rspack.CssExtractRspackPlugin.loader : "style-loader",
|
|
376
|
-
"css-loader",
|
|
377
|
-
"sass-loader",
|
|
378
|
-
],
|
|
379
|
-
},
|
|
380
|
-
],
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
plugins: [
|
|
384
|
-
new VizePlugin({
|
|
385
|
-
isProduction,
|
|
386
|
-
autoRules: false,
|
|
387
|
-
}),
|
|
388
|
-
|
|
389
|
-
...(isProduction
|
|
390
|
-
? [
|
|
391
|
-
new rspack.CssExtractRspackPlugin({
|
|
392
|
-
filename: "styles/[name].[contenthash:8].css",
|
|
393
|
-
chunkFilename: "styles/[name].[contenthash:8].chunk.css",
|
|
394
|
-
}),
|
|
395
|
-
]
|
|
396
|
-
: []),
|
|
397
|
-
],
|
|
398
|
-
|
|
399
|
-
resolve: {
|
|
400
|
-
alias: {
|
|
401
|
-
"@": path.resolve(import.meta.dirname, "src"),
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
};
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
</details>
|
|
408
|
-
|
|
409
|
-
## API
|
|
410
|
-
|
|
411
|
-
### VizePlugin
|
|
412
|
-
|
|
413
|
-
```typescript
|
|
414
|
-
import { VizePlugin } from "@vizejs/rspack-plugin";
|
|
415
|
-
|
|
416
|
-
new VizePlugin({
|
|
417
|
-
isProduction: boolean; // Auto-detected from Rspack mode
|
|
418
|
-
include: string | RegExp | (string | RegExp)[]; // Filter watched .vue files
|
|
419
|
-
exclude: string | RegExp | (string | RegExp)[]; // Exclude watched .vue files
|
|
420
|
-
ssr: boolean; // Enable SSR mode (default: false)
|
|
421
|
-
sourceMap: boolean; // Enable source maps (default: true in dev)
|
|
422
|
-
vapor: boolean; // Enable Vapor mode (default: false)
|
|
423
|
-
root: string; // Root directory (default: Rspack's root)
|
|
424
|
-
css: {
|
|
425
|
-
native: boolean; // Use Rspack native CSS. Default: true on Rspack 2.x, false on 1.x (1.x also needs experiments: { css: true })
|
|
426
|
-
};
|
|
427
|
-
compilerOptions: {}; // Extra @vizejs/native compileSfc options
|
|
428
|
-
debug: boolean; // Enable debug logging (default: false)
|
|
429
|
-
autoRules: boolean; // Auto-clone CSS rules for Vue style sub-requests (default: true)
|
|
430
|
-
typescript: boolean; // Auto-inject builtin:swc-loader for .vue post-processing (default: true)
|
|
431
|
-
});
|
|
432
|
-
// Debug logging uses Rspack's infrastructure logger.
|
|
433
|
-
// Control verbosity via `infrastructureLogging.level` in your rspack config.
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### VizeLoader
|
|
437
|
-
|
|
438
|
-
```typescript
|
|
439
|
-
// In rspack.config.js
|
|
440
|
-
{
|
|
441
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
442
|
-
options: {
|
|
443
|
-
include: string | RegExp | (string | RegExp)[]; // Safe compile allowlist
|
|
444
|
-
exclude: string | RegExp | (string | RegExp)[]; // Safe compile denylist
|
|
445
|
-
sourceMap: boolean; // Enable source maps (default: true)
|
|
446
|
-
ssr: boolean; // Enable SSR mode (default: false)
|
|
447
|
-
vapor: boolean; // Enable Vapor mode (default: false)
|
|
448
|
-
customElement: boolean | RegExp; // Custom element mode (default: /\.ce\.vue$/)
|
|
449
|
-
hotReload: boolean; // Enable HMR (default: true in dev, false in prod/SSR)
|
|
450
|
-
transformAssetUrls: boolean | Record<string, string[]>; // See below (default: true)
|
|
451
|
-
compilerOptions: { // Extra @vizejs/native compileSfc options
|
|
452
|
-
filename?: string;
|
|
453
|
-
sourceMap?: boolean;
|
|
454
|
-
ssr?: boolean;
|
|
455
|
-
isTs?: boolean; // Preserve TypeScript (auto-detected from <script lang="ts">)
|
|
456
|
-
vapor?: boolean; // Enable Vapor mode compilation
|
|
457
|
-
scopeId?: string;
|
|
458
|
-
};
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
If `include/exclude` filters out a `.vue` file matched by this loader rule, the loader emits a warning and passes through the source unchanged.
|
|
464
|
-
This avoids hard failures while still alerting you to mismatched rule/filter configuration.
|
|
465
|
-
|
|
466
|
-
Compilation errors cause the loader to fail immediately (`callback(error)`) instead of returning broken code.
|
|
467
|
-
|
|
468
|
-
#### TypeScript
|
|
469
|
-
|
|
470
|
-
`@vizejs/native compileSfc` preserves TypeScript syntax in its output (same behavior as `@vue/compiler-sfc`). By default, `VizePlugin` injects a `.vue` `enforce: "post"` rule using Rspack's built-in `builtin:swc-loader` to strip those type annotations for main SFC requests.
|
|
471
|
-
|
|
472
|
-
- **Default behavior**: No extra config is required. `new VizePlugin()` automatically injects the SWC post-processing rule.
|
|
473
|
-
- **Opt out**: Set `new VizePlugin({ typescript: false })` if you want to manage `.vue` TypeScript stripping yourself.
|
|
474
|
-
- **Custom loader**: When opting out, use `esbuild-loader`, `builtin:swc-loader`, or any other TS transpiler as your own `enforce: "post"` rule for `.vue` files (excluding `type=style` requests).
|
|
475
|
-
|
|
476
|
-
<details>
|
|
477
|
-
<summary>Advanced: builtin:swc-loader</summary>
|
|
478
|
-
|
|
479
|
-
```javascript
|
|
480
|
-
// rspack.config.mjs
|
|
481
|
-
import { defineConfig } from "@rspack/cli";
|
|
482
|
-
import { VizePlugin } from "@vizejs/rspack-plugin";
|
|
483
|
-
|
|
484
|
-
export default defineConfig({
|
|
485
|
-
module: {
|
|
486
|
-
rules: [
|
|
487
|
-
{
|
|
488
|
-
test: /\.vue$/,
|
|
489
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
test: /\.vue$/,
|
|
493
|
-
resourceQuery: { not: [/type=/] },
|
|
494
|
-
enforce: "post",
|
|
495
|
-
loader: "builtin:swc-loader",
|
|
496
|
-
options: {
|
|
497
|
-
jsc: {
|
|
498
|
-
parser: {
|
|
499
|
-
syntax: "typescript",
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
},
|
|
503
|
-
type: "javascript/auto",
|
|
504
|
-
},
|
|
505
|
-
],
|
|
506
|
-
},
|
|
507
|
-
plugins: [
|
|
508
|
-
new VizePlugin({
|
|
509
|
-
typescript: false,
|
|
510
|
-
}),
|
|
511
|
-
],
|
|
512
|
-
});
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
</details>
|
|
516
|
-
|
|
517
|
-
<details>
|
|
518
|
-
<summary>Advanced: esbuild-loader</summary>
|
|
519
|
-
|
|
520
|
-
```javascript
|
|
521
|
-
// rspack.config.mjs
|
|
522
|
-
import { defineConfig } from "@rspack/cli";
|
|
523
|
-
import { VizePlugin } from "@vizejs/rspack-plugin";
|
|
524
|
-
|
|
525
|
-
export default defineConfig({
|
|
526
|
-
module: {
|
|
527
|
-
rules: [
|
|
528
|
-
{
|
|
529
|
-
test: /\.vue$/,
|
|
530
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
531
|
-
},
|
|
532
|
-
{
|
|
533
|
-
test: /\.vue$/,
|
|
534
|
-
resourceQuery: { not: [/type=/] },
|
|
535
|
-
enforce: "post",
|
|
536
|
-
loader: "esbuild-loader",
|
|
537
|
-
options: {
|
|
538
|
-
loader: "ts",
|
|
539
|
-
target: "es2020",
|
|
540
|
-
},
|
|
541
|
-
type: "javascript/auto",
|
|
542
|
-
},
|
|
543
|
-
],
|
|
544
|
-
},
|
|
545
|
-
plugins: [
|
|
546
|
-
new VizePlugin({
|
|
547
|
-
typescript: false,
|
|
548
|
-
}),
|
|
549
|
-
],
|
|
550
|
-
});
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
> Requires `esbuild-loader` and `esbuild` to be installed in your project.
|
|
554
|
-
|
|
555
|
-
</details>
|
|
556
|
-
|
|
557
|
-
The `isTs` option is auto-detected from `<script lang="ts">` and passed to the native compiler for correct parsing.
|
|
558
|
-
|
|
559
|
-
#### `transformAssetUrls`
|
|
560
|
-
|
|
561
|
-
Static asset URLs in template element attributes (e.g. `<img src="./logo.png">`) are automatically rewritten into JavaScript `import` bindings so that Rspack can process them through its asset pipeline.
|
|
562
|
-
|
|
563
|
-
| Value | Behaviour |
|
|
564
|
-
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
565
|
-
| `true` (default) | Apply built-in transforms: `img[src]`, `video[src,poster]`, `source[src]`, `image[xlink:href,href]`, `use[xlink:href,href]` |
|
|
566
|
-
| `false` | Disable the feature entirely — URL strings are left as-is |
|
|
567
|
-
| `Record<string, string[]>` | Custom element/attribute mapping that **replaces** the built-in defaults |
|
|
568
|
-
|
|
569
|
-
Only relative (`./`, `../`), alias (`@/`), and tilde (`~/`, `~pkg`) URLs are transformed. External (`https://…`), protocol-relative (`//…`), and data URIs are left unchanged.
|
|
570
|
-
|
|
571
|
-
```js
|
|
572
|
-
// Custom mapping example
|
|
573
|
-
{
|
|
574
|
-
loader: "@vizejs/rspack-plugin/loader",
|
|
575
|
-
options: {
|
|
576
|
-
transformAssetUrls: {
|
|
577
|
-
"my-image": ["data-src"],
|
|
578
|
-
img: ["src"],
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
}
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
> **Known limitations**
|
|
585
|
-
>
|
|
586
|
-
> - URL rewriting operates via string replacement on the compiled JS output, not on AST nodes. If a `<script>` block contains an identical string literal it will also be replaced (extremely unlikely in practice).
|
|
587
|
-
> - URLs with hash fragments (e.g. `./icons.svg#home`) are split: the base path becomes the `import` specifier and the fragment is concatenated at runtime.
|
|
588
|
-
|
|
589
|
-
### VizeStyleLoader
|
|
590
|
-
|
|
591
|
-
```typescript
|
|
592
|
-
// In rspack.config.js
|
|
593
|
-
{
|
|
594
|
-
loader: "@vizejs/rspack-plugin/style-loader",
|
|
595
|
-
options: {
|
|
596
|
-
native: boolean; // Rspack native CSS mode. Default: true on Rspack 2.x, false on 1.x (1.x also needs experiments: { css: true })
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
```
|
|
600
|
-
|
|
601
|
-
### VizeScopeLoader
|
|
602
|
-
|
|
603
|
-
Applies native scoped CSS transformation using `@vizejs/native compileCss`. Runs **after** preprocessors (SCSS/Less/Stylus → CSS) and **before** css-loader or Rspack native CSS handling. For native CSS, Rspack 1.x needs `experiments.css`, while Rspack 2.x enables it by default.
|
|
604
|
-
|
|
605
|
-
```typescript
|
|
606
|
-
// In rspack.config.js
|
|
607
|
-
{
|
|
608
|
-
loader: "@vizejs/rspack-plugin/scope-loader",
|
|
609
|
-
// No options — scope metadata is extracted from the query string (?scoped=xxxxx)
|
|
610
|
-
}
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
The scope-loader is automatically injected by `VizePlugin` when `autoRules: true` (default). Only needed in manual `oneOf` configurations.
|
|
173
|
+
## Detailed configuration
|
|
174
|
+
|
|
175
|
+
- [Manual `oneOf` rules and style request routing](./docs/manual-rules.md)
|
|
176
|
+
- [Plugin and loader API reference](./docs/api.md)
|
|
177
|
+
- [Migration guide](./MIGRATION.md)
|
|
178
|
+
- [SFC hot updates and browser regression tests](./docs/hmr.md)
|
|
179
|
+
|
|
180
|
+
## Configuration responsibilities
|
|
181
|
+
|
|
182
|
+
Rspack rules select files through `test`, `include`, and `exclude`. SFC and JSX
|
|
183
|
+
loader options configure compilation. `VizePlugin` configures CSS integration,
|
|
184
|
+
automatic rules, TypeScript post-processing, and diagnostic logging.
|
|
185
|
+
|
|
186
|
+
Compilation options on `VizePlugin` are deprecated and are not forwarded to loaders.
|
|
187
|
+
Existing configurations can be updated using the [migration guide](./MIGRATION.md).
|
|
188
|
+
With automatic rules, SFC loader `css.native` must match the plugin's resolved
|
|
189
|
+
CSS mode. With `autoRules: false`, each loader's explicit mode is preserved and
|
|
190
|
+
the plugin supplies a default only where the mode is unspecified. This applies
|
|
191
|
+
to static entries in nested `rules` / `oneOf` as well. Automatic
|
|
192
|
+
style-rule cloning targets the first matching root-level Vue rule without `oneOf`; nested
|
|
193
|
+
configurations must supply their own style routing. Function-valued `use` entries
|
|
194
|
+
are not rewritten; use static entries for plugin-managed CSS configuration.
|
|
195
|
+
|
|
196
|
+
Manual style routing retains control over loader order, preprocessor options,
|
|
197
|
+
CSS Modules, and rule-level parser/generator settings. Match each SFC loader's
|
|
198
|
+
CSS mode to its style sub-request pipeline. Automatic cloning copies the CSS
|
|
199
|
+
loader chain and type; it does not reproduce arbitrary CSS rule conditions or
|
|
200
|
+
parser/generator settings. Use manual routing for those configurations.
|
|
614
201
|
|
|
615
202
|
## License
|
|
616
203
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-ByWFOFCe.mjs";import*as o from"@vizejs/native";import{rewriteSfcTemplateAssetReferences as s}from"@vizejs/native";import c from"node:path";import{createHash as l}from"node:crypto";import{parseSync as u}from"oxc-parser";import{transformSync as d}from"oxc-transform";function f(e,t){return`{
|
|
2
|
+
const current = ${e}
|
|
3
|
+
const next = ${t}
|
|
4
|
+
Object.keys(current).forEach(key => {
|
|
5
|
+
if (!Object.prototype.hasOwnProperty.call(next, key)) delete current[key]
|
|
6
|
+
})
|
|
7
|
+
Object.assign(current, next)
|
|
8
|
+
}`}function p(e,t,n=`null`){return`
|
|
9
|
+
/* hot reload */
|
|
10
|
+
if (module.hot) {
|
|
11
|
+
_sfc_main.__hmrId = "${e}"
|
|
12
|
+
const api = __VUE_HMR_RUNTIME__
|
|
13
|
+
const previous = module.hot.data && module.hot.data.vize
|
|
14
|
+
// Own writable mappings; CSS module namespace exports may be read-only.
|
|
15
|
+
if (_sfc_main.__cssModules) {
|
|
16
|
+
Object.keys(_sfc_main.__cssModules).forEach(name => {
|
|
17
|
+
_sfc_main.__cssModules[name] = Object.assign(Object.create(null), _sfc_main.__cssModules[name])
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
const current = {
|
|
21
|
+
metadata: ${JSON.stringify(t??null)},
|
|
22
|
+
imports: (() => {
|
|
23
|
+
// A circular import may still be uninitialized. An unavailable snapshot
|
|
24
|
+
// disables state preservation without changing module loading semantics.
|
|
25
|
+
try { return ${n} } catch { return null }
|
|
26
|
+
})(),
|
|
27
|
+
component: _sfc_main,
|
|
28
|
+
setup: _sfc_main.setup && _sfc_main.setup.toString()
|
|
29
|
+
}
|
|
30
|
+
module.hot.dispose(data => { data.vize = current })
|
|
31
|
+
module.hot.accept()
|
|
32
|
+
if (!api.createRecord('${e}', _sfc_main)) {
|
|
33
|
+
const before = previous && previous.metadata
|
|
34
|
+
const after = current.metadata
|
|
35
|
+
const sameImports = previous && previous.imports && current.imports &&
|
|
36
|
+
previous.imports.length === current.imports.length &&
|
|
37
|
+
current.imports.every((entry, index) => entry[0] === previous.imports[index][0] && Object.is(entry[1], previous.imports[index][1]))
|
|
38
|
+
const canPreserve = before && after && before.canRerender && after.canRerender &&
|
|
39
|
+
before.source !== after.source &&
|
|
40
|
+
before.options === after.options && before.styles === after.styles && sameImports &&
|
|
41
|
+
previous.setup === current.setup
|
|
42
|
+
if (canPreserve && (before.module === after.module ||
|
|
43
|
+
(typeof before.script === 'string' && before.script === after.script &&
|
|
44
|
+
typeof before.template === 'string' && typeof after.template === 'string' &&
|
|
45
|
+
before.template !== after.template && typeof _sfc_main.render === 'function'))) {
|
|
46
|
+
// Retain both the module table and each mapping captured by setup.
|
|
47
|
+
if (previous.component.__cssModules && _sfc_main.__cssModules) {
|
|
48
|
+
Object.keys(_sfc_main.__cssModules).forEach(name => ${f(`previous.component.__cssModules[name]`,`_sfc_main.__cssModules[name]`)})
|
|
49
|
+
_sfc_main.__cssModules = previous.component.__cssModules
|
|
50
|
+
}
|
|
51
|
+
if (before.module !== after.module || _sfc_main.__cssModules) {
|
|
52
|
+
api.rerender('${e}', _sfc_main.render)
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
api.reload('${e}', _sfc_main)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}`}function m(e,t,n,r){return`
|
|
59
|
+
if (module.hot) {
|
|
60
|
+
module.hot.accept(${t}, () => {
|
|
61
|
+
${f(`_sfc_main.__cssModules[${JSON.stringify(r)}]`,n)}
|
|
62
|
+
__VUE_HMR_RUNTIME__.rerender("${e}", _sfc_main.render)
|
|
63
|
+
})
|
|
64
|
+
}`}const h=`vize-rspack-output.tsx`,g=`_sfc_main`;function _(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function v(e){return typeof e?.start==`number`?e.start:null}function y(e){return _(e)&&typeof e.name==`string`?e.name:null}function b(e){try{let t=u(h,e);if(typeof t==`object`&&t){let e=t.errors;if(Array.isArray(e)&&e.length>0)return null;let n=t.program;if(_(n))return n}return _(t)?t:null}catch{return null}}function x(e){return!e||!Array.isArray(e.body)?[]:e.body.filter(_)}function S(e,t){return y(e)===t}function C(e){return(Array.isArray(e.declarations)?e.declarations:[]).filter(_).map(e=>_(e.id)?y(e.id):null).filter(e=>e!=null)}function w(e){return x(e).find(e=>e.type===`ExportDefaultDeclaration`)??null}function T(e,t){let n=v(t);if(n==null)return null;let r=/^export\s+default\b/.exec(e.slice(n));return r?n+r[0].length:null}function E(e){let t=b(e),n=x(t);return{hasDefaultExport:w(t)!=null,hasSfcMainDefined:n.some(e=>e.type===`VariableDeclaration`&&C(e).includes(g))}}function D(e){let t=d(h,e,{target:`esnext`,jsx:`preserve`});if(t.errors.length)return null;let n=b(t.code);if(!n)return null;let r=[];for(let e of x(n)){if(e.type!==`ImportDeclaration`)continue;let t=_(e.source)?e.source.value:null;if(typeof t!=`string`)return null;if(t===`vue`||t.includes(`?vue&type=style&`))continue;let n=Array.isArray(e.specifiers)?e.specifiers.filter(_):[];if(n.length===0)return null;for(let e of n){let n=_(e.local)?y(e.local):null;if(!n)return null;let i=JSON.stringify(`${t}:${n}`);r.push(e.type===`ImportNamespaceSpecifier`?`...Object.keys(${n}).sort().map(key => [${i} + ':' + key, ${n}[key]])`:`[${i}, ${n}]`)}}return`[${r.join(`, `)}]`}function O(e){let t=e.code,n=w(b(t)),r=v(n),i=n?T(t,n):null;r==null||i==null||e.replace(r,i,`const ${g} =`)}function k(e,t,n={}){let r=e.code,i=w(b(r)),a=_(i?.declaration)?i.declaration:null,o=v(i),s=typeof i?.end==`number`?i.end:null;!S(a,g)||o==null||(n.normalizeSemicolon&&s!=null&&r[s-1]!==`;`&&r[s]!==`;`&&e.replace(s,s,`;`),e.replace(o,o,`${t}\n`))}function A(e,t){return j(e,t).code}function j(e,r){let i=new t(e.code,n(e.map)),a=e.isCustomElement;e.templateAssetUrls.length>0&&i.edit(s(i.code,e.templateAssetUrls));let o=E(i.code),u=o.hasDefaultExport,d=o.hasSfcMainDefined;if(u&&!d?(O(i),e.hasScoped&&e.scopeId&&i.append(`\n_sfc_main.__scopeId = "data-v-${e.scopeId}";`),i.append(`
|
|
65
|
+
export default _sfc_main;`)):u&&d&&e.hasScoped&&e.scopeId&&k(i,`_sfc_main.__scopeId = "data-v-${e.scopeId}";`),e.styles.length>0){if(a&&e.styles.some(e=>e.module))throw Error(`[vize] <style module> is not supported in custom elements mode.`);let t=e.styles.filter(e=>e.module===!0).length;if(t>1)throw Error(`[vize] Found ${t} unnamed <style module> blocks. Only one unnamed <style module> is allowed per SFC. Use named modules instead: <style module="name">`);let n=e.styles.filter(e=>e.src||/\S/.test(e.content)),o=[],s=n.map(t=>{let n=[`vue`,`type=style`,`index=${t.index}`,`lang=${t.lang||`css`}`,...t.scoped?[`scoped=${e.scopeId}`]:[],...t.module?[`module=${typeof t.module==`string`?t.module:`true`}`]:[],...a?[`inline`]:[]],i=`${r.requestPath}?${n.join(`&`)}`;if(a)return`import _style_${t.index} from ${JSON.stringify(i)};`;if(t.module){let e=typeof t.module==`string`?t.module:`$style`,n=`_cssModule_${t.index}`;return o.push({request:i,varName:n,bindingName:e}),`import * as ${n} from ${JSON.stringify(i)};`}return`import ${JSON.stringify(i)};`}).join(`
|
|
66
|
+
`);i.prepend(`${s}\n`),a&&k(i,`_sfc_main.styles = [${n.map(e=>`_style_${e.index}`).join(`,`)}];`,{normalizeSemicolon:!0}),!a&&o.length>0&&k(i,`${[r.nativeCss?``:`const __vize_resolve_css_module__ = (value) => value.default && typeof value.default === "object" ? value.default : value;`,...o.map(e=>`_sfc_main.__cssModules = _sfc_main.__cssModules || {};\n_sfc_main.__cssModules[${JSON.stringify(e.bindingName)}] = ${r.nativeCss?e.varName:`__vize_resolve_css_module__(${e.varName})`};`)].filter(Boolean).join(`
|
|
67
|
+
`)}\n${r.hmr&&e.scopeId?o.map(t=>m(e.scopeId,JSON.stringify(t.request),r.nativeCss?t.varName:`__vize_resolve_css_module__(${t.varName})`,t.bindingName)).join(`
|
|
68
|
+
`):``}`,{normalizeSemicolon:!0})}if(r.filePath&&!r.isProduction){let e=r.rootContext?c.relative(r.rootContext,r.filePath).replace(/\\/g,`/`):c.basename(r.filePath);k(i,`_sfc_main.__file = ${JSON.stringify(e)};`,{normalizeSemicolon:!0})}if(e.customBlocks.length>0&&k(i,e.customBlocks.map((e,t)=>{let n=[`vue`,`type=${e.type}`,`index=${t}`,...e.src?[`src=true`]:[]];for(let[t,r]of Object.entries(e.attrs))t!==`src`&&(r===!0?n.push(t):n.push(`${t}=${r}`));let i=`${r.requestPath}?${n.join(`&`)}`;return`import block${t} from ${JSON.stringify(i)};\nif (typeof block${t} === 'function') block${t}(_sfc_main);`}).join(`
|
|
69
|
+
`),{normalizeSemicolon:!0}),e.templateAssetUrls.length>0){let t=e.templateAssetUrls.map(({url:e,varName:t})=>{let n=e.startsWith(`~`)?e.slice(1):e,r=n.indexOf(`#`);return r>=0&&(n=n.slice(0,r)),`import ${t} from ${JSON.stringify(n)};`}).join(`
|
|
70
|
+
`);i.prepend(`${t}\n`)}if(r.hmr&&e.scopeId){let t=e.hmr&&{...e.hmr,module:l(`sha256`).update(i.code).digest(`hex`).slice(0,16),styles:JSON.stringify({scoped:e.hasScoped,blocks:e.styles.map(({content:e,...t})=>({...t,active:!!(t.src||/\S/.test(e))}))})};k(i,p(e.scopeId,t,D(i.code)??`null`),{normalizeSemicolon:!0})}return{code:i.code,map:i.map}}const{compileSfc:M}=o,{compileJsx:N}=o;function P(e){return e.endsWith(`.jsx`)||e.endsWith(`.tsx`)}function F(e,t,n){return`
|
|
71
|
+
export const __vize_css__ = ${JSON.stringify(t)};
|
|
72
|
+
const __vize_css_id__ = ${JSON.stringify(`vize-style-${n}`)};
|
|
73
|
+
(function() {
|
|
74
|
+
if (typeof document !== "undefined") {
|
|
75
|
+
let style = document.getElementById(__vize_css_id__);
|
|
76
|
+
if (!style) {
|
|
77
|
+
style = document.createElement("style");
|
|
78
|
+
style.id = __vize_css_id__;
|
|
79
|
+
style.textContent = __vize_css__;
|
|
80
|
+
document.head.appendChild(style);
|
|
81
|
+
} else {
|
|
82
|
+
style.textContent = __vize_css__;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
})();
|
|
86
|
+
${e}`}function I(e,t,n={}){let r=N(t,{filename:e,lang:e.endsWith(`.tsx`)?`tsx`:`jsx`,jsxMode:n.jsxMode,jsxCompat:n.jsxCompat,vapor:n.vapor??!1,sourceMap:n.sourceMap??!1});if(r.errors.length>0)throw Error(`[vize] Compilation failed for ${e}:\n${r.errors.join(`
|
|
87
|
+
`)}`);let i=(r.scopedStyles??[]).map(e=>e.css).join(`
|
|
88
|
+
`),a=r.code,o=r.map??null;if(i){let e=r.scopedStyles[0].scopeId.replace(/^data-v-/,``);a=F(a,i,e),o=null}return{code:a,map:o,warnings:r.warnings}}const L=new Map;function R(e){return l(`sha256`).update(e).digest(`hex`).slice(0,16)}function z(){L.clear()}function B(t,n,o={}){let s=o.compilerOptions?.isTs??/<script[^>]*\blang=["']ts["']/.test(n),c=o.ssr??o.compilerOptions?.ssr??!1,l=o.vapor??o.compilerOptions?.vapor??!1,u=o.sourceMap??o.compilerOptions?.sourceMap??!0,d=o.isCustomElement??!1,f=o.rootContext??``,p=o.isProduction??!1,m=o.transformAssetUrls??!0,h=`${t}:ssr=${c}:vapor=${l}:ts=${s}:map=${u}:ce=${d}:syntax=${o.compilerOptions?.templateSyntax??`standard`}:xic=${o.compilerOptions?.experimentalInTagComments??!1}:xpt=${o.compilerOptions?.experimentalPatternedTemplate??!1}:xsc=${o.compilerOptions?.experimentalSelfComponent??!1}:xslot=${o.compilerOptions?.experimentalStrictSlotChildren??!1}:xss=${o.compilerOptions?.experimentalServerScript??!1}:root=${f}:prod=${p}:${m===!1?`tau=false`:m===!0?`tau=true`:`tau=${JSON.stringify(m)}`}`,g=R(n),_=L.get(h);if(_&&_.contentHash===g)return _.result;let v=i(t,o.rootContext,o.isProduction,n),y={...o.compilerOptions,filename:t,sourceMap:o.sourceMap??o.compilerOptions?.sourceMap??!0,ssr:c,vapor:l,isTs:s,scopeId:`data-v-${v}`},b=M(n,y),x=r(n,m),S={code:b.code,hmr:{source:g,script:b.scriptHash,template:b.templateHash,options:R(JSON.stringify(y)),canRerender:!l&&!c&&!d&&b.customBlocks.length===0},...b.map?{map:b.map}:{},css:b.css,errors:b.errors,warnings:b.warnings,scopeId:v,hasScoped:b.hasScoped,styles:b.styles.map(e),customBlocks:b.customBlocks.map(a),isCustomElement:d,templateAssetUrls:x,macroArtifacts:b.macroArtifacts??[]};return S.errors.length===0&&L.set(h,{contentHash:g,result:S}),S}export{A as a,P as i,B as n,j as o,I as r,p as s,z as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/types/
|
|
2
|
-
/**
|
|
1
|
+
//#region src/types/native.d.ts
|
|
2
|
+
/** Native compiler API types used by the Rspack adapter. */
|
|
3
3
|
interface SfcCompileOptionsNapi {
|
|
4
4
|
filename?: string;
|
|
5
5
|
sourceMap?: boolean;
|
|
@@ -49,7 +49,7 @@ interface MacroArtifact {
|
|
|
49
49
|
interface SfcCompileResultNapi {
|
|
50
50
|
code: string;
|
|
51
51
|
css?: string;
|
|
52
|
-
/** Source map JSON
|
|
52
|
+
/** Source map v3 JSON when requested from the native compiler. */
|
|
53
53
|
map?: string;
|
|
54
54
|
errors: string[];
|
|
55
55
|
warnings: string[];
|
|
@@ -108,6 +108,8 @@ interface JsxCompileResultNapi {
|
|
|
108
108
|
*/
|
|
109
109
|
scopedStyles: JsxScopedStyleNapi[];
|
|
110
110
|
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/types/index.d.ts
|
|
111
113
|
interface StyleBlockInfo {
|
|
112
114
|
/** Raw style content */
|
|
113
115
|
content: string;
|
|
@@ -149,6 +151,16 @@ interface TemplateAssetUrl {
|
|
|
149
151
|
}
|
|
150
152
|
interface CompiledModule {
|
|
151
153
|
code: string;
|
|
154
|
+
/** Per-source metadata for browser-local HMR comparisons. */
|
|
155
|
+
hmr?: {
|
|
156
|
+
source: string;
|
|
157
|
+
script?: string;
|
|
158
|
+
template?: string;
|
|
159
|
+
options: string;
|
|
160
|
+
canRerender: boolean;
|
|
161
|
+
};
|
|
162
|
+
/** Source map v3 JSON for the native module, before output assembly. */
|
|
163
|
+
map?: string;
|
|
152
164
|
css?: string;
|
|
153
165
|
errors: string[];
|
|
154
166
|
warnings: string[];
|
|
@@ -165,19 +177,28 @@ interface CompiledModule {
|
|
|
165
177
|
/** Compile-time macro artifacts extracted from the source SFC. */
|
|
166
178
|
macroArtifacts?: MacroArtifact[];
|
|
167
179
|
}
|
|
180
|
+
/** Native options with loader-level aliases retained for existing configurations. */
|
|
181
|
+
type VizeSfcCompilerOptions = Omit<SfcCompileOptionsNapi, "ssr" | "vapor" | "sourceMap"> & {
|
|
182
|
+
/** @deprecated Use the SFC loader's top-level ssr option. */ssr?: boolean; /** @deprecated Use the SFC loader's top-level vapor option. */
|
|
183
|
+
vapor?: boolean; /** @deprecated Use the SFC loader's top-level sourceMap option. */
|
|
184
|
+
sourceMap?: boolean;
|
|
185
|
+
};
|
|
186
|
+
/** Compatibility type; prefer VizeSfcLoaderOptions or VizeJsxLoaderOptions. */
|
|
168
187
|
interface VizeLoaderOptions {
|
|
169
|
-
/**
|
|
188
|
+
/** Override production output; otherwise follows loader mode / NODE_ENV. */
|
|
189
|
+
isProduction?: boolean;
|
|
190
|
+
/** Source maps; falls back to compilerOptions, then Rspack's loader context. */
|
|
170
191
|
sourceMap?: boolean;
|
|
171
192
|
/** SSR mode @default false */
|
|
172
193
|
ssr?: boolean;
|
|
173
194
|
/** Project root */
|
|
174
195
|
root?: string;
|
|
175
|
-
/**
|
|
196
|
+
/** @deprecated Use module.rules[].include. Retained as a loader passthrough filter. */
|
|
176
197
|
include?: string | RegExp | (string | RegExp)[];
|
|
177
|
-
/**
|
|
198
|
+
/** @deprecated Use module.rules[].exclude. Retained as a loader passthrough filter. */
|
|
178
199
|
exclude?: string | RegExp | (string | RegExp)[];
|
|
179
200
|
/** Low-level compiler options for @vizejs/native compileSfc */
|
|
180
|
-
compilerOptions?:
|
|
201
|
+
compilerOptions?: VizeSfcCompilerOptions;
|
|
181
202
|
/** Custom element mode. true=all, RegExp=matched. @default /\.ce\.vue$/ */
|
|
182
203
|
customElement?: boolean | RegExp;
|
|
183
204
|
/** Vapor mode @default false */
|
|
@@ -190,7 +211,9 @@ interface VizeLoaderOptions {
|
|
|
190
211
|
hotReload?: boolean;
|
|
191
212
|
/** CSS handling config */
|
|
192
213
|
css?: {
|
|
193
|
-
/**
|
|
214
|
+
/** With autoRules: false, override the plugin default for this SFC chain.
|
|
215
|
+
* With automatic rules, must match the plugin's resolved CSS mode. */
|
|
216
|
+
native?: boolean;
|
|
194
217
|
};
|
|
195
218
|
/**
|
|
196
219
|
* Transform static asset URLs in templates into import bindings.
|
|
@@ -198,34 +221,40 @@ interface VizeLoaderOptions {
|
|
|
198
221
|
*/
|
|
199
222
|
transformAssetUrls?: boolean | Record<string, string[]>;
|
|
200
223
|
}
|
|
224
|
+
/** Options accepted by the SFC loader. JSX compilation uses a separate loader. */
|
|
225
|
+
type VizeSfcLoaderOptions = Omit<VizeLoaderOptions, "jsxMode" | "jsxCompat">;
|
|
226
|
+
/** Options accepted by the JSX/TSX loader. */
|
|
227
|
+
type VizeJsxLoaderOptions = Pick<VizeLoaderOptions, "sourceMap" | "vapor" | "jsxMode" | "jsxCompat" | "include" | "exclude">;
|
|
201
228
|
interface VizeStyleLoaderOptions {
|
|
202
229
|
/** Rspack native CSS mode @default false */
|
|
203
230
|
native?: boolean;
|
|
204
231
|
}
|
|
205
232
|
interface VizeRspackPluginOptions {
|
|
206
|
-
/**
|
|
233
|
+
/** @deprecated Use rule.include. This legacy field only filters plugin watch logs. */
|
|
207
234
|
include?: string | RegExp | (string | RegExp)[];
|
|
208
|
-
/**
|
|
235
|
+
/** @deprecated Use rule.exclude. This legacy field only filters plugin watch logs. */
|
|
209
236
|
exclude?: string | RegExp | (string | RegExp)[];
|
|
210
|
-
/**
|
|
237
|
+
/** @deprecated Use Rspack mode. Retained for plugin flags/logging only. */
|
|
211
238
|
isProduction?: boolean;
|
|
212
|
-
/**
|
|
239
|
+
/** @deprecated Use SFC loader ssr. This plugin field is not forwarded. */
|
|
213
240
|
ssr?: boolean;
|
|
214
|
-
/**
|
|
241
|
+
/** @deprecated Use loader sourceMap. This plugin field is not forwarded. */
|
|
215
242
|
sourceMap?: boolean;
|
|
216
|
-
/**
|
|
243
|
+
/** @deprecated Use loader vapor. This plugin field only affects the legacy debug message. */
|
|
217
244
|
vapor?: boolean;
|
|
218
|
-
/**
|
|
245
|
+
/** @deprecated Use JSX loader jsxMode. This plugin field is not forwarded. */
|
|
219
246
|
jsxMode?: "vdom" | "vapor";
|
|
220
|
-
/** JSX
|
|
247
|
+
/** @deprecated Use JSX loader jsxCompat. This plugin field is not forwarded. */
|
|
221
248
|
jsxCompat?: "native" | "babel";
|
|
222
|
-
/**
|
|
249
|
+
/** @deprecated Use loader root or Rspack context. This plugin field is not forwarded. */
|
|
223
250
|
root?: string;
|
|
224
251
|
/** CSS config */
|
|
225
252
|
css?: {
|
|
226
|
-
/**
|
|
253
|
+
/** Automatic CSS mode, or default for manual SFC rules. Auto-detected from
|
|
254
|
+
* the Rspack version and experiments.css when omitted. */
|
|
255
|
+
native?: boolean;
|
|
227
256
|
};
|
|
228
|
-
/**
|
|
257
|
+
/** @deprecated Use SFC loader compilerOptions. This plugin field is not forwarded. */
|
|
229
258
|
compilerOptions?: SfcCompileOptionsNapi;
|
|
230
259
|
/** Debug logging @default false */
|
|
231
260
|
debug?: boolean;
|
|
@@ -245,4 +274,4 @@ type LoaderEntry = string | {
|
|
|
245
274
|
options?: Record<string, unknown>;
|
|
246
275
|
};
|
|
247
276
|
//#endregion
|
|
248
|
-
export {
|
|
277
|
+
export { StyleBlockInfo as a, VizeRspackPluginOptions as c, VizeStyleLoaderOptions as d, JsxCompileOptionsNapi as f, SfcCompileResultNapi as g, SfcCompileOptionsNapi as h, SfcSrcInfo as i, VizeSfcCompilerOptions as l, MacroArtifact as m, CustomBlockInfo as n, VizeJsxLoaderOptions as o, JsxCompileResultNapi as p, LoaderEntry as r, VizeLoaderOptions as s, CompiledModule as t, VizeSfcLoaderOptions as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as StyleBlockInfo, c as VizeRspackPluginOptions, d as VizeStyleLoaderOptions, f as JsxCompileOptionsNapi, g as SfcCompileResultNapi, h as SfcCompileOptionsNapi, i as SfcSrcInfo, l as VizeSfcCompilerOptions, m as MacroArtifact, n as CustomBlockInfo, o as VizeJsxLoaderOptions, p as JsxCompileResultNapi, r as LoaderEntry, s as VizeLoaderOptions, t as CompiledModule, u as VizeSfcLoaderOptions } from "./index-Cg474czL.mjs";
|
|
2
2
|
import vizeLoader from "./loader/index.mjs";
|
|
3
3
|
import vizeJsxLoader from "./loader/jsx-loader.mjs";
|
|
4
4
|
import vizeStyleLoader from "./loader/style-loader.mjs";
|
|
5
5
|
import vizeScopeLoader from "./loader/scope-loader.mjs";
|
|
6
|
-
import { Compiler, RuleSetRule } from "@rspack/core";
|
|
6
|
+
import { Compiler, RuleSetRule, sources } from "@rspack/core";
|
|
7
7
|
|
|
8
8
|
//#region src/plugin/index.d.ts
|
|
9
9
|
declare class VizePlugin {
|
|
@@ -46,19 +46,34 @@ declare function matchesPattern(file: string, pattern: string | RegExp | (string
|
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/shared/hotReload.d.ts
|
|
48
48
|
/** HMR code generation for Vue SFCs using `module.hot` (Rspack/webpack CJS API). */
|
|
49
|
+
interface HmrMetadata {
|
|
50
|
+
source: string;
|
|
51
|
+
script?: string;
|
|
52
|
+
template?: string;
|
|
53
|
+
options: string;
|
|
54
|
+
canRerender: boolean;
|
|
55
|
+
module: string;
|
|
56
|
+
styles: string;
|
|
57
|
+
}
|
|
49
58
|
/** Generate `module.hot` HMR boilerplate for a Vue SFC. */
|
|
50
|
-
declare function genHotReloadCode(id: string): string;
|
|
59
|
+
declare function genHotReloadCode(id: string, metadata?: HmrMetadata, imports?: string): string;
|
|
51
60
|
//#endregion
|
|
52
61
|
//#region src/shared/output.d.ts
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
hmr?: boolean;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
interface GenerateOutputOptions {
|
|
63
|
+
requestPath: string;
|
|
64
|
+
/** Inject HMR boilerplate using `module.hot` (Rspack/webpack CJS API) */
|
|
65
|
+
hmr?: boolean;
|
|
66
|
+
/** Original file path (for __file exposure in dev mode) */
|
|
67
|
+
filePath?: string;
|
|
68
|
+
/** Whether this is a production build */
|
|
69
|
+
isProduction?: boolean;
|
|
70
|
+
/** Project root context (for computing relative __file path) */
|
|
71
|
+
rootContext?: string;
|
|
72
|
+
/** Whether Rspack native CSS is handling CSS module exports */
|
|
60
73
|
nativeCss?: boolean;
|
|
61
|
-
}
|
|
74
|
+
}
|
|
75
|
+
/** Generate JS output with style/custom-block imports and optional HMR code. */
|
|
76
|
+
declare function generateOutput(compiled: CompiledModule, options: GenerateOutputOptions): string;
|
|
62
77
|
//#endregion
|
|
63
78
|
//#region src/shared/compiler.d.ts
|
|
64
79
|
/** `.jsx`/`.tsx` Vue components routed to the native JSX compiler. */
|
|
@@ -94,4 +109,4 @@ declare function compileFile(filePath: string, source: string, options?: {
|
|
|
94
109
|
transformAssetUrls?: boolean | Record<string, string[]>;
|
|
95
110
|
}): CompiledModule;
|
|
96
111
|
//#endregion
|
|
97
|
-
export { type CompiledModule, type CustomBlockInfo, type JsxCompileOptionsNapi, type JsxCompileResultNapi, type LoaderEntry, type MacroArtifact, type RuleCloningResult, type SfcCompileOptionsNapi, type SfcCompileResultNapi, type SfcSrcInfo, type StyleBlockInfo, type VizeLoaderOptions, VizePlugin, type VizeRspackPluginOptions, type VizeStyleLoaderOptions, addScopeToCssFallback, applyRuleCloning, clearCompilationCache, compileFile, compileJsxModule, extractCustomBlocks, extractSrcInfo, extractStyleBlocks, genHotReloadCode, generateOutput, generateScopeId, inlineSrcBlocks, isJsxFile, matchesPattern, vizeJsxLoader, vizeLoader, vizeScopeLoader, vizeStyleLoader };
|
|
112
|
+
export { type CompiledModule, type CustomBlockInfo, type JsxCompileOptionsNapi, type JsxCompileResultNapi, type LoaderEntry, type MacroArtifact, type RuleCloningResult, type SfcCompileOptionsNapi, type SfcCompileResultNapi, type SfcSrcInfo, type StyleBlockInfo, type VizeJsxLoaderOptions, type VizeLoaderOptions, VizePlugin, type VizeRspackPluginOptions, type VizeSfcCompilerOptions, type VizeSfcLoaderOptions, type VizeStyleLoaderOptions, addScopeToCssFallback, applyRuleCloning, clearCompilationCache, compileFile, compileJsxModule, extractCustomBlocks, extractSrcInfo, extractStyleBlocks, genHotReloadCode, generateOutput, generateScopeId, inlineSrcBlocks, isJsxFile, matchesPattern, vizeJsxLoader, vizeLoader, vizeScopeLoader, vizeStyleLoader };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,o as r,r as i,s as a,t as o}from"./utils-
|
|
1
|
+
import{a as e,c as t,i as n,o as r,r as i,s as a,t as o}from"./utils-ByWFOFCe.mjs";import{n as s,r as c,t as l}from"./loader-Cw4_LSPf.mjs";import{a as u,i as d,n as f,r as p,s as m,t as h}from"./compiler-Bvvgv3Cz.mjs";import g from"./loader/jsx-loader.mjs";import _ from"./loader/style-loader.mjs";import v from"./loader/scope-loader.mjs";import{createRequire as y}from"node:module";import{parse as b}from"node:querystring";const x=`@vizejs/rspack-plugin/loader`;let S;try{S=y(import.meta.url).resolve(x).replaceAll(`\\`,`/`)}catch{}function C(e){let t=e.replaceAll(`\\`,`/`);return e===x||t===S||(t.includes(`@vizejs/rspack-plugin/`)||t.includes(`rspack-vize-plugin/`))&&/\/dist\/loader\/index\.[cm]?js$/.test(t)}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`string`?e.startsWith(`{`)&&e.endsWith(`}`)?JSON.parse(e):b(e):w(e)?e:{}}function E(e,t,n=!0){function r(e){if(typeof e.loader!=`string`||!C(e.loader))return;let r=T(e.options),i=w(r.css)?r.css:{};if(i.native!==void 0){if(!n)return;if(i.native!==t)throw Error(`[vize] Loader css.native conflicts with VizePlugin's automatic CSS mode. Configure a matching mode on VizePlugin, or set autoRules: false and provide matching style sub-request rules. See MIGRATION.md.`)}e.options={...r,css:{...i,native:t}}}function i(e){if(typeof e==`string`&&C(e)){let t={loader:e};return r(t),t}return w(e)&&r(e),e}function a(e){for(let t of e)w(t)&&(r(t),Array.isArray(t.use)?t.use=t.use.map(i):t.use!==void 0&&typeof t.use!=`function`&&(t.use=i(t.use)),Array.isArray(t.oneOf)&&a(t.oneOf),Array.isArray(t.rules)&&a(t.rules))}a(e)}const D=`@vizejs/rspack-plugin/style-loader`,O=`@vizejs/rspack-plugin/scope-loader`,k={"\\.css$":`css`,"\\.scss$":`scss`,"\\.sass$":`sass`,"\\.less$":`less`,"\\.styl(us)?$":`styl`};function A(e,t){let n=[],r=e.findIndex(e=>e!==`...`&&j(e));if(r===-1)return{applied:!1,clonedCount:0,warnings:n};let i=e[r];if(i.oneOf)return{applied:!1,clonedCount:0,warnings:n};let a=[];for(let t=0;t<e.length;t++){if(t===r)continue;let n=e[t];if(n===`...`)continue;let i=N(n);i&&a.push({index:t,rule:n,lang:i})}let o=[];for(let e of a)o.push(...P(e.rule,e.lang,t));o.some(e=>e.resourceQuery instanceof RegExp&&e.resourceQuery.test(`vue&type=style&index=0&lang=css`))||o.push(...F(t));let{test:s,include:c,exclude:l,resource:u,descriptionData:d,...f}=i,p={...f,loader:void 0,options:void 0,use:z(R(i))};E([p],t);for(let e of o)e.sideEffects=!0;e[r]={test:s,include:c,exclude:l,resource:u,descriptionData:d,oneOf:[...o,p]};for(let e of a)I(e.rule);return{applied:!0,clonedCount:o.length,warnings:n}}function j(e){return M(e.test)?R(e).some(e=>{let t=typeof e==`string`?e:e.loader;return t?C(t):!1}):!1}function M(e){return e?e instanceof RegExp?e.test(`App.vue`)||e.test(`foo.vue`):typeof e==`string`?e.includes(`.vue`):!1:!1}function N(e){let t=e.test;if(!t||!(t instanceof RegExp))return null;let n=t.source;for(let[e,t]of Object.entries(k))if(n.includes(e)||n===e)return t;return t.test(`foo.css`)&&!t.test(`foo.vue`)?`css`:t.test(`foo.scss`)&&!t.test(`foo.vue`)?`scss`:t.test(`foo.sass`)&&!t.test(`foo.vue`)?`sass`:t.test(`foo.less`)&&!t.test(`foo.vue`)?`less`:t.test(`foo.styl`)&&!t.test(`foo.vue`)?`styl`:null}function P(e,t,n){let r=R(e);if(r.length===0)return[];let i=z(r),a=n?-1:i.findIndex(e=>{let t=typeof e==`string`?e:e.loader;return/(?:^|[/\\])css-loader(?:[/\\?]|$)/.test(t??``)});i.splice(a+1,0,{loader:O}),i.push({loader:D});let o=(t,n)=>{let r={resourceQuery:t,use:z(i)};return e.type?r.type=e.type:n&&(r.type=n),r};return n?[o(RegExp(`(?=.*type=style)(?=.*lang=${t})(?=.*module=)`),`css/module`),o(RegExp(`(?=.*type=style)(?=.*lang=${t})`),`css/auto`)]:[o(RegExp(`(?=.*type=style)(?=.*lang=${t})`))]}function F(e){return e?[{resourceQuery:/(?=.*type=style)(?=.*lang=css)(?=.*module=)/,type:`css/module`,use:[{loader:O},{loader:D}]},{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`css/auto`,use:[{loader:O},{loader:D}]}]:[{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`javascript/auto`,use:[{loader:O},{loader:D}]}]}function I(e){let t=e.resourceQuery;if(t)return typeof t==`object`&&!Array.isArray(t)&&!(t instanceof RegExp)&&`not`in t,void 0;e.resourceQuery={not:[/vue/]}}function L(e){return e?Array.isArray(e)?e:[e]:[]}function R(e){let t=L(e.use);if(t.length>0)return t;let n=e.loader;if(n){let t=e.options;return t?[{loader:n,options:t}]:[n]}return[]}function z(e){return e.map(e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t={...e};return`options`in e&&e.options&&typeof e.options==`object`&&(t.options={...e.options}),t}return e})}var B=class e{static name=`VizePlugin`;options;constructor(e={}){this.options=e}apply(t){let n=t.getInfrastructureLogger(e.name),r=this.options.isProduction??t.options.mode===`production`,i=[`include`,`exclude`,`isProduction`,`ssr`,`sourceMap`,`vapor`,`jsxMode`,`jsxCompat`,`root`,`compilerOptions`].filter(e=>this.options[e]!==void 0);i.length>0&&n.warn(`Deprecated VizePlugin options: ${i.join(`, `)}. Compilation options belong in loader options; file filters belong in module.rules. Legacy plugin behavior is unchanged: compilation options are not forwarded. See MIGRATION.md.`),this.options.debug&&this.options.vapor&&!r&&n.debug(`Legacy plugin vapor is set; configure vapor on the loader to select compilation mode.`);let a=s(t.options),o=t.webpack?.rspackVersion,l=c(this.options.css?.native,t.options,o);this.options.css?.native&&a===`disabled`&&n.warn("`css.native: true` is set but `experiments.css` is not enabled in rspack config.");let u=t.options.module?.rules,d=this.options.autoRules??!0;if(u&&E(u,l,d),d){let e=t.options.module?.rules;if(e){let t=A(e,l);t.applied&&this.options.debug&&n.debug(`Auto-injected ${t.clonedCount} style rule(s) for Vue SFC sub-requests.`);for(let e of t.warnings)n.warn(e)}}if(this.options.typescript??!0){let e=t.options.module?.rules;e&&(e.some(e=>{if(e===`...`||typeof e!=`object`||!e)return!1;let t=e;if(t.enforce!==`post`)return!1;let n=t.test;return n instanceof RegExp?n.test(`App.vue`):typeof n==`string`?n.includes(`.vue`):!1})||(e.push({test:/\.vue$/,resourceQuery:{not:[/type=/]},enforce:`post`,loader:`builtin:swc-loader`,options:{jsc:{parser:{syntax:`typescript`}}},type:`javascript/auto`}),this.options.debug&&n.debug(`Auto-injected TypeScript post-processing rule for .vue files.`)))}let{DefinePlugin:f}=t.webpack,p=new Set;for(let e of t.options.plugins??[]){let t=e?.definitions;if(t)for(let e of Object.keys(t))p.add(e)}let m={};p.has(`__VUE_OPTIONS_API__`)||(m.__VUE_OPTIONS_API__=JSON.stringify(!0)),p.has(`__VUE_PROD_DEVTOOLS__`)||(m.__VUE_PROD_DEVTOOLS__=JSON.stringify(!r)),p.has(`__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`)||(m.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=JSON.stringify(!r)),Object.keys(m).length>0&&new f(m).apply(t),this.options.debug&&!r&&t.hooks.watchRun.tap(e.name,e=>{let t=e.modifiedFiles,r=e.removedFiles;if(t)for(let e of t)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file changed: ${e}`);if(r)for(let e of r)e.endsWith(`.vue`)&&this.shouldHandleFile(e)&&n.debug(`Vue file removed: ${e}`)})}shouldHandleFile(e){return!(!t(e,this.options.include,!0)||t(e,this.options.exclude,!1))}};export{B as VizePlugin,o as addScopeToCssFallback,A as applyRuleCloning,h as clearCompilationCache,f as compileFile,p as compileJsxModule,i as extractCustomBlocks,n as extractSrcInfo,e as extractStyleBlocks,m as genHotReloadCode,u as generateOutput,r as generateScopeId,a as inlineSrcBlocks,d as isJsxFile,t as matchesPattern,g as vizeJsxLoader,l as vizeLoader,v as vizeScopeLoader,_ as vizeStyleLoader};
|
package/dist/loader/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as VizeSfcLoaderOptions } from "../index-Cg474czL.mjs";
|
|
2
2
|
import { LoaderContext } from "@rspack/core";
|
|
3
3
|
|
|
4
4
|
//#region src/loader/index.d.ts
|
|
5
|
-
declare function vizeLoader(this: LoaderContext<
|
|
5
|
+
declare function vizeLoader(this: LoaderContext<VizeSfcLoaderOptions>, source: string): void;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { vizeLoader as default };
|
package/dist/loader/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../loader-
|
|
1
|
+
import{t as e}from"../loader-Cw4_LSPf.mjs";export{e as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as VizeJsxLoaderOptions } from "../index-Cg474czL.mjs";
|
|
2
2
|
import { LoaderContext } from "@rspack/core";
|
|
3
3
|
|
|
4
4
|
//#region src/loader/jsx-loader.d.ts
|
|
5
|
-
declare function vizeJsxLoader(this: LoaderContext<
|
|
5
|
+
declare function vizeJsxLoader(this: LoaderContext<VizeJsxLoaderOptions>, source: string): void;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { vizeJsxLoader as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"../utils-
|
|
1
|
+
import{c as e,m as t}from"../utils-ByWFOFCe.mjs";import{r as n}from"../compiler-Bvvgv3Cz.mjs";function r(e){let r=this.async(),a=this.getOptions(),o=this.resourcePath;if(this.addDependency(o),!i(o,a)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${o}. Passing through source unchanged.`)),r(null,e);return}try{let i=this.mode===`production`||process.env.NODE_ENV===`production`,s=a.sourceMap??this.sourceMap??!i,{code:c,map:l,warnings:u}=n(o,e,{jsxMode:a.jsxMode,jsxCompat:a.jsxCompat,vapor:a.vapor??!1,sourceMap:s});for(let e of u)this.emitWarning(Error(`[vize] ${e}`));r(null,c,t(l)?l:void 0)}catch(e){r(e)}}function i(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"../utils-
|
|
1
|
+
import{l as e}from"../utils-ByWFOFCe.mjs";import*as t from"@vizejs/native";const{compileCss:n}=t;function r(t){let r=this.async(),{resourceQuery:i,resourcePath:a}=this;if(!i){r(null,t);return}let o=new URLSearchParams(i.slice(1)).get(`scoped`);if(!o){r(null,t);return}let s=`data-v-${o}`,c=n(e(t),{filename:a,scoped:!0,scopeId:s});for(let e of c.errors)this.emitError(Error(`[vize] ${e}`));for(let e of c.warnings)this.emitWarning(Error(`[vize] ${e}`));r(null,c.code)}export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"../utils-
|
|
1
|
+
import{a as e}from"../utils-ByWFOFCe.mjs";import t from"node:path";import n from"node:fs/promises";function r(r){let i=this.async(),{resourceQuery:a,resourcePath:o}=this;if(!a){i(null,r);return}let s=new URLSearchParams(a.slice(1));if(s.get(`type`)!==`style`){i(null,r);return}let c=parseInt(s.get(`index`)||`0`,10);this.addDependency(o);let l=e(r)[c];if(!l){this.hot||this.emitError(Error(`[vize] Style block at index ${c} not found in ${o}`)),i(null,``);return}if(l.src){let e=t.resolve(t.dirname(o),l.src);this.addDependency(e),n.readFile(e,`utf-8`).then(e=>{i(null,e)}).catch(()=>{this.emitWarning(Error(`[vize] <style src> target not found: ${l.src} (resolved: ${e}) in ${o}`)),i(null,``)});return}i(null,l.content)}export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,f as t,i as n,p as r,r as i}from"./utils-ByWFOFCe.mjs";import{n as a,o}from"./compiler-Bvvgv3Cz.mjs";import{sources as s}from"@rspack/core";import c from"node:fs";import l from"node:path";function u(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function d(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function f(e,t,n){if(e!=null)return e;let r=u(t);if(r!==`unavailable`)return r===`enabled`;let i=d(n);return i!=null&&i>=2}const p=/\.ce\.vue$/;function m(e){let u=this.async(),d=this.getOptions(),f=this.resourcePath,p=this.resourceQuery,m=v(this,f),y=d.isProduction??(this.mode===`production`||process.env.NODE_ENV===`production`),b=d.ssr??d.compilerOptions?.ssr??!1,x=!b&&!y&&d.hotReload!==!1,S=g(this,d),C=d.sourceMap??d.compilerOptions?.sourceMap??this.sourceMap??!y;if(this.addDependency(f),p?.includes(`type=style`)){u(Error(`[vize] Main loader received style sub-request: ${f}${p}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(p&&p.includes(`vue`)&&p.includes(`type=`)&&!p.includes(`type=style`)){let t=new URLSearchParams(p.slice(1)),n=t.get(`type`);if(n&&n!==`style`){let r=parseInt(t.get(`index`)||`0`,10),a=i(e)[r];if(a){if(a.src){let e=l.resolve(l.dirname(f),a.src);this.addDependency(e);try{u(null,c.readFileSync(e,`utf-8`))}catch{u(Error(`[vize] Custom block <${n} src="${a.src}"> not found (resolved: ${e}) in ${f}`))}return}u(null,a.content)}else u(null,``);return}}if(!h(f,d)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${f}. Passing through source unchanged.`)),u(null,e);return}try{let i=_(f,d.customElement),p=n(e),h=new t(e,C&&(p.scriptSrc||p.templateSrc)?new s.OriginalSource(e,f).map({columns:!0}):null);if(p.scriptSrc){let e=l.resolve(l.dirname(f),p.scriptSrc);this.addDependency(e);try{r(h,`script`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <script src="${p.scriptSrc}"> not found (resolved: ${e}) in ${f}`));return}}if(p.templateSrc){let e=l.resolve(l.dirname(f),p.templateSrc);this.addDependency(e);try{r(h,`template`,c.readFileSync(e,`utf-8`),e)}catch{u(Error(`[vize] <template src="${p.templateSrc}"> not found (resolved: ${e}) in ${f}`));return}}let g=d.root?l.resolve(this.rootContext,d.root):this.rootContext,v=a(f,h.code,{sourceMap:C,ssr:b,vapor:d.vapor??d.compilerOptions?.vapor??!1,compilerOptions:d.compilerOptions,isCustomElement:i,rootContext:g,isProduction:y,transformAssetUrls:d.transformAssetUrls});for(let e of v.warnings)this.emitWarning(Error(`[vize] ${e}`));if(v.errors.length>0){for(let e of v.errors)this.emitError(Error(`[vize] ${e}`));let e=v.errors.join(`\\n`);u(Error(`[vize] Compilation failed for ${f}:\n${e}`));return}let w=o(v,{requestPath:m,hmr:x,filePath:f,isProduction:y,rootContext:g,nativeCss:S}),T=w.map&&h.map?new s.SourceMapSource(w.code,f,JSON.stringify(w.map),h.code,JSON.stringify(h.map),!0).map({columns:!0}):w.map;u(null,w.code,T?JSON.stringify(T):void 0)}catch(e){u(e)}}function h(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function g(e,t){let n=e._compiler;return f(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function _(e,t){return t===!0?!0:t===!1||t===void 0?p.test(e):t.test(e)}function v(e,t){return`./${l.basename(t)}`}export{u as n,f as r,m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{collectSfcTemplateAssetUrls as e,extractSfcCustomBlocks as t,extractSfcSrcInfo as n,extractSfcStyleBlocks as r,generateSfcScopeId as i,scopeViteCssForPipeline as a,stripSfcScopedCssComments as o}from"@vizejs/native";import{sources as s}from"@rspack/core";import{diffChars as c}from"diff";function l(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t==`object`&&t&&t.version===3&&Array.isArray(t.sources)&&t.sources.every(e=>typeof e==`string`)&&Array.isArray(t.names)&&t.names.every(e=>typeof e==`string`)&&(t.sourcesContent===void 0||Array.isArray(t.sourcesContent)&&t.sourcesContent.every(e=>e===null||typeof e==`string`))&&typeof t.mappings==`string`?t:null}catch{return null}}var u=class{code;map;constructor(e,t){this.code=e,this.map=t}edit(e){let t=this.code;if(this.code=e,this.map===null||e===t)return;let n=c(t,e,{maxEditLength:1e4,timeout:100});if(!n){this.map=null;return}let r=new s.SourceMapSource(t,this.map.file??`sfc.js`,JSON.stringify(this.map)),i=new s.ConcatSource,a=0;for(let e of n)e.added?i.add(e.value):(e.removed||i.add(f(r,t.length,a,a+e.value.length)),a+=e.value.length);this.map=i.map({columns:!0})}replace(e,t,n){let r=this.code,i=typeof n==`string`?n:n.source().toString();if(this.code=r.slice(0,e)+i+r.slice(t),this.map===null)return;let a=new s.SourceMapSource(r,this.map.file??`sfc.js`,JSON.stringify(this.map));this.map=new s.ConcatSource(f(a,r.length,0,e),n,f(a,r.length,t,r.length)).map({columns:!0})}prepend(e){this.replace(0,0,e)}append(e){this.replace(this.code.length,this.code.length,e)}};function d(e,t,n,r){let i=RegExp(`(<${t})([^>]*)\\bsrc=["'][^"']+["']([^>]*>)[\\s\\S]*?(<\\/${t}>)`,`i`).exec(e.code);if(!i)return;let[,a,o,c,l]=i,u=(o+c).replace(/\bsrc=["'][^"']+["']\s*/g,``);e.replace(i.index,i.index+i[0].length,new s.ConcatSource(`${a}${u}\n`,r?new s.OriginalSource(n,r):n,`\n${l}`))}function f(e,t,n,r){if(n===r)return new s.RawSource(``);let i=new s.ReplaceSource(e);return n>0&&i.replace(0,n-1,``),r<t&&i.replace(r,t-1,``),i}function p(e,t,n,r){return i(e,t,n,r)}function m(e){return r(e).map(w)}function h(e){return o(e)}function g(e,t){return a(e,t.startsWith(`data-v-`)?t:`data-v-${t}`)}function _(e){return t(e).map(T)}function v(e){let t=n(e);return{scriptSrc:t.scriptSrc??null,templateSrc:t.templateSrc??null}}function y(e,t,n){let r=new u(e,null);return t!==null&&d(r,`script`,t),n!==null&&d(r,`template`,n),r.code}function b(e,t,n){if(!t)return n;let r=e.replace(/\\/g,`/`);return(Array.isArray(t)?t:[t]).some(t=>typeof t==`string`?r.includes(t)||e.includes(t):x(t,r))}function x(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}Object.freeze({img:[`src`],video:[`src`,`poster`],source:[`src`],image:[`xlink:href`,`href`],use:[`xlink:href`,`href`]});function S(t,n){return n===!1?[]:e(t,C(n))}function C(e){if(!(e==null||e===!0))return Object.entries(e).map(([e,t])=>({tag:e,attrs:t}))}function w(e){return{content:e.content,src:e.src??null,lang:e.lang??null,scoped:e.scoped,module:e.module?e.moduleName??!0:!1,index:e.index}}function T(e){let t={};for(let n of e.attrs)t[n.name]=n.value??!0;return{type:e.blockType,content:e.content,src:e.src??null,attrs:t,index:e.index}}export{m as a,b as c,w as d,u as f,v as i,h as l,l as m,S as n,p as o,d as p,_ as r,y as s,g as t,T as u};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/rspack-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.426.0",
|
|
4
4
|
"description": "High-performance Rspack plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -59,17 +59,22 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@vizejs/native": "0.
|
|
63
|
-
"
|
|
62
|
+
"@vizejs/native": "0.426.0",
|
|
63
|
+
"diff": "8.0.4",
|
|
64
|
+
"oxc-parser": "0.144.0",
|
|
65
|
+
"oxc-transform": "0.144.0"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
68
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
66
69
|
"@rspack/core": "2.1.8",
|
|
67
70
|
"@tsdown/css": "0.22.14",
|
|
68
71
|
"@types/node": "25.9.2",
|
|
72
|
+
"css-loader": "7.1.2",
|
|
69
73
|
"tsdown": "0.22.14",
|
|
70
74
|
"typescript": "6.0.3",
|
|
71
75
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.24",
|
|
72
|
-
"vite-plus": "0.1.24"
|
|
76
|
+
"vite-plus": "0.1.24",
|
|
77
|
+
"vue": "3.5.35"
|
|
73
78
|
},
|
|
74
79
|
"peerDependencies": {
|
|
75
80
|
"@rspack/core": "^1.0.0 || ^2.0.0"
|
|
@@ -90,6 +95,7 @@
|
|
|
90
95
|
"check:fix": "vp check --fix src vite.config.ts",
|
|
91
96
|
"fmt": "vp fmt --write src vite.config.ts",
|
|
92
97
|
"test": "pnpm build && node --test src/*.test.ts src/**/*.test.ts",
|
|
98
|
+
"test:hmr": "pnpm build && node --test test/hmr.test.mjs",
|
|
93
99
|
"test:update": "pnpm build && node --test --test-update-snapshots src/*.test.ts src/**/*.test.ts"
|
|
94
100
|
}
|
|
95
101
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import{d as e,n as t,o as n,u as r}from"./utils-CWJUzLH_.mjs";import*as i from"@vizejs/native";import{rewriteSfcTemplateAssetReferences as a}from"@vizejs/native";import o from"node:path";import{createHash as s}from"node:crypto";import{parseSync as c}from"oxc-parser";function l(e){return`
|
|
2
|
-
/* hot reload */
|
|
3
|
-
if (module.hot) {
|
|
4
|
-
_sfc_main.__hmrId = "${e}"
|
|
5
|
-
const api = __VUE_HMR_RUNTIME__
|
|
6
|
-
module.hot.accept()
|
|
7
|
-
if (!api.createRecord('${e}', _sfc_main)) {
|
|
8
|
-
api.reload('${e}', _sfc_main)
|
|
9
|
-
}
|
|
10
|
-
}`}function u(e,t,n,r){return`
|
|
11
|
-
if (module.hot) {
|
|
12
|
-
module.hot.accept(${t}, () => {
|
|
13
|
-
_sfc_main.__cssModules[${JSON.stringify(r)}] = ${n}
|
|
14
|
-
__VUE_HMR_RUNTIME__.rerender("${e}")
|
|
15
|
-
})
|
|
16
|
-
}`}const d=`_sfc_main`;function f(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function p(e){return typeof e?.start==`number`?e.start:null}function m(e){return f(e)&&typeof e.name==`string`?e.name:null}function h(e){try{let t=c(`vize-rspack-output.tsx`,e);if(typeof t==`object`&&t){let e=t.errors;if(Array.isArray(e)&&e.length>0)return null;let n=t.program;if(f(n))return n}return f(t)?t:null}catch{return null}}function g(e){return!e||!Array.isArray(e.body)?[]:e.body.filter(f)}function _(e,t){return m(e)===t}function v(e){return(Array.isArray(e.declarations)?e.declarations:[]).filter(f).map(e=>f(e.id)?m(e.id):null).filter(e=>e!=null)}function y(e){return g(e).find(e=>e.type===`ExportDefaultDeclaration`)??null}function b(e,t){let n=p(t);if(n==null)return null;let r=/^export\s+default\b/.exec(e.slice(n));return r?n+r[0].length:null}function x(e){let t=h(e),n=g(t);return{hasDefaultExport:y(t)!=null,hasSfcMainDefined:n.some(e=>e.type===`VariableDeclaration`&&v(e).includes(d))}}function S(e){let t=y(h(e)),n=p(t),r=t?b(e,t):null;return n==null||r==null?e:`${e.slice(0,n)}const ${d} =${e.slice(r)}`}function C(e,t,n={}){let r=y(h(e)),i=f(r?.declaration)?r.declaration:null,a=p(r),o=typeof r?.end==`number`?r.end:null;if(!_(i,d)||a==null)return e;if(n.normalizeSemicolon&&o!=null){let n=e[o]===`;`?o+1:o;return`${e.slice(0,a)}${t}\nexport default ${d};${e.slice(n)}`}return`${e.slice(0,a)}${t}\n${e.slice(a)}`}function w(e,t){let n=e.code,r=e.isCustomElement;e.templateAssetUrls.length>0&&(n=a(n,e.templateAssetUrls));let i=x(n),s=i.hasDefaultExport,c=i.hasSfcMainDefined;if(s&&!c?(n=S(n),e.hasScoped&&e.scopeId&&(n+=`\n_sfc_main.__scopeId = "data-v-${e.scopeId}";`),n+=`
|
|
17
|
-
export default _sfc_main;`):s&&c&&e.hasScoped&&e.scopeId&&(n=C(n,`_sfc_main.__scopeId = "data-v-${e.scopeId}";`)),e.styles.length>0){if(r&&e.styles.some(e=>e.module))throw Error(`[vize] <style module> is not supported in custom elements mode.`);let i=e.styles.filter(e=>e.module===!0).length;if(i>1)throw Error(`[vize] Found ${i} unnamed <style module> blocks. Only one unnamed <style module> is allowed per SFC. Use named modules instead: <style module="name">`);let a=e.styles.filter(e=>e.src||/\S/.test(e.content)),o=[];if(n=a.map(n=>{let i=[`vue`,`type=style`,`index=${n.index}`,`lang=${n.lang||`css`}`,...n.scoped?[`scoped=${e.scopeId}`]:[],...n.module?[`module=${typeof n.module==`string`?n.module:`true`}`]:[],...r?[`inline`]:[]],a=`${t.requestPath}?${i.join(`&`)}`;if(r)return`import _style_${n.index} from ${JSON.stringify(a)};`;if(n.module){let e=typeof n.module==`string`?n.module:`$style`,r=`_cssModule_${n.index}`;return o.push({request:a,varName:r,bindingName:e}),t.nativeCss?`import * as ${r} from ${JSON.stringify(a)};`:`import ${r} from ${JSON.stringify(a)};`}return`import ${JSON.stringify(a)};`}).join(`
|
|
18
|
-
`)+`
|
|
19
|
-
`+n,r){let e=a.map(e=>`_style_${e.index}`).join(`,`);n=C(n,`_sfc_main.styles = [${e}];`,{normalizeSemicolon:!0})}if(!r&&o.length>0){let r=o.map(e=>`_sfc_main.__cssModules = _sfc_main.__cssModules || {};\n_sfc_main.__cssModules[${JSON.stringify(e.bindingName)}] = ${e.varName};`).join(`
|
|
20
|
-
`),i=t.hmr&&e.scopeId?o.map(t=>u(e.scopeId,JSON.stringify(t.request),t.varName,t.bindingName)).join(`
|
|
21
|
-
`):``;n=C(n,`${r}\n${i}`,{normalizeSemicolon:!0})}}if(t.filePath&&!t.isProduction){let e=t.rootContext?o.relative(t.rootContext,t.filePath).replace(/\\/g,`/`):o.basename(t.filePath);n=C(n,`_sfc_main.__file = ${JSON.stringify(e)};`,{normalizeSemicolon:!0})}if(t.hmr&&e.scopeId&&(n=C(n,l(e.scopeId),{normalizeSemicolon:!0})),e.customBlocks.length>0){let r=e.customBlocks.map((e,n)=>{let r=[`vue`,`type=${e.type}`,`index=${n}`,...e.src?[`src=true`]:[]];for(let[t,n]of Object.entries(e.attrs))t!==`src`&&(n===!0?r.push(t):r.push(`${t}=${n}`));let i=`${t.requestPath}?${r.join(`&`)}`;return`import block${n} from ${JSON.stringify(i)};\nif (typeof block${n} === 'function') block${n}(_sfc_main);`}).join(`
|
|
22
|
-
`);n=C(n,r,{normalizeSemicolon:!0})}return e.templateAssetUrls.length>0&&(n=e.templateAssetUrls.map(({url:e,varName:t})=>{let n=e.startsWith(`~`)?e.slice(1):e,r=n.indexOf(`#`);return r>=0&&(n=n.slice(0,r)),`import ${t} from ${JSON.stringify(n)};`}).join(`
|
|
23
|
-
`)+`
|
|
24
|
-
`+n),n}const{compileSfc:T}=i,{compileJsx:E}=i;function D(e){return e.endsWith(`.jsx`)||e.endsWith(`.tsx`)}function O(e,t,n){return`
|
|
25
|
-
export const __vize_css__ = ${JSON.stringify(t)};
|
|
26
|
-
const __vize_css_id__ = ${JSON.stringify(`vize-style-${n}`)};
|
|
27
|
-
(function() {
|
|
28
|
-
if (typeof document !== "undefined") {
|
|
29
|
-
let style = document.getElementById(__vize_css_id__);
|
|
30
|
-
if (!style) {
|
|
31
|
-
style = document.createElement("style");
|
|
32
|
-
style.id = __vize_css_id__;
|
|
33
|
-
style.textContent = __vize_css__;
|
|
34
|
-
document.head.appendChild(style);
|
|
35
|
-
} else {
|
|
36
|
-
style.textContent = __vize_css__;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
})();
|
|
40
|
-
${e}`}function k(e,t,n={}){let r=E(t,{filename:e,lang:e.endsWith(`.tsx`)?`tsx`:`jsx`,jsxMode:n.jsxMode,jsxCompat:n.jsxCompat,vapor:n.vapor??!1,sourceMap:n.sourceMap??!1});if(r.errors.length>0)throw Error(`[vize] Compilation failed for ${e}:\n${r.errors.join(`
|
|
41
|
-
`)}`);let i=(r.scopedStyles??[]).map(e=>e.css).join(`
|
|
42
|
-
`),a=r.code,o=r.map??null;if(i){let e=r.scopedStyles[0].scopeId.replace(/^data-v-/,``);a=O(a,i,e),o=null}return{code:a,map:o,warnings:r.warnings}}const A=new Map;function j(e){return s(`sha256`).update(e).digest(`hex`).slice(0,16)}function M(){A.clear()}function N(i,a,o={}){let s=o.compilerOptions?.isTs??/<script[^>]*\blang=["']ts["']/.test(a),c=o.ssr??o.compilerOptions?.ssr??!1,l=o.vapor??o.compilerOptions?.vapor??!1,u=o.sourceMap??o.compilerOptions?.sourceMap??!0,d=o.isCustomElement??!1,f=o.rootContext??``,p=o.isProduction??!1,m=o.transformAssetUrls??!0,h=`${i}:ssr=${c}:vapor=${l}:ts=${s}:map=${u}:ce=${d}:syntax=${o.compilerOptions?.templateSyntax??`standard`}:xic=${o.compilerOptions?.experimentalInTagComments??!1}:xpt=${o.compilerOptions?.experimentalPatternedTemplate??!1}:xsc=${o.compilerOptions?.experimentalSelfComponent??!1}:xslot=${o.compilerOptions?.experimentalStrictSlotChildren??!1}:xss=${o.compilerOptions?.experimentalServerScript??!1}:root=${f}:prod=${p}:${m===!1?`tau=false`:m===!0?`tau=true`:`tau=${JSON.stringify(m)}`}`,g=j(a),_=A.get(h);if(_&&_.contentHash===g)return _.result;let v=n(i,o.rootContext,o.isProduction,a),y=T(a,{...o.compilerOptions,filename:i,sourceMap:o.sourceMap??o.compilerOptions?.sourceMap??!0,ssr:c,vapor:l,isTs:s,scopeId:`data-v-${v}`}),b=t(a,m),x={code:y.code,css:y.css,errors:y.errors,warnings:y.warnings,scopeId:v,hasScoped:y.hasScoped,styles:y.styles.map(e),customBlocks:y.customBlocks.map(r),isCustomElement:d,templateAssetUrls:b,macroArtifacts:y.macroArtifacts??[]};return x.errors.length===0&&A.set(h,{contentHash:g,result:x}),x}export{w as a,D as i,N as n,l as o,k as r,M as t};
|
package/dist/loader-3I9d5PUe.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,i as t,r as n,s as r}from"./utils-CWJUzLH_.mjs";import{a as i,n as a}from"./compiler-CUPTljp_.mjs";import o from"node:fs";import s from"node:path";function c(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function l(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function u(e,t,n){if(e!=null)return e;let r=c(t);if(r!==`unavailable`)return r===`enabled`;let i=l(n);return i!=null&&i>=2}const d=/\.ce\.vue$/;function f(e){let c=this.async(),l=this.getOptions(),u=this.resourcePath,d=this.resourceQuery,f=g(this,u),_=this.mode===`production`||process.env.NODE_ENV===`production`,v=!(l.ssr??!1)&&!_&&l.hotReload!==!1,y=m(this,l);if(this.addDependency(u),d?.includes(`type=style`)){c(Error(`[vize] Main loader received style sub-request: ${u}${d}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(d&&d.includes(`vue`)&&d.includes(`type=`)&&!d.includes(`type=style`)){let t=new URLSearchParams(d.slice(1)),r=t.get(`type`);if(r&&r!==`style`){let i=parseInt(t.get(`index`)||`0`,10),a=n(e)[i];if(a){if(a.src){let e=s.resolve(s.dirname(u),a.src);this.addDependency(e);try{c(null,o.readFileSync(e,`utf-8`))}catch{c(Error(`[vize] Custom block <${r} src="${a.src}"> not found (resolved: ${e}) in ${u}`))}return}c(null,a.content)}else c(null,``);return}}if(!p(u,l)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${u}. Passing through source unchanged.`)),c(null,e);return}try{let n=h(u,l.customElement),d=t(e),p=e;if(d.scriptSrc){let e=s.resolve(s.dirname(u),d.scriptSrc);this.addDependency(e);try{let t=o.readFileSync(e,`utf-8`);p=r(p,t,null)}catch{c(Error(`[vize] <script src="${d.scriptSrc}"> not found (resolved: ${e}) in ${u}`));return}}if(d.templateSrc){let e=s.resolve(s.dirname(u),d.templateSrc);this.addDependency(e);try{let t=o.readFileSync(e,`utf-8`);p=r(p,null,t)}catch{c(Error(`[vize] <template src="${d.templateSrc}"> not found (resolved: ${e}) in ${u}`));return}}let m=a(u,p,{sourceMap:l.sourceMap??this.sourceMap??!0,ssr:l.ssr??!1,vapor:l.vapor??!1,compilerOptions:l.compilerOptions,isCustomElement:n,rootContext:this.rootContext,isProduction:_,transformAssetUrls:l.transformAssetUrls});for(let e of m.warnings)this.emitWarning(Error(`[vize] ${e}`));if(m.errors.length>0){for(let e of m.errors)this.emitError(Error(`[vize] ${e}`));let e=m.errors.join(`\\n`);c(Error(`[vize] Compilation failed for ${u}:\n${e}`));return}c(null,i(m,{requestPath:f,hmr:v,filePath:u,isProduction:_,rootContext:this.rootContext,nativeCss:y}))}catch(e){c(e)}}function p(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function m(e,t){let n=e._compiler;return u(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function h(e,t){return t===!0?!0:t===!1||t===void 0?d.test(e):t.test(e)}function g(e,t){return`./${s.basename(t)}`}export{c as n,u as r,f as t};
|
package/dist/utils-CWJUzLH_.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{collectSfcTemplateAssetUrls as e,extractSfcCustomBlocks as t,extractSfcSrcInfo as n,extractSfcStyleBlocks as r,generateSfcScopeId as i,scopeViteCssForPipeline as a,stripSfcScopedCssComments as o}from"@vizejs/native";function s(e,t,n,r){return i(e,t,n,r)}function c(e){return r(e).map(v)}function l(e){return o(e)}function u(e,t){return a(e,t.startsWith(`data-v-`)?t:`data-v-${t}`)}function d(e){return t(e).map(y)}function f(e){let t=n(e);return{scriptSrc:t.scriptSrc??null,templateSrc:t.templateSrc??null}}function p(e,t,n){let r=e;return t!==null&&(r=r.replace(/(<script)([^>]*)\bsrc=["'][^"']+["']([^>]*>)[\s\S]*?(<\/script>)/i,(e,n,r,i,a)=>`${n}${(r+i).replace(/\bsrc=["'][^"']+["']\s*/g,``)}\n${t}\n${a}`)),n!==null&&(r=r.replace(/(<template)([^>]*)\bsrc=["'][^"']+["']([^>]*>)[\s\S]*?(<\/template>)/i,(e,t,r,i,a)=>`${t}${(r+i).replace(/\bsrc=["'][^"']+["']\s*/g,``)}\n${n}\n${a}`)),r}function m(e,t,n){if(!t)return n;let r=e.replace(/\\/g,`/`);return(Array.isArray(t)?t:[t]).some(t=>typeof t==`string`?r.includes(t)||e.includes(t):h(t,r))}function h(e,t){e.lastIndex=0;let n=e.test(t);return e.lastIndex=0,n}Object.freeze({img:[`src`],video:[`src`,`poster`],source:[`src`],image:[`xlink:href`,`href`],use:[`xlink:href`,`href`]});function g(t,n){return n===!1?[]:e(t,_(n))}function _(e){if(!(e==null||e===!0))return Object.entries(e).map(([e,t])=>({tag:e,attrs:t}))}function v(e){return{content:e.content,src:e.src??null,lang:e.lang??null,scoped:e.scoped,module:e.module?e.moduleName??!0:!1,index:e.index}}function y(e){let t={};for(let n of e.attrs)t[n.name]=n.value??!0;return{type:e.blockType,content:e.content,src:e.src??null,attrs:t,index:e.index}}export{c as a,m as c,v as d,f as i,l,g as n,s as o,d as r,p as s,u as t,y as u};
|