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

Discrepancy between @lwc/engine-dom and @lwc/engine-server static parts application #4078

Open
jmsjtu opened this issue Mar 19, 2024 · 1 comment
Labels

Comments

@jmsjtu
Copy link
Member

jmsjtu commented Mar 19, 2024

Currently, our SSR implementation is not compatible with how we apply dynamic attributes to statically optimized elements in the browser.

In #4056 we've expanded static content optimization to allow attributes with expressions.

In the browser, we rely on cloneNode to create the DOM elements, loop through those elements and apply the dynamic attributes to them.

However, in SSR, the cloneNode function just returns the string value in vnode.fragment.

The main issue is the vnode.fragment used in mountStatic has already been assembled by buildParseFragmentFn during the mount process.

As a work-around, in SSR, we insert the expression values at the time the string is being built.

In #4056 we've created a token that serves as an index to map the string to its corresponding static part.

Long-term this should be resolved with a dedicated SSR compiler, see (#3880).

As an alternative to the solution in #4056 we could replicate the cloneNode behavior in SSR, which would require some form of HTML parser.

@nolanlawson
Copy link
Contributor

Alternatively, we could do disableStaticContentOptimization entirely for SSR (it doesn't really add anything), but this would require a separate SSR compile target similar to the dedicated SSR compiler.

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

No branches or pull requests

2 participants