Repository navigation
[labs/ssr-dom-shim] Register CSSStyleSheet polyfill in global scope when using Node.js hook for importing CSS files - #5240
Conversation
🦋 Changeset detectedLatest commit: c11b169 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
thescientist13
left a comment
There was a problem hiding this comment.
Thank you @kyubisation 🙌
4543e01 to
77b091c
Compare
|
We discussed this during the community call:
@thescientist13 What is your use case/opinion? Personally I'm inclined to 1., but I'd like your input on this. |
|
@kyubisation Regarding option 1:
Are you saying that for these example here, I would just have manually add an Regarding option 3:
What would adapting in this case look like? Not sure if this is useful info at, but for my use case, I am (already) using Worker Threads to do SSR, mainly to isolate SSR code like this from the global scope, so not sure how that would factor into your decision making? That said, I've been considering moving away from worker threads just because when using That said, I do need something like Worker Threads for local development / live reloading to do module cache busting, since ESM has no module invalidation API like CJS did - nodejs/node#49442 Maybe the VM approach Lit recommends would be my way to go? Or I was thinking of using Cluster, but ideally I'm trying to find something (at least long term) that would be "web standard" / WinterTC compatible. Maybe that's Shadow Realms? 🤔 All that yapping to say, and apologies if I didn't actually answer / get your question, is that I'm pretty much not opposed to any particular option in general, though I wouldn't be opposed to #2 since I always love it when a library does the thing for me 😅 ((though I guess there is still the case of Lit wanting to future proof in the event Node actually supports |
|
@thescientist13 Thank you for your input. After some considerations I think I agree with you of making it "just work" with option 2. I'll implement a corresponding approach and update the PR. 👍 |
318e49e to
607604f
Compare
|
@thescientist13 Also in #5153 I'm experimenting with Lit Worker support for Node.js. If you have the time to take a look at that and provide your input, it should help in shaping it for usability. |
…he DOM shim is not installed
607604f to
c11b169
Compare
…hen using Node.js hook for importing CSS files (lit#5240) Currently if the DOM shim is not installed (or not installed before the import context of any import to `lit` or `@lit/reactive-element`), the conversion of `CSSStyleSheet` is hard locked into resulting in undefined, which is skipped. Due to this, during the registering of the CSS import hook, the `CSSStyleSheet` is added to the global scope. Additionally, this changes the native CSS import feature detection to use a data url to avoid bundlers failing when inlining the CSS file or skipping it entirely.
Currently if the DOM shim is not installed (or not installed before the import context of any import to
litor@lit/reactive-element), the conversion ofCSSStyleSheetis hard locked into resulting in undefined, which is skipped.Due to this, during the registering of the CSS import hook, the
CSSStyleSheetis added to the global scope.Additionally, this changes the native CSS import feature detection to use a data url to avoid bundlers failing when inlining the CSS file or skipping it entirely.