Skip to content

Commit

Permalink
fix(plugin-vue): avoid applying ref transform to dependencies by default
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 6, 2021
1 parent 9679b3a commit 9a0c54a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
16 changes: 16 additions & 0 deletions packages/plugin-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ export interface Options {
*/
customElement?: boolean | string | RegExp | (string | RegExp)[]

/**
* Enable Vue ref transform (experimental).
* https://github.com/vuejs/vue-next/tree/master/packages/ref-transform
*
* **requires Vue \>= 3.2.5**
*
* - `true`: transform will be enabled for all vue,js(x),ts(x) files except
* those inside node_modules
* - `string | RegExp`: apply to vue + only matched files (will include
* node_modules, so specify directories in necessary)
* - `false`: disable in all cases
*
* @default false
*/
refTransform?: boolean | string | RegExp | (string | RegExp)[]

// options to pass on to @vue/compiler-sfc
script?: Partial<SFCScriptCompileOptions>
template?: Partial<SFCTemplateCompileOptions>
Expand Down
11 changes: 8 additions & 3 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ export interface Options {

/**
* Enable Vue ref transform (experimental).
* https://github.com/vuejs/vue-next/tree/master/packages/ref-transform
*
* **requires Vue \>= 3.2.5**
* - `true`: transform will be enabled for all vue,js(x),ts(x) files
* - `string | RegExp`: apply to vue + only matched files
*
* - `true`: transform will be enabled for all vue,js(x),ts(x) files except
* those inside node_modules
* - `string | RegExp`: apply to vue + only matched files (will include
* node_modules, so specify directories in necessary)
* - `false`: disable in all cases
*
* @default false
Expand Down Expand Up @@ -97,7 +102,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
refTransform === false
? () => false
: refTransform === true
? createFilter(/\.(j|t)sx?$/)
? createFilter(/\.(j|t)sx?$/, /node_modules/)
: createFilter(refTransform)

// compat for older verisons
Expand Down

0 comments on commit 9a0c54a

Please sign in to comment.