@vizejs/rspack-plugin 0.73.0 → 0.75.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/dist/{index-CrdHfSbU.d.mts → index-DQt-9mal.d.mts} +13 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/loader/index.d.mts +1 -1
- package/dist/loader/index.mjs +1 -1
- package/dist/loader/style-loader.d.mts +1 -1
- package/dist/{loader-BGVyAZvr.mjs → loader-CWfWX55h.mjs} +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,15 @@ interface SfcCompileOptionsNapi {
|
|
|
11
11
|
/** Scope ID for scoped CSS (e.g., "data-v-abc123") */
|
|
12
12
|
scopeId?: string;
|
|
13
13
|
}
|
|
14
|
+
interface MacroArtifact {
|
|
15
|
+
kind: string;
|
|
16
|
+
name: string;
|
|
17
|
+
source: string;
|
|
18
|
+
content: string;
|
|
19
|
+
moduleCode?: string;
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
}
|
|
14
23
|
interface SfcCompileResultNapi {
|
|
15
24
|
code: string;
|
|
16
25
|
css?: string;
|
|
@@ -18,6 +27,7 @@ interface SfcCompileResultNapi {
|
|
|
18
27
|
map?: string;
|
|
19
28
|
errors: string[];
|
|
20
29
|
warnings: string[];
|
|
30
|
+
macroArtifacts?: MacroArtifact[];
|
|
21
31
|
}
|
|
22
32
|
interface StyleBlockInfo {
|
|
23
33
|
/** Raw style content */
|
|
@@ -73,6 +83,8 @@ interface CompiledModule {
|
|
|
73
83
|
isCustomElement: boolean;
|
|
74
84
|
/** Static asset URLs needing import rewrite. Empty when transformAssetUrls is false. */
|
|
75
85
|
templateAssetUrls: TemplateAssetUrl[];
|
|
86
|
+
/** Compile-time macro artifacts extracted from the source SFC. */
|
|
87
|
+
macroArtifacts?: MacroArtifact[];
|
|
76
88
|
}
|
|
77
89
|
interface VizeLoaderOptions {
|
|
78
90
|
/** Source maps @default true */
|
|
@@ -142,4 +154,4 @@ type LoaderEntry = string | {
|
|
|
142
154
|
options?: Record<string, unknown>;
|
|
143
155
|
};
|
|
144
156
|
//#endregion
|
|
145
|
-
export {
|
|
157
|
+
export { SfcCompileOptionsNapi as a, StyleBlockInfo as c, VizeStyleLoaderOptions as d, MacroArtifact as i, VizeLoaderOptions as l, CustomBlockInfo as n, SfcCompileResultNapi as o, LoaderEntry as r, SfcSrcInfo as s, CompiledModule as t, VizeRspackPluginOptions as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
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";
|
|
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";
|
|
@@ -71,4 +71,4 @@ declare function generateOutput(compiled: CompiledModule, options: {
|
|
|
71
71
|
rootContext?: string;
|
|
72
72
|
}): string;
|
|
73
73
|
//#endregion
|
|
74
|
-
export { type CompiledModule, type CustomBlockInfo, type LoaderEntry, 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 };
|
|
74
|
+
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-DDd2p4Wp.mjs";import{a as s,i as c,n as l,r as u,t as d}from"./loader-
|
|
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-DDd2p4Wp.mjs";import{a as s,i as c,n as l,r as u,t as d}from"./loader-CWfWX55h.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};
|
package/dist/loader/index.d.mts
CHANGED
package/dist/loader/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../loader-
|
|
1
|
+
import{t as e}from"../loader-CWfWX55h.mjs";export{e as default};
|
|
@@ -13,7 +13,7 @@ if (module.hot) {
|
|
|
13
13
|
_sfc_main.__cssModules[${JSON.stringify(r)}] = ${n}
|
|
14
14
|
__VUE_HMR_RUNTIME__.rerender("${e}")
|
|
15
15
|
})
|
|
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};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+=`
|
|
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
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(`
|
|
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(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/rspack-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.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.
|
|
53
|
+
"@vizejs/native": "0.75.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@rspack/core": "1.7.11",
|