Skip to content

Commit

Permalink
fix(vite-plugin): Fix auto-loading on prod (TS)
Browse files Browse the repository at this point in the history
Due to vitejs/vite#7909, when using TypeScript,
the template code gets turned into a script typed request on prod builds.
  • Loading branch information
yusufkandemir committed Sep 21, 2022
1 parent 4dd6385 commit 59ad455
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vite-plugin/src/query.js
Expand Up @@ -25,8 +25,15 @@ export function parseViteRequest (id) {

const is = query.vue !== void 0 // is vue query?
? {
// Almost all code might get merged into a single request with no 'type' (App.vue?vue)
// or stay with their original 'type's (App.vue?vue&type=script&lang.ts)
vue: () => true,
template: () => query.type === void 0 || query.type === 'template',
template: () =>
query.type === void 0 ||
query.type === 'template' ||
// On prod, TS code turns into a separate 'script' request.
// See: https://github.com/vitejs/vite/pull/7909
(query.type === 'script' && query['lang.ts']),
script: (extensions = scriptExt) =>
(query.type === void 0 || query.type === 'script') &&
isOfExt({ query, extensions }) === true,
Expand Down

0 comments on commit 59ad455

Please sign in to comment.