Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export @lwc/ssr-* from lwc package #4554

Open
lpomerleau opened this issue Sep 17, 2024 · 4 comments
Open

Re-export @lwc/ssr-* from lwc package #4554

lpomerleau opened this issue Sep 17, 2024 · 4 comments

Comments

@lpomerleau
Copy link

lpomerleau commented Sep 17, 2024

Description

Steps to Reproduce

See lwc#2400 here.

In this PR, we are integrating the @lwc/ssr-compiler into LWR-Node for TD-0205202. We started passing TransformOptions.targetSSR = true into @lwc/compiler#transformSync.

  1. Clone the lwr repo
  2. Checkout the laura/ssr-compiler branch
  3. yarn (install + build)
  4. yarn ssr:start
  5. Visit http://localhost:4000

Expected Results

The @lwc/ssr-runtime is found. It replaces the lwc imports during SSR compilation here.

Actual Results

The LWR-Node runtime cannot find the @lwc/ssr-runtime package when bundling an SSR-compiled LWC:

[error] 404: Could not find module entry with specifier "@lwc/ssr-runtime"

Note: this error may be buried under another error: #4555

Browsers Affected

Node.js

Version

Node project
package.json
"peerDependencies": { "@lwc/compiler": ">= 2.x" }
"devDependencies": { "@lwc/compiler": "7.2.6" }

  • LWC: 7.2.6

Possible Solution

In LWR-Node, we set lwc as a peer dependency which is met by the app layer. Does the same approach need to be taken with @lwc/ssr-runtime to support SSR-compiled modules?

@nolanlawson
Copy link
Collaborator

So currently the lwc package does not export @lwc/ssr-compiler or @lwc/ssr-runtime. You can see its exported packages here: https://github.com/salesforce/lwc/tree/master/packages/lwc

I think we could definitely do this, but probably not until @lwc/ssr-* is ready for prime time.

In the meantime, yes, you would need to set it as a peer dependency. This is probably a good practice anyway, because transitive dependencies are not always allowed to be imported/required at the top level (I believe some versions of Yarn disallow this).

@nolanlawson
Copy link
Collaborator

Alternatively, we can just re-export these from the lwc package right now if this is a big blocker.

@nolanlawson nolanlawson changed the title SSR compiled modules expect to have access to @lwc/ssr-runtime Re-export @lwc/ssr-* from lwc package Sep 27, 2024
@nolanlawson
Copy link
Collaborator

We can just re-export these. It's not a big deal.

Copy link

git2gus bot commented Sep 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants