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

Preset cloudflare-module error "No such module "__STATIC_CONTENT_MANIFEST" #1317

Open
YannicEl opened this issue Jun 18, 2023 · 3 comments
Open

Comments

@YannicEl
Copy link

Environment

node: 18.13.0
nitropack: 2.4.1

Reproduction

https://stackblitz.com/edit/github-y5zrh4?file=package.json

wrangler dev doesn't yet work in stackblitz so you have to download the project and run:

  1. npm i
  2. npm run build
  3. npm run dev

Describe the bug

When building nitro with the preset cloudflare-module and then try to deploy it to cloudflare you get the following error message:
image

Looking at the output index.mjs file you can see that it imports a file called __STATIC_CONTENT_MANIFEST
image

But there is not file called __STATIC_CONTENT_MANIFEST in the .output folder
image

I'm happy to try writing a PR if somebody could lead me into the right direction.
What is the static file content manifest and when is it generated?

Additional context

No response

Logs

No response

@YannicEl
Copy link
Author

#1172 is this related?

@Hebilicious Hebilicious added bug Something isn't working preset:cloudflare and removed pending triage labels Jun 30, 2023 — with Volta.net
@Hebilicious Hebilicious self-assigned this Jun 30, 2023
@ChristianJacobsen
Copy link

Thanks to this comment over at the cloudflare/kv-asset-handler repo I was able to get this working by adding the following type declaration file to the root of my Nitro project:

declare module '__STATIC_CONTENT_MANIFEST' {
    export default String
}

I named mine manifest.d.ts like in the comment mentioned above, but ideally, I think this should be either produced by Nitro under the .nitro/types dir (at least until Cloudflare can fix this issue) or we should push Cloudflare to resolve this. There are a couple (cloudflare/workers-sdk#4969, cloudflare/workers-sdk#4968) open issues over there already.

@manniL manniL added the upstream label Jan 9, 2024
@ChristianJacobsen
Copy link

After some trial and error I've realized that I didn't properly read the very clear output from Nitro's build command. It says 'wrangler dev .output/server/index.mjs --site .output/public --local', and while the --local part is no longer needed - --site .output/public is. It is the directory that __STATIC_CONTENT_MANIFEST resolves to.

@YannicEl, if you're like me and don't want a whole lot of options passed to your wrangler dev command, just add the following to your wrangler.toml file and you'll be good:

main = './.output/server/index.mjs'

[site]
bucket = './.output/public'

I think you can close this issue as 'not-a-bug'.

For reference, here's a working example with both methods: https://codesandbox.io/p/devbox/nitro-cloudflare-p287wf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants