Skip to content

Commit b50fa56

Browse files
authoredOct 7, 2023
fix: re-use ident of vue rule for template compiler, fixes #2029 (#2030)
1 parent 98782e7 commit b50fa56

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎src/pluginWebpack4.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ class VueLoaderPlugin {
8686
const parsed = qs.parse(query.slice(1))
8787
return parsed.vue != null && parsed.type === 'template'
8888
},
89-
options: vueLoaderOptions,
89+
options: {
90+
ident: vueLoaderUse.ident,
91+
...vueLoaderOptions,
92+
},
9093
}
9194

9295
// for each rule that matches plain .js/.ts files, also create a clone and

‎test/edgeCases.spec.ts

+27
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,30 @@ test('should work with i18n loader in production mode', async () => {
239239

240240
expect(result.componentModule.__i18n).toHaveLength(1)
241241
})
242+
243+
// #2029
244+
test('should pass correct options to template compiler', async () => {
245+
const fakeCompiler: any = {
246+
compile: jest
247+
.fn()
248+
.mockReturnValue({ code: 'export function render() { return null; }' }),
249+
}
250+
251+
await mockBundleAndRun({
252+
entry: 'basic.vue',
253+
modify: (config: any) => {
254+
config.module.rules[0].options = {
255+
compiler: fakeCompiler,
256+
}
257+
config.module.rules.push(
258+
...Array.from({ length: 10 }).map((_, i) => ({
259+
test: new RegExp(`\.dummy${i}`),
260+
loader: 'null-loader',
261+
options: { dummyRule: i },
262+
}))
263+
)
264+
},
265+
})
266+
267+
expect(fakeCompiler.compile).toHaveBeenCalledTimes(1)
268+
})

0 commit comments

Comments
 (0)
Please sign in to comment.