underfin / vite-plugin-vue2

Vue2 plugin for Vite
621 stars 84 forks source link

losing esbuild param:'target' when transform script tag in .vue files #112

Closed DeAntiWang closed 3 years ago

DeAntiWang commented 3 years ago

Hello!

I'm trying to transform ES version of .vue files when vite serve mode, even through it will cause performance reducing. But I found that the params 'target' of func 'transformWithEsbuild' is losing.

image

Will it support in the future that allowing syntax conversions? It's important to me.

like that:

// vite.config.ts
...
plugins: [
    createVuePlugin({
        target: 'es6'
    });
],
...

// vite-plugin-vue2/dist/main.js

async function genScriptCode(...) {
...
if (script.lang === "ts") {
    const result = await options.devServer.transformWithEsbuild(scriptCode, filename, { loader: 'ts', ...options }, map);
}
...
}
underfin commented 3 years ago

You can use esbuild options to do it, like below.

{
      esbuild: {
           target: 'xxx'
      }
}

Doc is here. https://vitejs.dev/config/#esbuild