1
1
import { CallExpression , Node , ObjectPattern , Program } from '@babel/types'
2
2
import { SFCDescriptor } from '../parse'
3
- import { generateCodeFrame } from '@vue/shared'
3
+ import { generateCodeFrame , isArray } from '@vue/shared'
4
4
import { parse as babelParse , ParserPlugin } from '@babel/parser'
5
5
import { ImportBinding , SFCScriptCompileOptions } from '../compileScript'
6
6
import { PropsDestructureBindings } from './defineProps'
@@ -155,6 +155,17 @@ export function resolveParserPlugins(
155
155
dts = false
156
156
) {
157
157
const plugins : ParserPlugin [ ] = [ ]
158
+ if (
159
+ ! userPlugins ||
160
+ ! userPlugins . some (
161
+ p =>
162
+ p === 'importAssertions' ||
163
+ p === 'importAttributes' ||
164
+ ( isArray ( p ) && p [ 0 ] === 'importAttributes' )
165
+ )
166
+ ) {
167
+ plugins . push ( 'importAttributes' )
168
+ }
158
169
if ( lang === 'jsx' || lang === 'tsx' ) {
159
170
plugins . push ( 'jsx' )
160
171
} else if ( userPlugins ) {
@@ -163,7 +174,7 @@ export function resolveParserPlugins(
163
174
userPlugins = userPlugins . filter ( p => p !== 'jsx' )
164
175
}
165
176
if ( lang === 'ts' || lang === 'tsx' ) {
166
- plugins . push ( [ 'typescript' , { dts } ] )
177
+ plugins . push ( [ 'typescript' , { dts } ] , 'explicitResourceManagement' )
167
178
if ( ! userPlugins || ! userPlugins . includes ( 'decorators' ) ) {
168
179
plugins . push ( 'decorators-legacy' )
169
180
}
0 commit comments