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

bugfix: rewrite lit.js package resolution to use node export for Cloudflare SSR #6915

Closed
wants to merge 12 commits into from

Conversation

chaffinated
Copy link

@chaffinated chaffinated commented Apr 26, 2023

Changes

fix withastro/adapters#42

Rewrite lit packages entrypoint paths to work in Cloudflare SSR

Testing

Added test in cloudflare integration

Docs

No documentation was added because this should not directly affect developer experience.

@changeset-bot
Copy link

changeset-bot bot commented Apr 26, 2023

🦋 Changeset detected

Latest commit: 80d5074

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

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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Apr 26, 2023
@chaffinated chaffinated changed the title bugfix(use "node" for esbuild.platform) bugfix(use "neutral" for esbuild.platform) May 2, 2023
@johannesspohr
Copy link
Contributor

The same happened for solid-js, which actually contains a worker condition in the exports. I wonder if that should also be included in the conditions here?

Also, the vercel edge integration basically uses the same esbuild config and will probably suffer from the same issue (as described in #6989), I guess the same fix could be applied there as well.

@ematipico ematipico changed the title bugfix(use "neutral" for esbuild.platform) bugfix: use "neutral" for esbuild.platform May 8, 2023
@johannesspohr
Copy link
Contributor

@chaffinated great! In #7092 I added a test for solid, do you think it makes sense to also include sth like that for lit?

@chaffinated
Copy link
Author

@johannesspohr Yup! And I just found the astro-scripts in the workspace, so I'll get those added ASAP

to reflect "neutral" esbuild setting, instead of "node"
Stick with the standard CloudFlare convention of using `browser: "platform"` but with added export condition support for "worker" type environments; for SSR-specific package exports (which usually use `platform: "node"`), we instead will use hard-coded resolve rewrites to point to the appropriate exports for Lit.js libraries with added support for custom rewrite options passed to the CloudFlare adapter
@chaffinated chaffinated changed the title bugfix: use "neutral" for esbuild.platform bugfix: rewrite lit.js package resolution to use node export for Cloudflare SSR May 17, 2023
@bluwy
Copy link
Member

bluwy commented May 18, 2023

The new changes looks good to me. I've also commented at lit/lit#1983 (comment) to hear what their thoughts are on this before we move on with the patch. But I'm happy to move on with this if there's not much feedback.

@bluwy
Copy link
Member

bluwy commented May 23, 2023

Gonna merge this one once the CI passes. I don't think it'll be fixed in Lit soon, but I'll be following lit/lit#3907 for any updates there.

@bluwy
Copy link
Member

bluwy commented May 23, 2023

Looks like running two wrangler CLIs caused the CI to be flaky (even before my cleanup). Gonna have to investigate it a bit before merging.

@matthewp
Copy link
Contributor

I don't think we should accept this changes as is. I really don't want the Cloudflare adapter to have special-case code for one framework. That doesn't scale. Instead I think it would be fine if the Cloudflare adapter had some API where its esbuild configuration could be extended, and the Lit adapter implemented support for that.

@chaffinated
Copy link
Author

@matthewp I agree with this, but I think you may need to confer with @bluwy about that. Btw, who has the authority to make the final call on this?

@matthewp
Copy link
Contributor

We operate on consensus. The approach I think we should take here is:

  1. Have the cloudflare adapter expose an option to provide esbuild plugins.
  2. Create a 3rd party package to support Lit in Cloudflare via an esbuild plugin.

@JosefJezek
Copy link

@bluwy @chaffinated any progress?

@matthewp
Copy link
Contributor

Since this is quite a bit outdated, will need a new PR.

@matthewp matthewp closed this Sep 27, 2023
@dengel29
Copy link

So what's the right way to go about this, since all related issues and PRs seem to have been closed after a lack of consensus or direction? As a user, how can I register with the Astro team that this would be a nice feature?

@matthewp
Copy link
Contributor

@dengel29 My comment here is still true: #6915 (comment)

The Cloudflare adapter is community maintained by the maintainer is extremely active. If you brought up this issue and asked for such a config I bet he would be willing to work with you. That adapter lives here: https://github.com/withastro/adapters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@astrojs/lit breaks @astrojs/cloudflare builds
7 participants