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

Silent error when using the getMenu method and building a static output with Next.js #682

Open
lorenzo-dallamuta opened this issue Feb 13, 2024 · 0 comments
Labels
bug Something isn't working triage A new issue that needs triage

Comments

@lorenzo-dallamuta
Copy link

Package containing the bug

next (Drupal module)

Describe the bug

I don't understand if this an issue with Next-Drupal or with Next 14, but since this is a library that aims to work with Next.js as-is I'll first open the issue here.

I'm trying to build a static export with Next 14 (the output property of next.config.js is set to export), but when I include the getMenu method in my code, the Next build silently fails to produce the html templates of the pages (including index.html).

From Next 13 similar issues have been linked with the built-in image optimization of Next.js, but in this project I set the unoptmized flag to true for the images property in next.config.js and the issue still happens if and only if the getMenu method is invoked.

If I replace the getMenu method with something like this the build finishes with the expected result (note that I don't need token authorization so I left it out):

async function getMenu(name: string) {
    const url = drupal.buildUrl(`/jsonapi/menu_items/${name}`)
    const response = await fetch(url.toString())
    const serialized = await response.json()
    const items = drupal.deserialize(serialized) as DrupalMenuLinkContent[]
    const { items: tree } = drupal.buildMenuTree(items)
    return { items, tree: tree as DrupalMenuLinkContent[] }
}

Expected behavior

I build the Next project with the static output options set to true and the created out folder contains the html files for index.html and all the pages.

Steps to reproduce:

  1. use the getMenu method in a reachable part of the code
  2. set the output property to export in the next.config.js file
  3. launch the build command
  4. check the contents of the out folder for the static html files
  5. the html files aren't there (including no index.html)
@lorenzo-dallamuta lorenzo-dallamuta added bug Something isn't working triage A new issue that needs triage labels Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage A new issue that needs triage
Projects
None yet
Development

No branches or pull requests

1 participant