11import fs from 'fs'
22import type { Plugin , ViteDevServer } from 'vite'
3- import { createFilter } from 'vite'
4- /* eslint-disable import/no-duplicates */
3+ import { createFilter } from '@rollup/pluginutils'
54import type {
65 SFCBlock ,
76 SFCScriptCompileOptions ,
87 SFCStyleCompileOptions ,
98 SFCTemplateCompileOptions
109} from 'vue/compiler-sfc'
1110import type * as _compiler from 'vue/compiler-sfc'
12- /* eslint-enable import/no-duplicates */
1311import { resolveCompiler } from './compiler'
1412import { parseVueRequest } from './utils/query'
1513import { getDescriptor , getSrcDescriptor } from './utils/descriptorCache'
@@ -34,32 +32,9 @@ export interface Options {
3432 template ?: Partial < SFCTemplateCompileOptions >
3533 style ?: Partial < SFCStyleCompileOptions >
3634
37- /**
38- * Transform Vue SFCs into custom elements.
39- * - `true`: all `*.vue` imports are converted into custom elements
40- * - `string | RegExp`: matched files are converted into custom elements
41- *
42- * @default /\.ce\.vue$/
43- */
44- customElement ?: boolean | string | RegExp | ( string | RegExp ) [ ]
45-
46- /**
47- * Enable Vue reactivity transform (experimental).
48- * https://github.com/vuejs/core/tree/master/packages/reactivity-transform
49- * - `true`: transform will be enabled for all vue,js(x),ts(x) files except
50- * those inside node_modules
51- * - `string | RegExp`: apply to vue + only matched files (will include
52- * node_modules, so specify directories in necessary)
53- * - `false`: disable in all cases
54- *
55- * @default false
56- */
57- reactivityTransform ?: boolean | string | RegExp | ( string | RegExp ) [ ]
58-
59- /**
60- * Use custom compiler-sfc instance. Can be used to force a specific version.
61- */
62- compiler ?: typeof _compiler
35+ // customElement?: boolean | string | RegExp | (string | RegExp)[]
36+ // reactivityTransform?: boolean | string | RegExp | (string | RegExp)[]
37+ // compiler?: typeof _compiler
6338}
6439
6540export interface ResolvedOptions extends Options {
@@ -74,33 +49,21 @@ export interface ResolvedOptions extends Options {
7449export default function vuePlugin ( rawOptions : Options = { } ) : Plugin {
7550 const {
7651 include = / \. v u e $ / ,
77- exclude,
78- customElement = / \. c e \. v u e $ / ,
79- reactivityTransform = false
52+ exclude
53+ // customElement = /\.ce\.vue$/,
54+ // reactivityTransform = false
8055 } = rawOptions
8156
8257 const filter = createFilter ( include , exclude )
8358
84- const customElementFilter =
85- typeof customElement === 'boolean'
86- ? ( ) => customElement
87- : createFilter ( customElement )
88-
89- const refTransformFilter =
90- reactivityTransform === false
91- ? ( ) => false
92- : reactivityTransform === true
93- ? createFilter ( / \. ( j | t ) s x ? $ / , / n o d e _ m o d u l e s / )
94- : createFilter ( reactivityTransform )
95-
9659 let options : ResolvedOptions = {
9760 isProduction : process . env . NODE_ENV === 'production' ,
9861 compiler : null as any , // to be set in buildStart
9962 ...rawOptions ,
10063 include,
10164 exclude,
102- customElement,
103- reactivityTransform,
65+ // customElement,
66+ // reactivityTransform,
10467 root : process . cwd ( ) ,
10568 sourceMap : true ,
10669 cssDevSourcemap : false ,
@@ -117,25 +80,13 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
11780 return handleHotUpdate ( ctx , options )
11881 } ,
11982
120- config ( config ) {
121- return {
122- define : {
123- __VUE_OPTIONS_API__ : config . define ?. __VUE_OPTIONS_API__ ?? true ,
124- __VUE_PROD_DEVTOOLS__ : config . define ?. __VUE_PROD_DEVTOOLS__ ?? false
125- } ,
126- ssr : {
127- external : [ 'vue' , '@vue/server-renderer' ]
128- }
129- }
130- } ,
131-
13283 configResolved ( config ) {
13384 options = {
13485 ...options ,
13586 root : config . root ,
87+ isProduction : config . isProduction ,
13688 sourceMap : config . command === 'build' ? ! ! config . build . sourcemap : true ,
13789 cssDevSourcemap : config . css ?. devSourcemap ?? false ,
138- isProduction : config . isProduction ,
13990 devToolsEnabled :
14091 ! ! config . define ! . __VUE_PROD_DEVTOOLS__ || ! config . isProduction
14192 }
@@ -146,7 +97,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
14697 } ,
14798
14899 buildStart ( ) {
149- options . compiler = options . compiler || resolveCompiler ( options . root )
100+ options . compiler = resolveCompiler ( options . root )
150101 } ,
151102
152103 async resolveId ( id ) {
@@ -200,29 +151,22 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
200151 return
201152 }
202153 if ( ! filter ( filename ) && ! query . vue ) {
203- if (
204- ! query . vue &&
205- refTransformFilter ( filename ) &&
206- options . compiler . shouldTransformRef ( code )
207- ) {
208- return options . compiler . transformRef ( code , {
209- filename,
210- sourceMap : true
211- } )
212- }
154+ // if (
155+ // !query.vue &&
156+ // refTransformFilter(filename) &&
157+ // options.compiler.shouldTransformRef(code)
158+ // ) {
159+ // return options.compiler.transformRef(code, {
160+ // filename,
161+ // sourceMap: true
162+ // })
163+ // }
213164 return
214165 }
215166
216167 if ( ! query . vue ) {
217168 // main request
218- return transformMain (
219- code ,
220- filename ,
221- options ,
222- this ,
223- ssr ,
224- customElementFilter ( filename )
225- )
169+ return transformMain ( code , filename , options , this , ssr )
226170 } else {
227171 // sub block request
228172 const descriptor = query . src
0 commit comments