Skip to content

Commit 982ee0e

Browse files
committed
fix(plugin-vue): Support decorators in .vue file.
issues: vitejs#430 More thoughts: So should we not hard-code loader:'ts' and target:'es2020; { target: 'esnext', // vitejs#430 Support decorators in .vue file. vitejs#430 // target can be overridden by esbuild config target ...options.devServer?.config.esbuild, loader: 'ts', sourcemap: options.sourceMap, }, Just for fault tolerance and compatibility considerations vite is the basic component of vite-plugin-vue. When vite-plugin-vue calls the transformWithEsbuild function provided by vite:esbuild in the vite project, should it be consistent with the parameters of vite:esbuild calling transformWithEsbuild, that is, esbuildTransformOptions, that is, options.devServer?.config.esbuild in the development environment transformWithEsbuild( resolvedCode, filename, options.devServer?.config.esbuild || {}, resolvedMap, ) Because the running results of vite in the development environment and the production environment should be consistent, it is also necessary to keep it consistent with the parameters passed in when vite:esbuild calls the transformWithEsbuild function This code will only be triggered in the development environment, so it is correct to use options.devServer?.config.esbuild
1 parent 6ea0ec5 commit 982ee0e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/plugin-vue/src/main.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,11 @@ export async function transformMain(
249249
resolvedCode,
250250
filename,
251251
{
252-
loader: 'ts',
253252
target: 'esnext',
253+
// #430 Support decorators in .vue file. https://github.com/vitejs/vite-plugin-vue/issues/430
254+
// target can be overridden by esbuild config target
255+
...options.devServer?.config.esbuild,
256+
loader: 'ts',
254257
sourcemap: options.sourceMap,
255258
},
256259
resolvedMap,

0 commit comments

Comments
 (0)