@vizejs/rspack-plugin 0.88.0 → 0.90.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.
@@ -105,6 +105,10 @@ interface VizeLoaderOptions {
105
105
  vapor?: boolean;
106
106
  /** HMR. false to disable in dev. @default true (dev), false (prod/SSR) */
107
107
  hotReload?: boolean;
108
+ /** CSS handling config */
109
+ css?: {
110
+ /** Native CSS (experiments.css), uses LightningCSS @default auto-detected */native?: boolean;
111
+ };
108
112
  /**
109
113
  * Transform static asset URLs in templates into import bindings.
110
114
  * true=built-in tags, false=disabled, object=custom map. @default true
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-DQt-9mal.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-BA-YuYIM.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";
@@ -68,7 +68,8 @@ declare function generateOutput(compiled: CompiledModule, options: {
68
68
  hmr?: boolean; /** Original file path (for __file exposure in dev mode) */
69
69
  filePath?: string; /** Whether this is a production build */
70
70
  isProduction?: boolean; /** Project root context (for computing relative __file path) */
71
- rootContext?: string;
71
+ rootContext?: string; /** Whether Rspack native CSS is handling CSS module exports */
72
+ nativeCss?: boolean;
72
73
  }): string;
73
74
  //#endregion
74
75
  export { type CompiledModule, type CustomBlockInfo, 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, extractCustomBlocks, extractSrcInfo, extractStyleBlocks, genHotReloadCode, generateOutput, generateScopeId, inlineSrcBlocks, matchesPattern, 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-BW6CWIY4.mjs";import{a as s,i as c,n as l,r as u,t as d}from"./loader-CftyCUa0.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){let n=S(e.rule,e.lang,t);n&&o.push(n)}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 null;let i={resourceQuery:RegExp(`(?=.*type=style)(?=.*lang=${t})`),use:[{loader:h},...D(r),{loader:m}]};return e.type?i.type=e.type:n&&(i.type=`css/auto`),i}function C(e){let t=/(?=.*type=style)(?=.*lang=css)/;return e?{resourceQuery:t,type:`css/auto`,use:[{loader:h},{loader:m}]}:{resourceQuery:t,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-BW6CWIY4.mjs";import{a as s,i as c,n as l,r as u,t as d}from"./loader-G4-4uHYx.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,4 +1,4 @@
1
- import { l as VizeLoaderOptions } from "../index-DQt-9mal.mjs";
1
+ import { l as VizeLoaderOptions } from "../index-BA-YuYIM.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-CftyCUa0.mjs";export{e as default};
1
+ import{t as e}from"../loader-G4-4uHYx.mjs";export{e as default};
@@ -1,4 +1,4 @@
1
- import { d as VizeStyleLoaderOptions } from "../index-DQt-9mal.mjs";
1
+ import { d as VizeStyleLoaderOptions } from "../index-BA-YuYIM.mjs";
2
2
  import { LoaderContext } from "@rspack/core";
3
3
 
4
4
  //#region src/loader/style-loader.d.ts
@@ -14,11 +14,11 @@ if (module.hot) {
14
14
  __VUE_HMR_RUNTIME__.rerender("${e}")
15
15
  })
16
16
  }`}const{compileSfc:p}=u,m=new Map;function h(e){return s(`sha256`).update(e).digest(`hex`).slice(0,16)}function g(){m.clear()}function _(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??``,g=o.isProduction??!1,_=o.transformAssetUrls??!0,v=`${t}:ssr=${c}:vapor=${l}:ts=${s}:map=${u}:ce=${d}:root=${f}:prod=${g}:${_===!1?`tau=false`:_===!0?`tau=true`:`tau=${JSON.stringify(_)}`}`,y=h(n),b=m.get(v);if(b&&b.contentHash===y)return b.result;let x=i(t,o.rootContext,o.isProduction,n),S=/<style[^>]*\bscoped\b/.test(n),C=p(n,{...o.compilerOptions,filename:t,sourceMap:o.sourceMap??o.compilerOptions?.sourceMap??!0,ssr:c,vapor:l,isTs:s,scopeId:S?`data-v-${x}`:void 0}),w=e(n),T=a(n),E=r(n,_),D={code:C.code,css:C.css,errors:C.errors,warnings:C.warnings,scopeId:x,hasScoped:S,styles:w,customBlocks:T,isCustomElement:d,templateAssetUrls:E,macroArtifacts:C.macroArtifacts??[]};return D.errors.length===0&&m.set(v,{contentHash:y,result:D}),D}function v(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
- 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`]:[]].join(`&`),a=`${t.requestPath}?${i}`;if(r)return`import _style_${n.index} from ${JSON.stringify(a)};`;if(n.module){let e=typeof n.module==`string`?n.module:`$style`,t=`_cssModule_${n.index}`;return o.push({request:a,varName:t,bindingName:e}),`import ${t} from ${JSON.stringify(a)};`}return`import ${JSON.stringify(a)};`}).join(`
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`]:[]].join(`&`),a=`${t.requestPath}?${i}`;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
20
  `),i=t.hmr&&e.scopeId?o.map(t=>f(e.scopeId,JSON.stringify(t.request),t.varName,t.bindingName)).join(`
21
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?c.relative(t.rootContext,t.filePath).replace(/\\/g,`/`):c.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,`${d(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=r.join(`&`),a=t.requestPath;return`import block${n} from ${JSON.stringify(`${a}?${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 y=/\.ce\.vue$/;function b(e){let t=this.async(),r=this.getOptions(),i=this.resourcePath,s=this.resourceQuery,u=C(this,i),d=this.mode===`production`||process.env.NODE_ENV===`production`,f=!(r.ssr??!1)&&!d&&r.hotReload!==!1;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=c.resolve(c.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(!x(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=S(i,r.customElement),s=n(e),p=e;if(s.scriptSrc){let e=c.resolve(c.dirname(i),s.scriptSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);p=o(p,t,null)}catch{t(Error(`[vize] <script src="${s.scriptSrc}"> not found (resolved: ${e}) in ${i}`));return}}if(s.templateSrc){let e=c.resolve(c.dirname(i),s.templateSrc);this.addDependency(e);try{let t=l.readFileSync(e,`utf-8`);p=o(p,null,t)}catch{t(Error(`[vize] <template src="${s.templateSrc}"> not found (resolved: ${e}) in ${i}`));return}}let m=_(i,p,{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 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`);t(Error(`[vize] Compilation failed for ${i}:\n${e}`));return}t(null,v(m,{requestPath:u,hmr:f,filePath:i,isProduction:d,rootContext:this.rootContext}))}catch(e){t(e)}}function x(e,n){return!(!t(e,n.include,!0)||t(e,n.exclude,!1))}function S(e,t){return t===!0?!0:t===!1||t===void 0?y.test(e):t.test(e)}function C(e,t){return`./${c.basename(t)}`}export{d as a,v as i,g as n,_ as r,b as t};
24
+ `+n),n}const y=/\.ce\.vue$/;function b(e){let t=this.async(),r=this.getOptions(),i=this.resourcePath,s=this.resourceQuery,u=w(this,i),d=this.mode===`production`||process.env.NODE_ENV===`production`,f=!(r.ssr??!1)&&!d&&r.hotReload!==!1,p=S(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=c.resolve(c.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(!x(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=C(i,r.customElement),s=n(e),m=e;if(s.scriptSrc){let e=c.resolve(c.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=c.resolve(c.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=_(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,v(h,{requestPath:u,hmr:f,filePath:i,isProduction:d,rootContext:this.rootContext,nativeCss:p}))}catch(e){t(e)}}function x(e,n){return!(!t(e,n.include,!0)||t(e,n.exclude,!1))}function S(e,t){return t.css?.native==null?!!e._compiler?.options?.experiments?.css:t.css.native}function C(e,t){return t===!0?!0:t===!1||t===void 0?y.test(e):t.test(e)}function w(e,t){return`./${c.basename(t)}`}export{d as a,v as i,g as n,_ as r,b as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/rspack-plugin",
3
- "version": "0.88.0",
3
+ "version": "0.90.0",
4
4
  "description": "High-performance Rspack plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@vizejs/native": "0.88.0"
53
+ "@vizejs/native": "0.90.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@rspack/core": "2.0.3",