vuetty 0.1.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.
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "rollup";
2
+
3
+ export interface VuettyPluginOptions {
4
+ featureFlags?: Record<string, string>;
5
+ compilerOptions?: Record<string, any>;
6
+ [key: string]: any;
7
+ }
8
+
9
+ export function vuettyPlugin(options?: VuettyPluginOptions): Plugin;
@@ -0,0 +1 @@
1
+ import{parse as e,compileScript as t}from"@vue/compiler-sfc";import{readFileSync as o}from"node:fs";function r(r={}){const n={__VUE_OPTIONS_API__:"true",__VUE_PROD_DEVTOOLS__:"false",__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:"false",...r.featureFlags||{}};return{name:"vuetty",transform(e,t){if(!/\.(js|jsx|ts|tsx|mjs|cjs)$/.test(t))return null;let o=e,r=!1;for(const[e,t]of Object.entries(n)){const n=new RegExp(e,"g");n.test(o)&&(o=o.replace(n,t),r=!0)}return r?{code:o,map:null}:null},load(n){if(!n.endsWith(".vue"))return null;const s=o(n,"utf-8"),{code:l,errors:c}=function(o,r,n={}){try{const{descriptor:s,errors:l}=e(o,{filename:r});if(l.length)return{code:"",errors:l.map(e=>({message:`SFC Parse Error: ${e.message}`,location:e.loc?{file:r,line:e.loc.start.line,column:e.loc.start.column}:void 0}))};let c="";if(s.script||s.scriptSetup)try{const e=t(s,{id:r,inlineTemplate:!0,templateOptions:{compilerOptions:{whitespace:"preserve",comments:!1,hoistStatic:!0,...n.compilerOptions}}});return c=e.content,{code:c,errors:[],map:e.map}}catch(e){return{code:"",errors:[{message:`Script/Template Compilation Error: ${e.message}`,location:e.loc?{file:r,line:e.loc.start.line,column:e.loc.start.column}:void 0}]}}return{code:"",errors:[{message:"SFC has no script or scriptSetup block",location:{file:r}}]}}catch(e){return{code:"",errors:[{message:`Unexpected SFC Compilation Error: ${e.message}`,location:{file:r}}]}}}(s,n,r);if(c.length>0){const e=c.map(e=>`${e.message}${e.location?` at ${e.location.file}:${e.location.line}:${e.location.column}`:""}`).join("\n");this.error(`Vuetty SFC compilation failed:\n${e}`)}return{code:l,map:null}}}}export{r as vuettyPlugin};