salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.64k stars 393 forks source link

[SSR v2] Fix unused imports from `'@lwc/ssr-runtime'` #4793

Open nolanlawson opened 6 days ago

nolanlawson commented 6 days ago

In core, this Rollup warning is treated as an error:

LWC1002: Error in module resolution: "api", "track" and "wire" are imported from external
module "@lwc/ssr-runtime" but never used in `foo.js`

This happens because sometimes we are sloppy about doing e.g.:

import { api } from '@lwc/ssr-runtime'

... in the output .js files from the @lwc/ssr-compiler, even though api may be unused.

We should clean this up and ensure that all of our imports are actually used.

git2gus[bot] commented 6 days ago

This issue has been linked to a new work item: W-17152250

cardoso commented 2 days ago

@nolanlawson aren't the decorators always compiled away?

nolanlawson commented 2 days ago

@cardoso Rollup removes the unused imports in our unit tests, yeah. But on-core, these warnings turn into errors because we're much stricter.

cardoso commented 2 days ago

@nolanlawson I think that part I understand. I'm actually wondering if the fix here is simply removing the decorator imports during ssr. Or is there a case they're referenced at runtime?

nolanlawson commented 2 days ago

Well some of them haven't been implemented yet. 🙂 See #4807 for example.