lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Update SSR fixtures to emit individually transformed files

Open wjhsf opened this issue 1 year ago • 6 comments

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.

wjhsf avatar Nov 12 '24 17:11 wjhsf

We already have es-module-lexer which can be used for this.

nolanlawson avatar Nov 12 '24 17:11 nolanlawson

There's no way as far as I know to make rollup keep unused imports. Perhaps this should be done without rollup?

cardoso avatar Nov 13 '24 17:11 cardoso

Yeah the idea is:

  1. Use es-module-lexer to crawl the module graph
  2. Run @lwc/compiler directly 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.

nolanlawson avatar Nov 13 '24 17:11 nolanlawson

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.

wjhsf avatar Nov 13 '24 17:11 wjhsf

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

nolanlawson avatar Nov 13 '24 17:11 nolanlawson

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.

wjhsf avatar Nov 13 '24 21:11 wjhsf