Subscribe on changes!

Webpack target node: <img> inside router-link leads to duplicate import statement in final bundle

avatar
Oct 14th 2020

Version

3.0.0

Reproduction link

https://github.com/BobbySpoon/Vue3-bundling-issue

Steps to reproduce

Copy repo and run build script. Repo is very minimal reduction of the code I am actually writing, but isolates/ points to problem.

What is expected?

No duplication of import _imports_0 from './logo.png' when bundling the code with webpack target: 'node'. Please note that this is ONLY happening when tag is nested inside router-link

What is actually happening?

Webpack with target: 'node': Babel parser will complain that Identifier \_imports\_0 has already been declared

Webpack with no target (i.e. default browser)

no errors


The import statement gets produced by @vue/compiler-sfc function transformAssetUrl (a @vue/compiler-core plugin). I'm experimenting on a migration from vue2 ssr (as described in the docs) to vue3 which generally works so far except described problem.

Creating server bundle without target: node of course solves the problem but then we run into issues with code splitting things (e.g. component: () => import(...) will not work anymore)

Since this issue is (as far as I can tell now) produced by vue-compiler I did not post this as vue-router issue.

Any help/ hint is much appreciated. :)

avatar
Oct 15th 2020

Closing this one on favour of #2386.