Each test file is treated as a separate bundle. Common dependencies are duplicated between the test files.
This is wasteful, and creates extra overhead for large project. But more importantly it creates issues when working with web components, as they may only be registered once per document. Bundling the same web component twice will throw an error.
I creates a reproduction for this: https://github.com/LarsDenBakker/karma-rollup-preprocessor-issues
npm install
npm run test:dynamic-import
optionally, debug the code at: http://localhost:9876/debug.html
You will see the error being thrown. If you inspect the output bundles in the browser, you will see the web component code bundled twice.
We are switching from webpack to rollup for our recommended setup for developers working with web component at: https://open-wc.org/
We had a similar issue with webpack codymikol/karma-webpack#379 which we were able to solve.
Happy to help out where possible.
Each test file is treated as a separate bundle. Common dependencies are duplicated between the test files.
This is wasteful, and creates extra overhead for large project. But more importantly it creates issues when working with web components, as they may only be registered once per document. Bundling the same web component twice will throw an error.
I creates a reproduction for this: https://github.com/LarsDenBakker/karma-rollup-preprocessor-issues
You will see the error being thrown. If you inspect the output bundles in the browser, you will see the web component code bundled twice.
We are switching from webpack to rollup for our recommended setup for developers working with web component at: https://open-wc.org/
We had a similar issue with webpack codymikol/karma-webpack#379 which we were able to solve.
Happy to help out where possible.