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

SSR split seems to not output prerendered html pages #7466

Closed
1 task
alexanderniebuhr opened this issue Jun 23, 2023 · 14 comments · Fixed by #7509
Closed
1 task

SSR split seems to not output prerendered html pages #7466

alexanderniebuhr opened this issue Jun 23, 2023 · 14 comments · Fixed by #7509
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@alexanderniebuhr
Copy link
Member

alexanderniebuhr commented Jun 23, 2023

What version of astro are you using?

2.7.0

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

Cloudflare

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

While working on #7464, it seems like that pages with

export const prerender = true

are emitted as .js entry files instead of .html assets. Note I have only tested it with the local fork.

What's the expected result?

prerender pages should be handled as before

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-q6erqj-ab1xqd?file=astro.config.mjs&view=editor

Participation

  • I am willing to submit a pull request for this issue.
@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 26, 2023

it seems like it outputs js & css entry files for the pre-rendered pages, but the static html files are missing in the dist folder.

Why are we emitting a .js entryFile for pre-rendered pages at all?

@ematipico can you reproduce it, or am I missing something?

@ematipico
Copy link
Member

It could be a bug. Can you create a repo for us to test please?

@ematipico ematipico added the needs repro Issue needs a reproduction label Jun 27, 2023
@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 27, 2023

Can you create a repo for us to test please?

https://stackblitz.com/edit/github-q6erqj-ab1xqd?file=astro.config.mjs&view=editor

  • run npm install && npm run build both with build.split: true & build.split: false
  • see difference in dist folder. .html is missing & unnecessary .js is emited

@ematipico ematipico removed the needs repro Issue needs a reproduction label Jun 27, 2023
@ematipico
Copy link
Member

Thank you @alexanderniebuhr , this repro will help us a lot!

@ematipico ematipico self-assigned this Jun 27, 2023
@ematipico ematipico added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jun 27, 2023
@alexanderniebuhr
Copy link
Member Author

@ematipico amazing speed for a fix!
I get the following in my cloudflare adapter MR. What am I doing wrong?

     Error: Unable to find the manifest for the module file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/integrations/cloudflare/test/fixtures/split/dist/$server_build/src/pages/entry.prerender.astro.mjs?time=1687954762279. This is unexpected and likely a bug in Astro, please report.
      at generatePages (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/dist/core/build/generate.js:112:19)
      at async staticBuild (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/dist/core/build/static-build.js:92:7)
      at async AstroBuilder.build (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/dist/core/build/index.js:118:5)
      at async AstroBuilder.run (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/dist/core/build/index.js:149:7)
      at async build (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/dist/core/build/index.js:37:3)
      at async Context.<anonymous> (file:///Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/integrations/cloudflare/test/directory-split.test.js:23:3)

@ematipico
Copy link
Member

Is the path to the file correct?

@alexanderniebuhr

This comment was marked as outdated.

@alexanderniebuhr
Copy link
Member Author

@ematipico actually I can't reach the astro:build:done hook anymore, if I have pre-rendered pages.

@ematipico
Copy link
Member

That's interesting, I'll have to have a look it

@ematipico ematipico reopened this Jun 28, 2023
@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 28, 2023

trying to debug this a little with logs, so I can compare cloudflare test vs the your test, to see the differences.
But I can't see that this test packages/astro/test/ssr-split-manifest.test.js is running, at all. How could I just run this selected test?

@ematipico
Copy link
Member

pnpm test:match "astro:ssr-manifest, split" The string must be what you have in the test text

@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 28, 2023

pnpm test:match "astro:ssr-manifest, split" The string must be what you have in the test text

my bad, I tried filename...

Foundings

Cloudflare has a different ssrEntryPage.

const ssrEntryPage = await import(ssrEntryURLPage.toString());

The question is: Why is manifest missing from the cloudflare one?
Maybe because the following line is missing in the emited splitted entryFiles?

const manifest = _exports['manifest'];

Logs

not-cloudflare:

[Module: null prototype] {
  createApp: [Function: createApp],
  manifest: {
    adapterName: 'my-ssr-adapter',
    routes: [ [Object], [Object], [Object], [Object], [Object] ],
    base: '/',
    markdown: {
      drafts: false,
      syntaxHighlight: 'shiki',
      shikiConfig: [Object],
      remarkPlugins: [],
      rehypePlugins: [],
      remarkRehype: {},
      gfm: true,
      smartypants: true
    },
    componentMetadata: Map(3) {
      '/Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/test/fixtures/ssr-split-manifest/src/pages/index.astro' => [Object],
      '/Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/test/fixtures/ssr-split-manifest/src/pages/zod.astro' => [Object],
      '/Users/alexanderniebuhr/Developer/Projects/alexanderniebuhr_astro/packages/astro/test/fixtures/ssr-split-manifest/src/pages/prerender.astro' => [Object]
    },
    renderers: [ [Object] ],
    clientDirectives: Map(5) {
      'idle' => '(()=>{var i=t=>{let e=async()=>{await(await t())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)};(self.Astro||(self.Astro={})).idle=i;window.dispatchEvent(new Event("astro:idle"));})();',
      'load' => '(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).load=e;window.dispatchEvent(new Event("astro:load"));})();',
      'media' => '(()=>{var s=(i,t)=>{let a=async()=>{await(await i())()};if(t.value){let e=matchMedia(t.value);e.matches?a():e.addEventListener("change",a,{once:!0})}};(self.Astro||(self.Astro={})).media=s;window.dispatchEvent(new Event("astro:media"));})();',
      'only' => '(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();',
      'visible' => '(()=>{var r=(s,c,i)=>{let o=async()=>{await(await s())()},n=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){n.disconnect(),o();break}});for(let e=0;e<i.children.length;e++){let t=i.children[e];n.observe(t)}};(self.Astro||(self.Astro={})).visible=r;window.dispatchEvent(new Event("astro:visible"));})();'
    },
    entryModules: {
      '\x00@astro-page-split:src/pages/index@_@astro': 'src/pages/entry.index.astro.mjs',
      '\x00@astro-page-split:src/pages/prerender@_@astro': 'src/pages/entry.prerender.astro.mjs',
      '\x00@astro-page-split:src/pages/lorem@_@md': 'src/pages/entry.lorem.md.mjs',
      '\x00@astro-page-split:src/pages/zod@_@astro': 'src/pages/entry.zod.astro.mjs',
      '\x00@astro-page-split:src/pages/[...post]@_@astro': 'src/pages/entry._---post_.astro.mjs',
      '\x00@astro-renderers': 'renderers.mjs',
      '\x00empty-middleware': '_empty-middleware.mjs',
      '/src/pages/[...post].astro': 'chunks/pages/_...post_.astro.56a1aa02.mjs',
      '/src/pages/lorem.md': 'chunks/pages/lorem.md.49086284.mjs',
      '/src/pages/zod.astro': 'chunks/pages/zod.astro.972c86fd.mjs',
      '/src/pages/prerender.astro': 'chunks/prerender.ba6092c6.mjs',
      'astro:scripts/before-hydration.js': ''
    },
    assets: Set(2) { '/_astro/index.a8a337e4.css', '/prerender/index.html' },
    pageModule: [Object: null prototype] [Module] {
      onRequest: undefined,
      page: [Function: page],
      renderers: [Array]
    }
  }
}

cloudflare:

[Module: null prototype] { onRequest: [AsyncFunction: onRequest] }

@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 28, 2023

@ematipico maybe I found the issue. Could it be because packages/integrations/cloudflare/src/server.directory.ts does not return manifest and just onRequest?

@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Jun 28, 2023

I was right found the issue and can fix myself.

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.

2 participants