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

Fix: is self accepting pt 2 module graph boogaloo #2872

Merged
merged 4 commits into from
Mar 24, 2022

Conversation

bholmesdev
Copy link
Contributor

Changes

  • Add .js extensions to Preact entrypoints for consistency
  • Switch to pulling server renderer IDs from the urlToModuleMap directly. This avoids any calls to ensureEntryFromUrl, which was causing the module to be loaded twice
  • Remove the renderer cache. By pulling from the module map, we get the correct ?v= version param everytime. This means... no need for a cache 😁

Testing

  • Tested on a local project using preact in isolation
  • Tested on a locacl project with preact, react, and svelte together
  • Cannot replicate in fixtures

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2022

🦋 Changeset detected

Latest commit: 9adf746

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

This PR includes changesets to release 2 packages
Name Type
astro Patch
@astrojs/preact 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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 24, 2022
packages/integrations/preact/src/index.ts Show resolved Hide resolved
Comment on lines +45 to +49
// Vite modules can be out-of-date when using an un-resolved url
// We also encountered inconsistencies when using the resolveUrl and resolveId helpers
// We've found that pulling the ID directly from the urlToModuleMap is the most stable!
const id = viteServer.moduleGraph.urlToModuleMap.get(renderer.serverEntrypoint)?.id ?? renderer.serverEntrypoint;
const mod = (await viteServer.ssrLoadModule(id)) as { default: SSRLoadedRenderer['ssr'] };
Copy link
Member

Choose a reason for hiding this comment

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

This looks much more straight-forward. I'm pleased if all works well!

Copy link
Member

@FredKSchott FredKSchott left a comment

Choose a reason for hiding this comment

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

LGTM!

@bholmesdev bholmesdev merged commit 098f6f6 into main Mar 24, 2022
@bholmesdev bholmesdev deleted the fix/is-self-accepting-pt-2-module-graph-boogaloo branch March 24, 2022 16:28
This was referenced Mar 24, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* fix: isSelfAccepting Preact error

* refactor: add .js ext to preact entrypoints for consistency

* chore: changeset

* fix: remove ./client and ./server from preact pkg exp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants