underfin / vite-plugin-vue2

Vue2 plugin for Vite
621 stars 84 forks source link

Generated code has not escaped charsets "\" in import paths for windows #152

Closed Ti-webdev closed 2 years ago

Ti-webdev commented 2 years ago
  1. create any component insde folder called ui, for example src/ui/AnyComponentName.vue with any template, for example <template><div /></template>
  2. add the componennt to manualChunks
    
    import { defineConfig } from 'vite'
    import { createVuePlugin } from 'vite-plugin-vue2';

export default defineConfig({ plugins: [ createVuePlugin(), ], build: { rollupOptions: { output: { manualChunks: { anyNameOfChunk: [ 'src/ui/AnyComponentName.vue' ] } } } }, })

3. run `vite build` on windows

Occurs rollup error

[rollup-plugin-dynamic-import-variables] Bad character escape sequence (8:107) file: C:\path-to-my-vue-app\src\ui\AnyComponentName.vue:8:107 error during build: SyntaxError: Bad character escape sequence (8:107)


The reson is generated code contains `\u...` symbol: `import { render as ... } from 'C:\path-to-my-vue-app\src\ui\AnyComponentName.vue?vue&type=template&lang.js'`.
Without manualChunks it has correct string of import:  `'C:/path-to-my-vue-app/src/ui/AnyComponentName.vue?vue&type=template&lang.js'` and works propertly.
Ti-webdev commented 2 years ago

https://github.com/underfin/vite-plugin-vue2/pull/154