Open LarsDenBakker opened 5 years ago
I'm not sure this is within the purview of the preprocessor.
One idea is that the files are not declared in the Karma config as included: true
.
Do you mind putting together a small repo demonstrating the problem?
@jlmakes thanks for your swift response.
I've set up a reproduction here: https://github.com/LarsDenBakker/karma-rollup-preprocessor-issues
Run:
npm install
npm run test:dynamic-import
optionally, debug the code at: http://localhost:9876/debug.html
You will see the dynamic import fail.
Adding them to the test config file will not work, as these files are generated by rollup itself when code splitting dynamic imports. Maybe this is out of scope for a preprocessor, but dynamic imports it becoming a very common code pattern. I expect it will be used more and more often.
Happy to help out where possible.
Thanks for the reproduction, can confirm npm run test:dynamic-import
errors:
TypeError: Failed to fetch dynamically imported module: test-dynamic-import/bar-aed5ea93.js
I assumed Karma copied test files to a temp directory before serving them, and the dynamically imported files would be missing — but upon investigating, there only seems to be encoded/binary files in there.
I'm not sure how to proceed, but I'm suspicious this is more on the Karma side of things.
Hi, its pretty possible that happens because calling bundle.generate
creates several chunks but only the first one is returned as processed, which is the test file itself since they are ordered, so I see two options here:
inlineDynamicImports
rollup option.Cant confirm ATM though.
When writing a simple test with the recommended config, I get a 404 on dynamic imports. Likely the actual files get moved after compiling, but the dynamic chunks are not actually moved?
Is this a known issue with rollup and karma? Is there some sample project to look at?