-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Move getStaticPaths call to happen during generation #4047
Conversation
🦋 Changeset detectedLatest commit: 3d865dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
const { astroConfig, logging, routeCache, ssr, viteServer } = opts; | ||
if (!viteServer) throw new Error(`vite.createServer() not called!`); | ||
const filePath = new URL(`./${route.component}`, astroConfig.root); | ||
const mod = (await viteServer.ssrLoadModule(fileURLToPath(filePath))) as ComponentInstance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the last ssrLoadModule
call still happening during the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I know you've been working towards this for a while. LGTM! If tests are passing, I'll merge this to get it in in time for the nightly release.
Ah, I'd hoped the breaking test was a small bug but it looks like its due to an actual regression. Probably due to a side-effect of changing the order that you build files in the |
Yeah, I think it's because |
Changes
getStaticPaths
during the build is moved to the end of the process, during page generation.vite.ssrLoadModule
anywhere in the build now. We are 100% completely static.getStaticPaths
. Before this change if you use a Lit element in a page behind getStaticPaths you would get awindow is undefined
error. This was because getStaticPaths was being called upfront, when the renderer had not yet run, and therefore the shim was not applied. Now it happens as it should.Testing
Docs
N/A, bug fix.