@@ -57,6 +57,12 @@ export default function loader(
57
57
) {
58
58
const loaderContext = this
59
59
60
+ if ( ! / \. v u e ( \. h t m l ) ? $ / . test ( loaderContext . resourcePath ) ) {
61
+ // ts-loader does some really weird stuff which causes vue-loader to
62
+ // somehow be applied on non-vue files... ignore them
63
+ return source
64
+ }
65
+
60
66
// check if plugin is installed
61
67
if (
62
68
! errorEmitted &&
@@ -150,8 +156,11 @@ export default function loader(
150
156
151
157
// script
152
158
let scriptImport = `const script = {}`
159
+ let isTS = false
153
160
const { script, scriptSetup } = descriptor
154
161
if ( script || scriptSetup ) {
162
+ const lang = script ?. lang || scriptSetup ?. lang
163
+ isTS = ! ! ( lang && / t s x ? / . test ( lang ) )
155
164
const src = ( script && ! scriptSetup && script . src ) || resourcePath
156
165
const attrsQuery = attrsToQuery ( ( scriptSetup || script ) ! . attrs , 'js' )
157
166
const query = `?vue&type=script${ attrsQuery } ${ resourceQuery } `
@@ -172,13 +181,8 @@ export default function loader(
172
181
const idQuery = `&id=${ id } `
173
182
const scopedQuery = hasScoped ? `&scoped=true` : ``
174
183
const attrsQuery = attrsToQuery ( descriptor . template . attrs )
175
- // const bindingsQuery = script
176
- // ? `&bindings=${JSON.stringify(script.bindings ?? {})}`
177
- // : ``
178
- // const varsQuery = descriptor.cssVars
179
- // ? `&vars=${qs.escape(generateCssVars(descriptor, id, isProduction))}`
180
- // : ``
181
- const query = `?vue&type=template${ idQuery } ${ scopedQuery } ${ attrsQuery } ${ resourceQuery } `
184
+ const tsQuery = isTS ? `&ts=true` : ``
185
+ const query = `?vue&type=template${ idQuery } ${ scopedQuery } ${ tsQuery } ${ attrsQuery } ${ resourceQuery } `
182
186
templateRequest = stringifyRequest ( src + query )
183
187
templateImport = `import { ${ renderFnName } } from ${ templateRequest } `
184
188
}
0 commit comments