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

Only resolve inline script specifiers in the static build #2302

Merged
merged 4 commits into from
Jan 4, 2022

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Jan 4, 2022

Changes

  • The 5c98456 commit is the new code here.
  • The other commit is a revert of a revert. Had to revert the new static build enhancements due to it breaking the docs site.
  • In order to not rely on vite HTML post-processing the static build resolves inline script specifiers by mapping them to the hashed built file. This doesn't work for the legacy build as Vite-HTML doesn't use the same underlying API. We will want to ask Vite to expose their API, but for now since it's not needed by the legacy build, we can just not resolve the specifiers at render-time.

@changeset-bot
Copy link

changeset-bot bot commented Jan 4, 2022

🦋 Changeset detected

Latest commit: 2d416c4

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

This PR includes changesets to release 1 package
Name Type
astro 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 pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope) test labels Jan 4, 2022
@netlify
Copy link

netlify bot commented Jan 4, 2022

✔️ Deploy Preview for astro-www ready!

🔨 Explore the source changes: 5c98456

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-www/deploys/61d44db1656da000074ca726

😎 Browse the preview: https://deploy-preview-2302--astro-www.netlify.app

@netlify
Copy link

netlify bot commented Jan 4, 2022

✔️ Deploy Preview for astro-docs-2 ready!

🔨 Explore the source changes: 5c98456

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61d44db1c7aa35000862a8e3

😎 Browse the preview: https://deploy-preview-2302--astro-docs-2.netlify.app

@netlify
Copy link

netlify bot commented Jan 4, 2022

✔️ Deploy Preview for astro-www ready!

🔨 Explore the source changes: f7471ef

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-www/deploys/61d44dd80bdc290008e032d1

😎 Browse the preview: https://deploy-preview-2302--astro-www.netlify.app

@netlify
Copy link

netlify bot commented Jan 4, 2022

✔️ Deploy Preview for astro-docs-2 ready!

🔨 Explore the source changes: f7471ef

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61d44dd8bd4b7800082bbb5a

😎 Browse the preview: https://deploy-preview-2302--astro-docs-2.netlify.app

@github-actions github-actions bot removed the test label Jan 4, 2022
@@ -151,14 +203,36 @@ async function generatePath(path: string, opts: StaticBuildOptions, gopts: Gener
route: pageData.route,
routeCache,
logging,
pathname: path,
pathname,
Copy link
Contributor

Choose a reason for hiding this comment

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

On L195 I was like "huh" and on L206 I’m like "ahh". 👍

Comment on lines +54 to +55
const filenameURL = new URL(`file://${id}`);
const pathname = filenameURL.pathname.substr(config.projectRoot.pathname.length - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit Idea: Is filenameURL being used to sanitize the URL? If so, I think a future PR should introduce posix sanitation methods. Then this line could be like:

/** Pathname, with a leading slash. */
const pathname = posix.path(id).slice(config.projectRoot.pathname.length - 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's being used to turn it into the pathname instead yeah. Yeah that way would presumably work too.

Copy link
Contributor

@jonathantneal jonathantneal left a comment

Choose a reason for hiding this comment

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

Generally, I follow. 👍

@matthewp matthewp merged commit 9db22b9 into main Jan 4, 2022
@matthewp matthewp deleted the bring-back-static-hydrated branch January 4, 2022 14:35
@github-actions github-actions bot mentioned this pull request Jan 4, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
…2302)

* Revert "Revert "Implement hydrated components in the static build (withastro#2260)""

This reverts commit 17ac18e.

* Only resolve specifiers in the static build

* Adding a changeset

* Fix the client-only test
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) pkg: example Related to an example package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants