I'm currently facing an issue with integrating a vue component library into my vue application. This component library is loaded by a script tag and is set up with webpack using the externals
setting to exclude vue dependencies. Therefore, the host bundle that is using this library needs to include vue and other necessary dependencies.
The component library is built using vue cli with the script
vue-cli-service build --target lib
to generate a lib.umd.js
file. In the index.html
of my host bundle, I include this file using a script tag. The webpack configuration of the host bundle uses config.externals(['@test/my-component-library'])
to exclude the external component library. In my host bundle, I import and use the component library like this:
import { MyComponent } from '@test/my-component-library'
However, when I run my application, I encounter the error message:
Uncaught SyntaxError: Invalid or unexpected token
. This error seems to be originating from the following line in my host bundle:
/*!*******************************************************!*\
!*** external "@test/my-component-library" ***!
\*******************************************************/
Could someone please explain why webpack is generating this code and suggest possible solutions to resolve this issue?