@@ -57,6 +57,12 @@ export default function loader(
5757) {
5858 const loaderContext = this
5959
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+
6066 // check if plugin is installed
6167 if (
6268 ! errorEmitted &&
@@ -150,8 +156,11 @@ export default function loader(
150156
151157 // script
152158 let scriptImport = `const script = {}`
159+ let isTS = false
153160 const { script, scriptSetup } = descriptor
154161 if ( script || scriptSetup ) {
162+ const lang = script ?. lang || scriptSetup ?. lang
163+ isTS = ! ! ( lang && / t s x ? / . test ( lang ) )
155164 const src = ( script && ! scriptSetup && script . src ) || resourcePath
156165 const attrsQuery = attrsToQuery ( ( scriptSetup || script ) ! . attrs , 'js' )
157166 const query = `?vue&type=script${ attrsQuery } ${ resourceQuery } `
@@ -172,13 +181,8 @@ export default function loader(
172181 const idQuery = `&id=${ id } `
173182 const scopedQuery = hasScoped ? `&scoped=true` : ``
174183 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 } `
182186 templateRequest = stringifyRequest ( src + query )
183187 templateImport = `import { ${ renderFnName } } from ${ templateRequest } `
184188 }
0 commit comments