@vizejs/rspack-plugin 0.691.0 → 0.692.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.
@@ -1,4 +1,4 @@
1
- import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-D_f3YvFb.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){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===3&&Array.isArray(t.sources)&&Array.isArray(t.names)&&typeof t.mappings==`string`}function p(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return f(t)?t:null}function m(e){let t=0;for(let n=e.indexOf(`
1
+ import{d as e,f as t,m as n,n as r,o as i,u as a}from"./utils-BdfkHIOi.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){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===3&&Array.isArray(t.sources)&&Array.isArray(t.names)&&typeof t.mappings==`string`}function p(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return f(t)?t:null}function m(e){let t=0;for(let n=e.indexOf(`
2
2
  `);n!==-1;n=e.indexOf(`
3
3
  `,n+1))t++;return t}function h(e,t,n){if(n<=0)return e;let r=e.mappings.split(`;`);if(t>=r.length)return e;let i=[...r.slice(0,t),...Array(n).fill(``),...r.slice(t)];return{...e,mappings:i.join(`;`)}}function g(e,t,n){let r=n+e;if(!n)return{code:r,map:t??null};let i=p(t);return!i||!n.endsWith(`
4
4
  `)?{code:r,map:null}:{code:r,map:JSON.stringify(h(i,0,m(n)))}}function _(e,t){return`{
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-D_f3YvFb.mjs";import{n as s,r as c,t as l}from"./loader-Cdt6ENIR.mjs";import{a as u,i as d,n as f,r as p,s as m,t as h}from"./compiler-BnMF4Q4d.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]},e.splice(r+1,0,{resourceQuery:/(?=.*\bvue\b)(?=.*type=style)(?=.*&src(?:&|$))/,oneOf:o.map(e=>({...e,use:z(L(e.use))}))});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 n===`css/module`&&(!e.type||e.type===`css/auto`)?r.type=n: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};
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-BdfkHIOi.mjs";import{n as s,r as c,t as l}from"./loader-DRaxL-wP.mjs";import{a as u,i as d,n as f,r as p,s as m,t as h}from"./compiler-_A74bJSH.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]},e.splice(r+1,0,{resourceQuery:/(?=.*\bvue\b)(?=.*type=style)(?=.*&src(?:&|$))/,oneOf:o.map(e=>({...e,use:z(L(e.use))}))});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 n===`css/module`&&(!e.type||e.type===`css/auto`)?r.type=n: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};
@@ -1 +1 @@
1
- import{t as e}from"../loader-Cdt6ENIR.mjs";export{e as default};
1
+ import{t as e}from"../loader-DRaxL-wP.mjs";export{e as default};
@@ -1 +1 @@
1
- import{c as e,m as t}from"../utils-D_f3YvFb.mjs";import{r as n}from"../compiler-BnMF4Q4d.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
+ import{c as e,m as t}from"../utils-BdfkHIOi.mjs";import{r as n}from"../compiler-_A74bJSH.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-D_f3YvFb.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
+ import{l as e}from"../utils-BdfkHIOi.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-D_f3YvFb.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}if(s.has(`src`)){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};
1
+ import{a as e}from"../utils-BdfkHIOi.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}if(s.has(`src`)){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-BdfkHIOi.mjs";import{n as a,o}from"./compiler-_A74bJSH.mjs";import{parseSfc as s}from"@vizejs/native";import c from"node:fs";import l from"node:path";import{sources as u}from"@rspack/core";function d(e){let t=e?.experiments;return!t||typeof t!=`object`||!Object.prototype.hasOwnProperty.call(t,`css`)?`unavailable`:t.css?`enabled`:`disabled`}function f(e){if(typeof e!=`string`)return null;let t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}function p(e,t,n){if(e!=null)return e;let r=d(t);if(r!==`unavailable`)return r===`enabled`;let i=f(n);return i!=null&&i>=2}const m=/\.ce\.vue$/;function h(e){let d=this.async(),f=this.getOptions(),p=this.resourcePath,m=this.resourceQuery,h=y(this,p),b=f.isProduction??(this.mode===`production`||process.env.NODE_ENV===`production`),x=f.ssr??f.compilerOptions?.ssr??!1,S=!x&&!b&&f.hotReload!==!1,C=_(this,f),w=f.sourceMap??f.compilerOptions?.sourceMap??this.sourceMap??!b;if(this.addDependency(p),m?.includes(`type=style`)){d(Error(`[vize] Main loader received style sub-request: ${p}${m}. Use module.rules[].oneOf with resourceQuery branches so style requests are handled by @vizejs/rspack-plugin/style-loader.`));return}if(m&&m.includes(`vue`)&&m.includes(`type=`)&&!m.includes(`type=style`)){let t=new URLSearchParams(m.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(p),a.src);this.addDependency(e);try{d(null,c.readFileSync(e,`utf-8`))}catch{d(Error(`[vize] Custom block <${n} src="${a.src}"> not found (resolved: ${e}) in ${p}`))}return}d(null,a.content)}else d(null,``);return}}if(!g(p,f)){this.emitWarning(Error(`[vize] File is filtered out by loader options include/exclude: ${p}. Passing through source unchanged.`)),d(null,e);return}try{let i=v(p,f.customElement),m=n(e),g=new t(e,w&&(m.scriptSrc||m.templateSrc)?new u.OriginalSource(e,p).map({columns:!0}):null);if(m.scriptSrc){let e=l.resolve(l.dirname(p),m.scriptSrc);this.addDependency(e);try{r(g,s,`script`,c.readFileSync(e,`utf-8`),{filename:e,sourceFilename:p})}catch{d(Error(`[vize] <script src="${m.scriptSrc}"> not found (resolved: ${e}) in ${p}`));return}}if(m.templateSrc){let e=l.resolve(l.dirname(p),m.templateSrc);this.addDependency(e);try{r(g,s,`template`,c.readFileSync(e,`utf-8`),{filename:e,sourceFilename:p})}catch{d(Error(`[vize] <template src="${m.templateSrc}"> not found (resolved: ${e}) in ${p}`));return}}let _=f.root?l.resolve(this.rootContext,f.root):this.rootContext,y=a(p,g.code,{sourceMap:w,ssr:x,vapor:f.vapor??f.compilerOptions?.vapor??!1,compilerOptions:f.compilerOptions,isCustomElement:i,rootContext:_,isProduction:b,transformAssetUrls:f.transformAssetUrls});for(let e of y.warnings)this.emitWarning(Error(`[vize] ${e}`));if(y.errors.length>0){for(let e of y.errors)this.emitError(Error(`[vize] ${e}`));let e=y.errors.join(`\\n`);d(Error(`[vize] Compilation failed for ${p}:\n${e}`));return}let T=o(y,{requestPath:h,hmr:S,filePath:p,isProduction:b,rootContext:_,nativeCss:C}),E=T.map&&g.map?new u.SourceMapSource(T.code,p,JSON.stringify(T.map),g.code,JSON.stringify(g.map),!0).map({columns:!0}):T.map;d(null,T.code,E?JSON.stringify(E):void 0)}catch(e){d(e)}}function g(t,n){return!(!e(t,n.include,!0)||e(t,n.exclude,!1))}function _(e,t){let n=e._compiler;return p(t.css?.native,n?.options,n?.webpack?.rspackVersion)}function v(e,t){return t===!0?!0:t===!1||t===void 0?m.test(e):t.test(e)}function y(e,t){return`./${l.basename(t)}`}export{d as n,p as r,h as t};
@@ -0,0 +1 @@
1
+ import{collectSfcTemplateAssetUrls as e,extractSfcCustomBlocks as t,extractSfcSrcInfo as n,extractSfcStyleBlocks as r,generateSfcScopeId as i,parseSfc as a,scopeViteCssForPipeline as o,stripSfcScopedCssComments as s}from"@vizejs/native";import c from"webpack-sources";import{diffChars as l}from"diff";import"node:fs";import"node:path";const u=/\s*([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gy;function d(e,t){let n=`<${e}`;if(!t.toLowerCase().startsWith(n))return null;let r=t.slice(n.length).replace(/\s*\/?\s*>$/,``),i=``,a=null,o=0;u.lastIndex=0;for(let e=u.exec(r);e;e=u.exec(r))o=u.lastIndex,e[1].toLowerCase()===`src`&&a===null?a=e[2]??e[3]??e[4]??``:i+=e[0];if(a===null||o!==r.length)return null;let s=i&&!/^\s/u.test(i)?` ${i}`:i;return{src:a,openTag:`${n}${s}>`}}function f(e,t){let n=`is compiled into the component, so vize needs its contents`;return e===`template`?`the template ${n}`:e===`script setup`?`<script setup> ${n}`:t.scoped?`a scoped style needs its contents`:t.module?`a CSS module needs its contents`:null}function p(e,t,n,r){let i;try{i=e(r,{filename:t})}catch{return[]}let a=[[`template`,i.template],[`script`,i.script],[`script setup`,i.scriptSetup],...i.styles.map((e,t)=>[`style`,e,t])],o=[];for(let[e,t,r]of a){if(!t)continue;let i=e===`script setup`?`script`:e,{start:a,tagStart:s,tagEnd:c}=t.loc,l=d(i,n.subarray(s,a).toString(`utf8`));l&&o.push({kind:e,tag:i,...l,tagStart:s,tagEnd:c,styleIndex:r,needsContents:f(e,t)})}return o}function m(e,t,n,r){return p(e,t,Buffer.from(n),n).find(e=>e.tag===r)}function h(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 g=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=l(t,e,{maxEditLength:1e4,timeout:100});if(!n){this.map=null;return}let r=new c.SourceMapSource(t,this.map.file??`sfc.js`,JSON.stringify(this.map)),i=new c.ConcatSource,a=0;for(let e of n)e.added?i.add(e.value):(e.removed||i.add(v(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 c.SourceMapSource(r,this.map.file??`sfc.js`,JSON.stringify(this.map));this.map=new c.ConcatSource(v(a,r.length,0,e),n,v(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 _(e,t,n,r,i={}){let a=m(t,i.sourceFilename??`anonymous.vue`,e.code,n);if(!a)return;let o=Buffer.from(e.code),s=o.subarray(0,a.tagStart).toString(`utf8`).length,l=o.subarray(0,a.tagEnd).toString(`utf8`).length;e.replace(s,l,new c.ConcatSource(`${a.openTag}\n`,i.filename?new c.OriginalSource(r,i.filename):r,`\n</${n}>`))}function v(e,t,n,r){if(n===r)return new c.RawSource(``);let i=new c.ReplaceSource(e);return n>0&&i.replace(0,n-1,``),r<t&&i.replace(r,t-1,``),i}function y(e,t,n,r){return i(e,t,n,r)}function b(e){return r(e).map(A)}function x(e){return s(e)}function S(e,t){return o(e,t.startsWith(`data-v-`)?t:`data-v-${t}`)}function C(e){return t(e).map(j)}function w(e){let t=n(e);return{scriptSrc:t.scriptSrc??null,templateSrc:t.templateSrc??null}}function T(e,t,n){let r=new g(e,null);return t!==null&&_(r,a,`script`,t),n!==null&&_(r,a,`template`,n),r.code}function E(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):D(t,r))}function D(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 O(t,n){return n===!1?[]:e(t,k(n))}function k(e){if(!(e==null||e===!0))return Object.entries(e).map(([e,t])=>({tag:e,attrs:t}))}function A(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 j(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{b as a,E as c,A as d,g as f,w as i,x as l,h as m,O as n,y as o,_ as p,C as r,T as s,S as t,j as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/rspack-plugin",
3
- "version": "0.691.0",
3
+ "version": "0.692.0",
4
4
  "description": "High-performance Rspack plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -59,7 +59,7 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@vizejs/native": "0.691.0",
62
+ "@vizejs/native": "0.692.0",
63
63
  "diff": "8.0.4",
64
64
  "oxc-parser": "0.144.0",
65
65
  "oxc-transform": "0.144.0",
@@ -1 +0,0 @@
1
- import{c as e,f as t,i as n,p as r,r as i}from"./utils-D_f3YvFb.mjs";import{n as a,o}from"./compiler-BnMF4Q4d.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};
@@ -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";import s from"webpack-sources";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};