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 injected route edge case #7399

Merged
merged 6 commits into from
Jun 16, 2023
Merged

Fix injected route edge case #7399

merged 6 commits into from
Jun 16, 2023

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Jun 15, 2023

Changes

  • Closes Unable to build Starlight documentation with Astro version >=2.6.4 #7397
  • Fixes edge case where injected routes would emit an unsupported entry file name at build time
  • Also updates our static build logging to fallback to the injected route pattern if an injected route is being generated. Previously, it would show the relative path to the injected component inside of node_modules

Testing

Existing tests should pass, additional injectRoute from packages added

Docs

No, bug fix only

@changeset-bot
Copy link

changeset-bot bot commented Jun 15, 2023

🦋 Changeset detected

Latest commit: d4b2a9f

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: astro Related to the core `astro` package (scope) label Jun 15, 2023
packages/astro/src/core/build/static-build.ts Outdated Show resolved Hide resolved
packages/astro/src/core/build/static-build.ts Show resolved Hide resolved
packages/astro/src/core/build/static-build.ts Outdated Show resolved Hide resolved
// this must be last
.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.')}.mjs`;
.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.')}`;
const name = pages[pageModuleId]?.route?.route ?? pageModuleId;
Copy link
Member

Choose a reason for hiding this comment

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

I think this must be done at the end? Here pageModuleId has its name still mangled and it won't match any route

Copy link
Member Author

Choose a reason for hiding this comment

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

The first step is to unmangle the facadeModuleId so we can match it to a route. After that, we mangle the [ and ] and ... characters.

@ematipico
Copy link
Member

Even though all tests should pass, I'm surprised we hit a regression. Isn't there a way to simulate a test for the issue that was filed?

import { expect } from 'chai';
import { loadFixture } from './test-utils.js';

describe('Custom 404 with injectRoute from dependency', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a specific test for #7397! The injected route will be matched to a relative path in ./node_modules but the build should still succeed. This test verifies that this is the case.

Copy link
Member

@ematipico ematipico 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 Nate!

@natemoo-re natemoo-re merged commit d2020c2 into main Jun 16, 2023
@natemoo-re natemoo-re deleted the fix/7397 branch June 16, 2023 20:58
@astrobot-houston astrobot-houston mentioned this pull request Jun 16, 2023
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.

Unable to build Starlight documentation with Astro version >=2.6.4
2 participants