lwc
lwc copied to clipboard
Update SSR fixtures to emit individually transformed files
Currently, the SSR fixtures emit a single file, compiled-experimental-ssr.js, which is generated by rollup. This can hide some issues, such as unused imports, that would be more easily identified if the fixtures were generated as individual files prior to bundling into a single file.
This will require a bit of additional logic to fully walk the import graph to identify all files that may need to be transformed.
We already have es-module-lexer which can be used for this.
There's no way as far as I know to make rollup keep unused imports. Perhaps this should be done without rollup?
Yeah the idea is:
- Use
es-module-lexerto crawl the module graph - Run
@lwc/compilerdirectly on each file instead of@lwc/rollup-plugin
There is a case to be made that this isn't worth it – we may end up writing a lot of extra test code just for a bit of extra debuggability.
There is a case to be made that this isn't worth it – we may end up writing a lot of extra test code just for a bit of extra debuggability.
We can't test that #4840 works without some way of generating non-bundled files.
I don't understand. Don't we have tests here to confirm that there are no unused import warnings?
https://github.com/salesforce/lwc/blob/2d11a5b0b18b3bbffaa412d5d3003ecff5be14d2/packages/%40lwc/ssr-compiler/src/tests/fixtures.spec.ts#L60-L69
Oh yeah, once we fix all unused imports, then we can delete line 64 and it'll be implicitly tested. We just got nothing for now.