Skip to content

Commit

Permalink
fix: re-use ident of vue rule for template compiler, fixes #2029 (#2030)
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Oct 7, 2023
1 parent 98782e7 commit b50fa56
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pluginWebpack4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ class VueLoaderPlugin {
const parsed = qs.parse(query.slice(1))
return parsed.vue != null && parsed.type === 'template'
},
options: vueLoaderOptions,
options: {
ident: vueLoaderUse.ident,
...vueLoaderOptions,
},
}

// for each rule that matches plain .js/.ts files, also create a clone and
Expand Down
27 changes: 27 additions & 0 deletions test/edgeCases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,30 @@ test('should work with i18n loader in production mode', async () => {

expect(result.componentModule.__i18n).toHaveLength(1)
})

// #2029
test('should pass correct options to template compiler', async () => {
const fakeCompiler: any = {
compile: jest
.fn()
.mockReturnValue({ code: 'export function render() { return null; }' }),
}

await mockBundleAndRun({
entry: 'basic.vue',
modify: (config: any) => {
config.module.rules[0].options = {
compiler: fakeCompiler,
}
config.module.rules.push(
...Array.from({ length: 10 }).map((_, i) => ({
test: new RegExp(`\.dummy${i}`),
loader: 'null-loader',
options: { dummyRule: i },
}))
)
},
})

expect(fakeCompiler.compile).toHaveBeenCalledTimes(1)
})

0 comments on commit b50fa56

Please sign in to comment.