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

disabled shadydom in node dev build #3526

Merged
merged 3 commits into from Jan 11, 2023

Conversation

WickyNilliams
Copy link
Contributor

@WickyNilliams WickyNilliams commented Dec 15, 2022

In a next.js environent this line was throwing because window is undefined. This module was imported transitively via a component importing the ref directive, which in turn imports async-directive, which in turn imports the file where the fix was added.

Related #3156

I notice there are tests for lit-html in that PR which import the ref directive, so i'm not sure how they pass (or conversely how it is not working for me)

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2022

🦋 Changeset detected

Latest commit: 87754c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
lit Patch
lit-html Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@augustjk
Copy link
Member

Thank you for the PR!

Ah.. this probably only happens when running in dev mode in Next.js and introduced with #3495. The tests you reference are passing because they are testing against the production Node build in which ENABLE_SHADYDOM_NOPATCH is replaced with false during the rollup build.

It makes no sense to keep that true in Node builds regardless of prod/dev, so I think the correct move might be to make that false for dev Node builds as well.

The lines here

lit/rollup-common.js

Lines 452 to 453 in feb2494

'const ENABLE_SHADYDOM_NOPATCH = true':
'const ENABLE_SHADYDOM_NOPATCH = false',

should also be added below here

'const NODE_MODE = false': 'const NODE_MODE = true',

@WickyNilliams
Copy link
Contributor Author

excuse the delay, first day back in the office. i'll update the PR as suggested, and also generate a changeset

@WickyNilliams WickyNilliams force-pushed the shady-dom-handle-window-undefined branch from 58b998b to af7ed29 Compare January 9, 2023 09:59
@WickyNilliams
Copy link
Contributor Author

ok, updated as per suggestion and dropped previous commit.

re: changesets, should i just pick the lit package? i am wondering if this change is more broad since it changes the common rollup config

@WickyNilliams WickyNilliams changed the title ensure shadydom check handles case where window is undefined disabled shadydom in node dev build Jan 9, 2023
@augustjk
Copy link
Member

augustjk commented Jan 9, 2023

re: changesets, should i just pick the lit package? i am wondering if this change is more broad since it changes the common rollup config

I think a patch to lit and lit-html makes sense as the ones being affected by that flag.

Thank you!

@WickyNilliams WickyNilliams force-pushed the shady-dom-handle-window-undefined branch from 0738d57 to 2e5eae3 Compare January 10, 2023 08:39
@WickyNilliams WickyNilliams force-pushed the shady-dom-handle-window-undefined branch from 2e5eae3 to 0c433e3 Compare January 10, 2023 08:41
@WickyNilliams
Copy link
Contributor Author

added the changeset as recommended. i had to battle with the CLA check a little, but it's all good now.

Copy link
Member

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!
I added a bit more description the changeset and tests for node dev builds.

@augustjk augustjk enabled auto-merge (squash) January 11, 2023 00:12
@augustjk augustjk merged commit 65e5665 into lit:main Jan 11, 2023
@WickyNilliams
Copy link
Contributor Author

Great, thanks! Appreciate you taking the time

@WickyNilliams WickyNilliams deleted the shady-dom-handle-window-undefined branch January 11, 2023 09:46
@lit-robot lit-robot mentioned this pull request Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants