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

.astro entryPoints not resolved in injectRoute #7642

Closed
1 task
salami-art opened this issue Jul 13, 2023 · 2 comments · Fixed by withastro/docs#3721
Closed
1 task

.astro entryPoints not resolved in injectRoute #7642

salami-art opened this issue Jul 13, 2023 · 2 comments · Fixed by withastro/docs#3721
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@salami-art
Copy link

What version of astro are you using?

2.8.2

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

mac

What browser are you using?

chrome

Describe the Bug

What do I check if the .astro entryPoint of an injectRouteis not resolved? I have another .ts entryPoint that resolves just fine

injectRoute({
  pattern: "/api/endpoints/[endpoint]",
  entryPoint: "src/endpoints/endpoint.ts",
});
injectRoute({
  pattern: "/test/endpoints/[endpoint]",
  entryPoint: "src/endpoints/Loader.astro",
});

=> error Cannot find module 'src/endpoints/Loader.astro'

What's the expected result?

The dev server shound start and use the Loader.astro entrypoint to handle requests to /test/endpoints/[endpoint]

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-d4i7hd?file=integration.ts

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re natemoo-re self-assigned this Jul 13, 2023
@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jul 13, 2023
@ematipico
Copy link
Member

Probably a duplicate of #7561 and #7563

@delucis
Copy link
Member

delucis commented Jul 14, 2023

I don’t think this is related to those issues, the reproduction works when updating the local entryPoint paths to use a Node-style relative-path format: https://stackblitz.com/edit/github-d4i7hd-9q5ovs?file=integration.ts (Works as in “loads the entrypoints” — both test files are missing getStaticPaths and will error when visited, but the issue reported here is resolved.)

injectRoute({
  pattern: "/api/endpoints/[endpoint]",
  entryPoint: "./src/endpoints/endpoint.ts",
});
injectRoute({
  pattern: "/test/endpoints/[endpoint]",
  entryPoint: "./src/endpoints/Loader.astro",
});

I think this is probably a documentation issue — the integration API docs show bare paths like in the reproduction, but those will be resolved as npm module names not as local paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants