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

handling puppeteer serialization issues with lit 2 and Shady DOM #719

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Sep 7, 2021

Related Issue

resolves #675, and fixes the critical TODOs from #611

  1. Find cause of big logo flash / FOUC
  2. broken component rendering and styles when pre-rendering with puppeteer

Screen Shot 2021-09-14 at 12 36 57 PM

Summary of Changes

  1. Reading the Polyfills section of the lit.dev docs informs that if using webcomponents-bundle.js (like we do for puppeteer) then we should also include lit.polyfill-support.js and well, it worked! Silly me for not just RTFM sooner, lol.

Deploy preview available at #726

TODO

  1. lit/polyfill-support.js should only be conditionally added if the user is actually using lit, so we should add a check, otherwise it will be 404 for non lit users. Could reuse refactor root package node modules resolution #725
  2. Should track the above into its own plugin-polyfills-lit, likely as part of our next Project. - create Lit specific polyfill plugin #728
> this work is ongoing, just wanted to get something out there for conversation's sake

Summary of Changes

  1. Removing the static optimization setting makes things work, likely because this preserves CSS-in-JS styles missing when the component's JS is not available at runtime anymore. Would like to it make work just like lit@1 though.

Also, not sure why path to evergreen.svg is unhappy now on nested routes?
Screen Shot 2021-09-07 at 5 08 50 PM

@thescientist13 thescientist13 added bug Something isn't working P0 Critical issue that should get addressed ASAP CLI SSR labels Sep 7, 2021
@thescientist13 thescientist13 self-assigned this Sep 7, 2021
@thescientist13 thescientist13 added the help wanted Extra attention is needed label Sep 7, 2021
@thescientist13 thescientist13 force-pushed the enhancement/upgrade-website-lit-2-support branch from 46b63cd to 9cafbec Compare September 7, 2021 21:37
@thescientist13 thescientist13 force-pushed the bug/issue-675-puppeteer-declarative-shadow-dom-support branch from 8127cf1 to 6a001d9 Compare September 14, 2021 14:40
@thescientist13 thescientist13 changed the title handling puppeteer serialization issues with declarative shadow dom handling puppeteer serialization issues with lit 2 and Shady DOM Sep 14, 2021
@thescientist13 thescientist13 removed the help wanted Extra attention is needed label Sep 14, 2021
@thescientist13 thescientist13 marked this pull request as ready for review September 14, 2021 20:50
@thescientist13
Copy link
Member Author

thescientist13 commented Sep 15, 2021

Hmm, not sure what's up with this build failure / stalling in Windows.
https://github.com/ProjectEvergreen/greenwood/runs/3611389959?check_suite_focus=true

prerendering page... /
prerendering page... /plugins/context/
prerendering page... /plugins/custom-plugins/
prerendering page... /plugins/
prerendering page... /plugins/resource/
prerendering page... /plugins/rollup/
prerendering page... /plugins/server/
(node:4368) UnhandledPromiseRejectionWarning: Error: EBUSY: resource busy or locked, copyfile 'D:\a\greenwood\greenwood\node_modules\@webcomponents\webcomponentsjs\bundles\webcomponents-sd-ce-pf.js' -> 'D:\a\greenwood\greenwood\public\bundles\webcomponents-sd-ce-pf.js'
prerendering complete for page /about/goals/.
(Use `node --trace-warnings ...` to show where the warning was created)
prerendering complete for page /about/how-it-works/.
(node:4368) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
prerendering complete for page /about/features/.
(node:4368) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
prerendering complete for page /docs/configuration/.
prerendering complete for page /about/.
prerendering complete for page /docs/component-model/.
prerendering complete for page /docs/css-and-images/.

Tested on a Windows VM and everything was fine, so I guess some sort of race condition? Only thing I can think of is [here in plugin-polyfills maybe there are some async shenanigans happening? 🤔

await Promise.all(polyfillFiles.map(async (file) => {
  const from = path.join(cwd, nodeModuleRoot, file);
  const to = path.join(outputDir, file);

  return !fs.existsSync(to)
    ? fs.promises.copyFile(from, to)
    : Promise.resolve();
}));

@thescientist13 thescientist13 merged commit be0bf56 into enhancement/upgrade-website-lit-2-support Sep 22, 2021
@thescientist13 thescientist13 linked an issue Sep 22, 2021 that may be closed by this pull request
8 tasks
@thescientist13 thescientist13 deleted the bug/issue-675-puppeteer-declarative-shadow-dom-support branch September 22, 2021 20:02
thescientist13 added a commit that referenced this pull request Sep 23, 2021
* WIP

* revert www changes

* apply lit polyfill support

* conditially check for lit before using polyfill
thescientist13 added a commit that referenced this pull request Oct 6, 2021
* init commit with website components working use lit 2

* update import node modules spec per new lit packaging

* disable SPA mode spec

* all specs passing with new lit

* update cli devDep

* everything working and rebased

* restore eve components

* add trusted types scaffolding for lit-html

* upgrade to latest version of lit-redux-router with lit 2 compat

* update specs

* update develop specs for lit@2

* upgrade lit rc4

* handling puppeteer serialization issues with lit 2 and Shady DOM (#719)

* WIP

* revert www changes

* apply lit polyfill support

* conditially check for lit before using polyfill

* upgrade to final stable version

* rebased from master but broken???

* bump deps and set lit resolututions

* ship lit polyfill for lit and plugin polyfills users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP SSR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lit@2 Shady DOM styles not present when pre-rendering with puppeteer
1 participant