@vizejs/rspack-plugin 0.160.0 → 0.162.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 CHANGED
@@ -4,7 +4,7 @@ High-performance Rspack plugin for Vue SFC compilation powered by [Vize](https:/
4
4
 
5
5
  > [!NOTE]
6
6
  > Rspack intentionally uses the dedicated `@vizejs/rspack-plugin` path instead of an `@vizejs/unplugin/rspack` export.
7
- > Its loader chain, `experiments.css`, and HMR behavior need Rspack-specific handling.
7
+ > Its loader chain, native CSS handling, and HMR behavior need Rspack-specific handling.
8
8
  >
9
9
  > Non-Vite bundler integrations are still unstable.
10
10
  > If you need Rollup, Rolldown, Webpack, esbuild, or Babel, use `@vizejs/unplugin` and test carefully before relying on it in production.
@@ -13,7 +13,7 @@ High-performance Rspack plugin for Vue SFC compilation powered by [Vize](https:/
13
13
 
14
14
  - ⚡ **Blazing Fast** - Powered by Rust-based `@vizejs/native` compiler
15
15
  - 🔄 **HMR Support** - Script/template hot reload via `module.hot` + `__VUE_HMR_RUNTIME__`, CSS Modules HMR with targeted rerender
16
- - 🎨 **CSS Processing** - Support for both native CSS (`experiments.css`) and CssExtractRspackPlugin
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
19
19
  - 🔧 **TypeScript** - Full TypeScript support with auto-detection and built-in SWC stripping by default
@@ -31,6 +31,10 @@ vp install -D @vizejs/rspack-plugin @rspack/core
31
31
 
32
32
  ## Usage
33
33
 
34
+ > [!IMPORTANT]
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 }` (or pass `css: { native: true }`) to enable it.
37
+
34
38
  ### Simple Mode (Recommended)
35
39
 
36
40
  Write a single `.vue` rule and your normal CSS rules. `VizePlugin` automatically clones your CSS rules for Vue style sub-requests and injects Rspack's built-in SWC post-processing for `.vue` TypeScript output.
@@ -43,10 +47,8 @@ const isProduction = process.env.NODE_ENV === "production";
43
47
 
44
48
  export default {
45
49
  mode: isProduction ? "production" : "development",
46
-
47
- experiments: {
48
- css: true, // Enable Rspack native CSS
49
- },
50
+ // Rspack 2.x: native CSS is on by default — nothing to configure here.
51
+ // Rspack 1.x only, to enable native CSS: experiments: { css: true },
50
52
 
51
53
  module: {
52
54
  rules: [
@@ -60,7 +62,9 @@ export default {
60
62
  plugins: [
61
63
  new VizePlugin({
62
64
  isProduction,
63
- css: { native: true },
65
+ // Native CSS is the default on Rspack 2.x.
66
+ // On Rspack 1.x, pass css: { native: true } and set experiments: { css: true }.
67
+ // Pass css: { native: false } to opt out of native CSS.
64
68
  }),
65
69
  ],
66
70
  };
@@ -68,7 +72,7 @@ export default {
68
72
 
69
73
  ### Native CSS with SCSS (Simple Mode)
70
74
 
71
- Uses Rspack's built-in `experiments.css` for optimal performance. Just add your SCSS rule — VizePlugin handles the rest.
75
+ Uses Rspack native CSS for optimal performance. On Rspack 2.x it's the default, so there's nothing extra to configure; on Rspack 1.x, add `experiments: { css: true }`. Just add your SCSS rule — VizePlugin handles the rest.
72
76
 
73
77
  ```javascript
74
78
  // rspack.config.mjs
@@ -80,9 +84,8 @@ const isProduction = process.env.NODE_ENV === "production";
80
84
  export default {
81
85
  mode: isProduction ? "production" : "development",
82
86
 
83
- experiments: {
84
- css: true,
85
- },
87
+ // Rspack 2.x: native CSS is on by default.
88
+ // Rspack 1.x only, to enable native CSS: experiments: { css: true },
86
89
 
87
90
  module: {
88
91
  rules: [
@@ -101,7 +104,6 @@ export default {
101
104
  plugins: [
102
105
  new VizePlugin({
103
106
  isProduction,
104
- css: { native: true },
105
107
  }),
106
108
  ],
107
109
 
@@ -225,9 +227,8 @@ const isProduction = process.env.NODE_ENV === "production";
225
227
  export default {
226
228
  mode: isProduction ? "production" : "development",
227
229
 
228
- experiments: {
229
- css: true,
230
- },
230
+ // Rspack 2.x: native CSS is on by default.
231
+ // Rspack 1.x only, to enable native CSS: experiments: { css: true },
231
232
 
232
233
  module: {
233
234
  rules: [
@@ -421,7 +422,7 @@ new VizePlugin({
421
422
  vapor: boolean; // Enable Vapor mode (default: false)
422
423
  root: string; // Root directory (default: Rspack's root)
423
424
  css: {
424
- native: boolean; // Use experiments.css (default: false), warns if config mismatch
425
+ native: boolean; // Use Rspack native CSS. Default: true on Rspack 2.x, false on 1.x (1.x also needs experiments: { css: true })
425
426
  };
426
427
  compilerOptions: {}; // Extra @vizejs/native compileSfc options
427
428
  debug: boolean; // Enable debug logging (default: false)
@@ -592,14 +593,14 @@ Only relative (`./`, `../`), alias (`@/`), and tilde (`~/`, `~pkg`) URLs are tra
592
593
  {
593
594
  loader: "@vizejs/rspack-plugin/style-loader",
594
595
  options: {
595
- native: boolean; // Using experiments.css (default: false)
596
+ native: boolean; // Rspack native CSS mode. Default: true on Rspack 2.x, false on 1.x (1.x also needs experiments: { css: true })
596
597
  };
597
598
  }
598
599
  ```
599
600
 
600
601
  ### VizeScopeLoader
601
602
 
602
- Applies native scoped CSS transformation using `@vizejs/native compileCss`. Runs **after** preprocessors (SCSS/Less/Stylus → CSS) and **before** css-loader or `experiments.css`.
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.
603
604
 
604
605
  ```typescript
605
606
  // In rspack.config.js
@@ -130,7 +130,7 @@ interface VizeLoaderOptions {
130
130
  hotReload?: boolean;
131
131
  /** CSS handling config */
132
132
  css?: {
133
- /** Native CSS (experiments.css), uses LightningCSS @default auto-detected */native?: boolean;
133
+ /** Rspack native CSS, uses LightningCSS @default auto-detected */native?: boolean;
134
134
  };
135
135
  /**
136
136
  * Transform static asset URLs in templates into import bindings.
@@ -139,7 +139,7 @@ interface VizeLoaderOptions {
139
139
  transformAssetUrls?: boolean | Record<string, string[]>;
140
140
  }
141
141
  interface VizeStyleLoaderOptions {
142
- /** Native CSS mode (experiments.css) @default false */
142
+ /** Rspack native CSS mode @default false */
143
143
  native?: boolean;
144
144
  }
145
145
  interface VizeRspackPluginOptions {
@@ -159,7 +159,7 @@ interface VizeRspackPluginOptions {
159
159
  root?: string;
160
160
  /** CSS config */
161
161
  css?: {
162
- /** Native CSS (experiments.css), uses LightningCSS @default false */native?: boolean;
162
+ /** Rspack native CSS, uses LightningCSS @default false */native?: boolean;
163
163
  };
164
164
  /** Compiler options */
165
165
  compilerOptions?: SfcCompileOptionsNapi;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SfcCompileOptionsNapi, c as StyleBlockInfo, d as VizeStyleLoaderOptions, i as MacroArtifact, l as VizeLoaderOptions, n as CustomBlockInfo, o as SfcCompileResultNapi, r as LoaderEntry, s as SfcSrcInfo, t as CompiledModule, u as VizeRspackPluginOptions } from "./index-lMwi--Ex.mjs";
1
+ import { a as SfcCompileOptionsNapi, c as StyleBlockInfo, d as VizeStyleLoaderOptions, i as MacroArtifact, l as VizeLoaderOptions, n as CustomBlockInfo, o as SfcCompileResultNapi, r as LoaderEntry, s as SfcSrcInfo, t as CompiledModule, u as VizeRspackPluginOptions } from "./index-DQ8S8WoC.mjs";
2
2
  import vizeLoader from "./loader/index.mjs";
3
3
  import vizeStyleLoader from "./loader/style-loader.mjs";
4
4
  import vizeScopeLoader from "./loader/scope-loader.mjs";
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-CFK8mca_.mjs";import{a as s,i as c,n as l,r as u,t as d}from"./loader-Cu6KT7rY.mjs";import f from"./loader/style-loader.mjs";import p from"./loader/scope-loader.mjs";const m=`@vizejs/rspack-plugin/style-loader`,h=`@vizejs/rspack-plugin/scope-loader`,g={"\\.css$":`css`,"\\.scss$":`scss`,"\\.sass$":`sass`,"\\.less$":`less`,"\\.styl(us)?$":`styl`};function _(e,t){let n=[],r=e.findIndex(e=>e!==`...`&&v(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=x(n);i&&a.push({index:t,rule:n,lang:i})}let o=[];for(let e of a)o.push(...S(e.rule,e.lang,t));o.some(e=>e.resourceQuery instanceof RegExp&&e.resourceQuery.test(`vue&type=style&index=0&lang=css`))||o.push(...C(t));let s={use:E(i)},c=[...o,s];e[r]={test:i.test,oneOf:c};for(let e of a)w(e.rule);return{applied:!0,clonedCount:o.length,warnings:n}}function v(e){return b(e.test)?E(e).some(e=>{let t=typeof e==`string`?e:e.loader;return t?y(t):!1}):!1}function y(e){return e===`@vizejs/rspack-plugin/loader`||e.includes(`rspack-vize-plugin`)&&e.includes(`loader`)&&!e.includes(`style-loader`)&&!e.includes(`scope-loader`)}function b(e){return e?e instanceof RegExp?e.test(`App.vue`)||e.test(`foo.vue`):typeof e==`string`?e.includes(`.vue`):!1:!1}function x(e){let t=e.test;if(!t||!(t instanceof RegExp))return null;let n=t.source;for(let[e,t]of Object.entries(g))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 S(e,t,n){let r=E(e);if(r.length===0)return[];let i=[{loader:h},...D(r),{loader:m}],a=(t,n)=>{let r={resourceQuery:t,use:D(i)};return e.type?r.type=e.type:n&&(r.type=n),r};return n?[a(RegExp(`(?=.*type=style)(?=.*lang=${t})(?=.*module=)`),`css/module`),a(RegExp(`(?=.*type=style)(?=.*lang=${t})`),`css/auto`)]:[a(RegExp(`(?=.*type=style)(?=.*lang=${t})`))]}function C(e){return e?[{resourceQuery:/(?=.*type=style)(?=.*lang=css)(?=.*module=)/,type:`css/module`,use:[{loader:h},{loader:m}]},{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`css/auto`,use:[{loader:h},{loader:m}]}]:[{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`javascript/auto`,use:[{loader:h},{loader:m}]}]}function w(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 T(e){return e?Array.isArray(e)?e:[e]:[]}function E(e){let t=T(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 D(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 O=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`;this.options.vapor&&!r&&n.debug(`Vapor mode is enabled.`);let i=!!t.options.experiments?.css;if(this.options.css?.native&&!i&&n.warn("`css.native: true` is set but `experiments.css` is not enabled in rspack config."),this.options.autoRules??!0){let e=t.options.module?.rules;if(e){let t=_(e,i);t.applied&&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`}),n.debug(`Auto-injected TypeScript post-processing rule for .vue files.`)))}let{DefinePlugin:a}=t.webpack,o=new Set;for(let e of t.options.plugins??[]){let t=e?.definitions;if(t)for(let e of Object.keys(t))o.add(e)}let s={};o.has(`__VUE_OPTIONS_API__`)||(s.__VUE_OPTIONS_API__=JSON.stringify(!0)),o.has(`__VUE_PROD_DEVTOOLS__`)||(s.__VUE_PROD_DEVTOOLS__=JSON.stringify(!r)),o.has(`__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`)||(s.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=JSON.stringify(!r)),Object.keys(s).length>0&&new a(s).apply(t),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{O as VizePlugin,o as addScopeToCssFallback,_ as applyRuleCloning,l as clearCompilationCache,u as compileFile,i as extractCustomBlocks,n as extractSrcInfo,e as extractStyleBlocks,s as genHotReloadCode,c as generateOutput,r as generateScopeId,a as inlineSrcBlocks,t as matchesPattern,d as vizeLoader,p as vizeScopeLoader,f as vizeStyleLoader};
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-CFK8mca_.mjs";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./loader-zhnTzdd6.mjs";import m from"./loader/style-loader.mjs";import h from"./loader/scope-loader.mjs";const g=`@vizejs/rspack-plugin/style-loader`,_=`@vizejs/rspack-plugin/scope-loader`,v={"\\.css$":`css`,"\\.scss$":`scss`,"\\.sass$":`sass`,"\\.less$":`less`,"\\.styl(us)?$":`styl`};function y(e,t){let n=[],r=e.findIndex(e=>e!==`...`&&b(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=C(n);i&&a.push({index:t,rule:n,lang:i})}let o=[];for(let e of a)o.push(...w(e.rule,e.lang,t));o.some(e=>e.resourceQuery instanceof RegExp&&e.resourceQuery.test(`vue&type=style&index=0&lang=css`))||o.push(...T(t));let s={use:E(k(i),t)},c=[...o,s];e[r]={test:i.test,oneOf:c};for(let e of a)D(e.rule);return{applied:!0,clonedCount:o.length,warnings:n}}function b(e){return S(e.test)?k(e).some(e=>{let t=typeof e==`string`?e:e.loader;return t?x(t):!1}):!1}function x(e){return e===`@vizejs/rspack-plugin/loader`||e.includes(`rspack-vize-plugin`)&&e.includes(`loader`)&&!e.includes(`style-loader`)&&!e.includes(`scope-loader`)}function S(e){return e?e instanceof RegExp?e.test(`App.vue`)||e.test(`foo.vue`):typeof e==`string`?e.includes(`.vue`):!1:!1}function C(e){let t=e.test;if(!t||!(t instanceof RegExp))return null;let n=t.source;for(let[e,t]of Object.entries(v))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 w(e,t,n){let r=k(e);if(r.length===0)return[];let i=[{loader:_},...A(r),{loader:g}],a=(t,n)=>{let r={resourceQuery:t,use:A(i)};return e.type?r.type=e.type:n&&(r.type=n),r};return n?[a(RegExp(`(?=.*type=style)(?=.*lang=${t})(?=.*module=)`),`css/module`),a(RegExp(`(?=.*type=style)(?=.*lang=${t})`),`css/auto`)]:[a(RegExp(`(?=.*type=style)(?=.*lang=${t})`))]}function T(e){return e?[{resourceQuery:/(?=.*type=style)(?=.*lang=css)(?=.*module=)/,type:`css/module`,use:[{loader:_},{loader:g}]},{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`css/auto`,use:[{loader:_},{loader:g}]}]:[{resourceQuery:/(?=.*type=style)(?=.*lang=css)/,type:`javascript/auto`,use:[{loader:_},{loader:g}]}]}function E(e,t){return A(e).map(e=>{if(typeof e==`string`)return x(e)?{loader:e,options:{css:{native:t}}}:e;if(typeof e!=`object`||!e)return e;let n=e.loader;if(!n||!x(n))return e;let r=e.options;if(!r||typeof r!=`object`||Array.isArray(r))return{...e,options:{css:{native:t}}};let i=r,a=i.css;return!a||typeof a!=`object`||Array.isArray(a)?{...e,options:{...i,css:{native:t}}}:{...e,options:{...i,css:{...a,native:t}}}})}function D(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 O(e){return e?Array.isArray(e)?e:[e]:[]}function k(e){let t=O(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 A(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 j=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`;this.options.vapor&&!r&&n.debug(`Vapor mode is enabled.`);let i=u(t.options),a=t.webpack?.rspackVersion,o=f(this.options.css?.native,t.options,a);if(this.options.css?.native&&i===`disabled`&&n.warn("`css.native: true` is set but `experiments.css` is not enabled in rspack config."),this.options.autoRules??!0){let e=t.options.module?.rules;if(e){let t=y(e,o);t.applied&&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`}),n.debug(`Auto-injected TypeScript post-processing rule for .vue files.`)))}let{DefinePlugin:s}=t.webpack,c=new Set;for(let e of t.options.plugins??[]){let t=e?.definitions;if(t)for(let e of Object.keys(t))c.add(e)}let l={};c.has(`__VUE_OPTIONS_API__`)||(l.__VUE_OPTIONS_API__=JSON.stringify(!0)),c.has(`__VUE_PROD_DEVTOOLS__`)||(l.__VUE_PROD_DEVTOOLS__=JSON.stringify(!r)),c.has(`__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`)||(l.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=JSON.stringify(!r)),Object.keys(l).length>0&&new s(l).apply(t),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{j as VizePlugin,o as addScopeToCssFallback,y as applyRuleCloning,l as clearCompilationCache,d as compileFile,i as extractCustomBlocks,n as extractSrcInfo,e as extractStyleBlocks,s as genHotReloadCode,c as generateOutput,r as generateScopeId,a as inlineSrcBlocks,t as matchesPattern,p as vizeLoader,h as vizeScopeLoader,m as vizeStyleLoader};
@@ -1,4 +1,4 @@
1
- import { l as VizeLoaderOptions } from "../index-lMwi--Ex.mjs";
1
+ import { l as VizeLoaderOptions } from "../index-DQ8S8WoC.mjs";
2
2
  import { LoaderContext } from "@rspack/core";
3
3
 
4
4
  //#region src/loader/index.d.ts
@@ -1 +1 @@
1
- import{t as e}from"../loader-Cu6KT7rY.mjs";export{e as default};
1
+ import{t as e}from"../loader-zhnTzdd6.mjs";export{e as default};
@@ -1,4 +1,4 @@
1
- import { d as VizeStyleLoaderOptions } from "../index-lMwi--Ex.mjs";
1
+ import { d as VizeStyleLoaderOptions } from "../index-DQ8S8WoC.mjs";
2
2
  import { LoaderContext } from "@rspack/core";
3
3
 
4
4
  //#region src/loader/style-loader.d.ts
@@ -1,4 +1,4 @@
1
- import{c as e,d as t,i as n,n as r,o as i,r as a,s as o,u as s}from"./utils-CFK8mca_.mjs";import*as c from"@vizejs/native";import l from"node:fs";import u from"node:path";import{createHash as d}from"node:crypto";function f(e){return`
1
+ import{c as e,d as t,i as n,n as r,o as i,r as a,s as o,u as s}from"./utils-CFK8mca_.mjs";import*as c from"@vizejs/native";import l from"node:fs";import u from"node:path";import{createHash as d}from"node:crypto";function f(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function p(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function m(e,t,n){if(e!=null)return e;let r=f(t);if(r!==`unavailable`)return r===`enabled`;let i=p(n);return i!=null&&i>=2}function h(e){return`
2
2
  /* hot reload */
3
3
  if (module.hot) {
4
4
  _sfc_main.__hmrId = "${e}"
@@ -7,18 +7,18 @@ if (module.hot) {
7
7
  if (!api.createRecord('${e}', _sfc_main)) {
8
8
  api.reload('${e}', _sfc_main)
9
9
  }
10
- }`}function p(e,t,n,r){return`
10
+ }`}function g(e,t,n,r){return`
11
11
  if (module.hot) {
12
12
  module.hot.accept(${t}, () => {
13
13
  _sfc_main.__cssModules[${JSON.stringify(r)}] = ${n}
14
14
  __VUE_HMR_RUNTIME__.rerender("${e}")
15
15
  })
16
- }`}function m(e,t){let n=e.code,r=e.isCustomElement;if(e.templateAssetUrls.length>0)for(let{url:t,varName:r}of e.templateAssetUrls){let e=t.indexOf(`#`),i=e>=0?t.slice(e):``,a=i?`${r} + ${JSON.stringify(i)}`:r,o=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`"${o}"`,`g`),a),n=n.replace(RegExp(`'${o}'`,`g`),a)}let i=/^export default /m,a=i.test(n),o=/\bconst\s+_sfc_main\s*=/.test(n);if(a&&!o?(n=n.replace(i,`const _sfc_main = `),e.hasScoped&&e.scopeId&&(n+=`\n_sfc_main.__scopeId = "data-v-${e.scopeId}";`),n+=`
16
+ }`}function _(e,t){let n=e.code,r=e.isCustomElement;if(e.templateAssetUrls.length>0)for(let{url:t,varName:r}of e.templateAssetUrls){let e=t.indexOf(`#`),i=e>=0?t.slice(e):``,a=i?`${r} + ${JSON.stringify(i)}`:r,o=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`"${o}"`,`g`),a),n=n.replace(RegExp(`'${o}'`,`g`),a)}let i=/^export default /m,a=i.test(n),o=/\bconst\s+_sfc_main\s*=/.test(n);if(a&&!o?(n=n.replace(i,`const _sfc_main = `),e.hasScoped&&e.scopeId&&(n+=`\n_sfc_main.__scopeId = "data-v-${e.scopeId}";`),n+=`
17
17
  export default _sfc_main;`):a&&o&&e.hasScoped&&e.scopeId&&(n=n.replace(/^export default _sfc_main/m,`_sfc_main.__scopeId = "data-v-${e.scopeId}";\nexport default _sfc_main`)),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
18
  `)+`
19
19
  `+n,r){let e=a.map(e=>`_style_${e.index}`).join(`,`);n=n.replace(/^export default _sfc_main;/m,`_sfc_main.styles = [${e}];\nexport default _sfc_main;`)}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=>p(e.scopeId,JSON.stringify(t.request),t.varName,t.bindingName)).join(`
21
- `):``;n=n.replace(/^export default _sfc_main;/m,`${r}\n${i}\nexport default _sfc_main;`)}}if(t.filePath&&!t.isProduction){let e=t.rootContext?u.relative(t.rootContext,t.filePath).replace(/\\/g,`/`):u.basename(t.filePath);n=n.replace(/^export default _sfc_main;/m,`_sfc_main.__file = ${JSON.stringify(e)};\nexport default _sfc_main;`)}if(t.hmr&&e.scopeId&&(n=n.replace(/^export default _sfc_main;/m,`${f(e.scopeId)}\nexport default _sfc_main;`)),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(`
20
+ `),i=t.hmr&&e.scopeId?o.map(t=>g(e.scopeId,JSON.stringify(t.request),t.varName,t.bindingName)).join(`
21
+ `):``;n=n.replace(/^export default _sfc_main;/m,`${r}\n${i}\nexport default _sfc_main;`)}}if(t.filePath&&!t.isProduction){let e=t.rootContext?u.relative(t.rootContext,t.filePath).replace(/\\/g,`/`):u.basename(t.filePath);n=n.replace(/^export default _sfc_main;/m,`_sfc_main.__file = ${JSON.stringify(e)};\nexport default _sfc_main;`)}if(t.hmr&&e.scopeId&&(n=n.replace(/^export default _sfc_main;/m,`${h(e.scopeId)}\nexport default _sfc_main;`)),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
22
  `);n=n.replace(/^export default _sfc_main;/m,`${r}\nexport default _sfc_main;`)}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
23
  `)+`
24
- `+n),n}const{compileSfc:h}=c,g=new Map;function _(e){return d(`sha256`).update(e).digest(`hex`).slice(0,16)}function v(){g.clear()}function y(e,n,a={}){let o=a.compilerOptions?.isTs??/<script[^>]*\blang=["']ts["']/.test(n),c=a.ssr??a.compilerOptions?.ssr??!1,l=a.vapor??a.compilerOptions?.vapor??!1,u=a.sourceMap??a.compilerOptions?.sourceMap??!0,d=a.isCustomElement??!1,f=a.rootContext??``,p=a.isProduction??!1,m=a.transformAssetUrls??!0,v=`${e}:ssr=${c}:vapor=${l}:ts=${o}:map=${u}:ce=${d}:root=${f}:prod=${p}:${m===!1?`tau=false`:m===!0?`tau=true`:`tau=${JSON.stringify(m)}`}`,y=_(n),b=g.get(v);if(b&&b.contentHash===y)return b.result;let x=i(e,a.rootContext,a.isProduction,n),S=h(n,{...a.compilerOptions,filename:e,sourceMap:a.sourceMap??a.compilerOptions?.sourceMap??!0,ssr:c,vapor:l,isTs:o,scopeId:`data-v-${x}`}),C=r(n,m),w={code:S.code,css:S.css,errors:S.errors,warnings:S.warnings,scopeId:x,hasScoped:S.hasScoped,styles:S.styles.map(t),customBlocks:S.customBlocks.map(s),isCustomElement:d,templateAssetUrls:C,macroArtifacts:S.macroArtifacts??[]};return w.errors.length===0&&g.set(v,{contentHash:y,result:w}),w}const b=/\.ce\.vue$/;function x(e){let t=this.async(),r=this.getOptions(),i=this.resourcePath,s=this.resourceQuery,c=T(this,i),d=this.mode===`production`||process.env.NODE_ENV===`production`,f=!(r.ssr??!1)&&!d&&r.hotReload!==!1,p=C(this,r);if(this.addDependency(i),s?.includes(`type=style`)){t(Error(`[vize] Main loader received style sub-request: ${i}${s}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(s&&s.includes(`vue`)&&s.includes(`type=`)&&!s.includes(`type=style`)){let n=new URLSearchParams(s.slice(1)),r=n.get(`type`);if(r&&r!==`style`){let o=parseInt(n.get(`index`)||`0`,10),s=a(e)[o];if(s){if(s.src){let e=u.resolve(u.dirname(i),s.src);this.addDependency(e);try{t(null,l.readFileSync(e,`utf-8`))}catch{t(Error(`[vize] Custom block <${r} src="${s.src}"> not found (resolved: ${e}) in ${i}`))}return}t(null,s.content)}else t(null,``);return}}if(!S(i,r)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${i}. Passing through source unchanged.`)),t(null,e);return}try{let a=w(i,r.customElement),s=n(e),h=e;if(s.scriptSrc){let e=u.resolve(u.dirname(i),s.scriptSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);h=o(h,t,null)}catch{t(Error(`[vize] <script src="${s.scriptSrc}"> not found (resolved: ${e}) in ${i}`));return}}if(s.templateSrc){let e=u.resolve(u.dirname(i),s.templateSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);h=o(h,null,t)}catch{t(Error(`[vize] <template src="${s.templateSrc}"> not found (resolved: ${e}) in ${i}`));return}}let g=y(i,h,{sourceMap:r.sourceMap??this.sourceMap??!0,ssr:r.ssr??!1,vapor:r.vapor??!1,compilerOptions:r.compilerOptions,isCustomElement:a,rootContext:this.rootContext,isProduction:d,transformAssetUrls:r.transformAssetUrls});for(let e of g.warnings)this.emitWarning(Error(`[vize] ${e}`));if(g.errors.length>0){for(let e of g.errors)this.emitError(Error(`[vize] ${e}`));let e=g.errors.join(`\\n`);t(Error(`[vize] Compilation failed for ${i}:\n${e}`));return}t(null,m(g,{requestPath:c,hmr:f,filePath:i,isProduction:d,rootContext:this.rootContext,nativeCss:p}))}catch(e){t(e)}}function S(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function C(e,t){return t.css?.native==null?!!e._compiler?.options?.experiments?.css:t.css.native}function w(e,t){return t===!0?!0:t===!1||t===void 0?b.test(e):t.test(e)}function T(e,t){return`./${u.basename(t)}`}export{f as a,m as i,v as n,y as r,x as t};
24
+ `+n),n}const{compileSfc:v}=c,y=new Map;function b(e){return d(`sha256`).update(e).digest(`hex`).slice(0,16)}function x(){y.clear()}function S(e,n,a={}){let o=a.compilerOptions?.isTs??/<script[^>]*\blang=["']ts["']/.test(n),c=a.ssr??a.compilerOptions?.ssr??!1,l=a.vapor??a.compilerOptions?.vapor??!1,u=a.sourceMap??a.compilerOptions?.sourceMap??!0,d=a.isCustomElement??!1,f=a.rootContext??``,p=a.isProduction??!1,m=a.transformAssetUrls??!0,h=`${e}:ssr=${c}:vapor=${l}:ts=${o}:map=${u}:ce=${d}:root=${f}:prod=${p}:${m===!1?`tau=false`:m===!0?`tau=true`:`tau=${JSON.stringify(m)}`}`,g=b(n),_=y.get(h);if(_&&_.contentHash===g)return _.result;let x=i(e,a.rootContext,a.isProduction,n),S=v(n,{...a.compilerOptions,filename:e,sourceMap:a.sourceMap??a.compilerOptions?.sourceMap??!0,ssr:c,vapor:l,isTs:o,scopeId:`data-v-${x}`}),C=r(n,m),w={code:S.code,css:S.css,errors:S.errors,warnings:S.warnings,scopeId:x,hasScoped:S.hasScoped,styles:S.styles.map(t),customBlocks:S.customBlocks.map(s),isCustomElement:d,templateAssetUrls:C,macroArtifacts:S.macroArtifacts??[]};return w.errors.length===0&&y.set(h,{contentHash:g,result:w}),w}const C=/\.ce\.vue$/;function w(e){let t=this.async(),r=this.getOptions(),i=this.resourcePath,s=this.resourceQuery,c=O(this,i),d=this.mode===`production`||process.env.NODE_ENV===`production`,f=!(r.ssr??!1)&&!d&&r.hotReload!==!1,p=E(this,r);if(this.addDependency(i),s?.includes(`type=style`)){t(Error(`[vize] Main loader received style sub-request: ${i}${s}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(s&&s.includes(`vue`)&&s.includes(`type=`)&&!s.includes(`type=style`)){let n=new URLSearchParams(s.slice(1)),r=n.get(`type`);if(r&&r!==`style`){let o=parseInt(n.get(`index`)||`0`,10),s=a(e)[o];if(s){if(s.src){let e=u.resolve(u.dirname(i),s.src);this.addDependency(e);try{t(null,l.readFileSync(e,`utf-8`))}catch{t(Error(`[vize] Custom block <${r} src="${s.src}"> not found (resolved: ${e}) in ${i}`))}return}t(null,s.content)}else t(null,``);return}}if(!T(i,r)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${i}. Passing through source unchanged.`)),t(null,e);return}try{let a=D(i,r.customElement),s=n(e),m=e;if(s.scriptSrc){let e=u.resolve(u.dirname(i),s.scriptSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);m=o(m,t,null)}catch{t(Error(`[vize] <script src="${s.scriptSrc}"> not found (resolved: ${e}) in ${i}`));return}}if(s.templateSrc){let e=u.resolve(u.dirname(i),s.templateSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);m=o(m,null,t)}catch{t(Error(`[vize] <template src="${s.templateSrc}"> not found (resolved: ${e}) in ${i}`));return}}let h=S(i,m,{sourceMap:r.sourceMap??this.sourceMap??!0,ssr:r.ssr??!1,vapor:r.vapor??!1,compilerOptions:r.compilerOptions,isCustomElement:a,rootContext:this.rootContext,isProduction:d,transformAssetUrls:r.transformAssetUrls});for(let e of h.warnings)this.emitWarning(Error(`[vize] ${e}`));if(h.errors.length>0){for(let e of h.errors)this.emitError(Error(`[vize] ${e}`));let e=h.errors.join(`\\n`);t(Error(`[vize] Compilation failed for ${i}:\n${e}`));return}t(null,_(h,{requestPath:c,hmr:f,filePath:i,isProduction:d,rootContext:this.rootContext,nativeCss:p}))}catch(e){t(e)}}function T(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function E(e,t){let n=e._compiler;return m(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function D(e,t){return t===!0?!0:t===!1||t===void 0?C.test(e):t.test(e)}function O(e,t){return`./${u.basename(t)}`}export{h as a,_ as i,x as n,f as o,S as r,m as s,w as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/rspack-plugin",
3
- "version": "0.160.0",
3
+ "version": "0.162.0",
4
4
  "description": "High-performance Rspack plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -54,7 +54,7 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@vizejs/native": "0.160.0"
57
+ "@vizejs/native": "0.162.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@rspack/core": "2.0.3",
@@ -66,7 +66,7 @@
66
66
  "vite-plus": "0.1.21"
67
67
  },
68
68
  "peerDependencies": {
69
- "@rspack/core": ">=1.0.0"
69
+ "@rspack/core": "^1.0.0 || ^2.0.0"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=22"