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-i18-next does not build with netlify edge-functions as it relies on internal node js APIs #82

Closed
ninjaa opened this issue Dec 3, 2022 · 3 comments

Comments

@ninjaa
Copy link

ninjaa commented Dec 3, 2022

Any pointers would be much appreciated. Keen to use edge functions if possible, or at least to understand the path down the line

[commonjs--resolver] Cannot bundle Node.js built-in "module" imported from "node_modules/astro-i18next/dist/index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
 error   Cannot bundle Node.js built-in "module" imported from "node_modules/astro-i18next/dist/index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
Error: Cannot bundle Node.js built-in "module" imported from "node_modules/astro-i18next/dist/index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
    at error (file:///home/ninjaa/bp/agreeable-ascension/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at throwPluginError (file:///home/ninjaa/bp/agreeable-ascension/node_modules/rollup/dist/es/shared/rollup.js:21587:12)
    at Object.error (file:///home/ninjaa/bp/agreeable-ascension/node_modules/rollup/dist/es/shared/rollup.js:22541:20)
    at Object.resolveId (file:///home/ninjaa/bp/agreeable-ascension/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:33611:34)
    at Object.handler (file:///home/ninjaa/bp/agreeable-ascension/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:45606:19)
    at file:///home/ninjaa/bp/agreeable-ascension/node_modules/rollup/dist/es/shared/rollup.js:22748:40

Found a relatable issue for astrojs/image
withastro/astro#5307

@ninjaa
Copy link
Author

ninjaa commented Dec 3, 2022

Duplicate of #82

@ninjaa ninjaa closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2022
@fprl
Copy link

fprl commented Dec 4, 2022

Hi @ninjaa,

This is because edge functions don't have access to any node APIs, this is the same for Vercel Edge, Deno and Cloudflare workers (they are adding support for some packages here).

I was going to ask @yassinedoghri what does he think about creating a PR to handle this. I have been testing a solution, and I think a good way of handling this would be to re-introduce the resources option in configs. If this is set, then the i18next-fs-backend package — which is the one importing and using all the node APIs — won't be imported.

The only thing is that you would need to manually import all the translation files (if you are using namespaces). Is there any workaround for this last thing? Maybe a pre-build script that builds the resources object from all the translations files on the locales directory.

I think if this is solved, it can solve all the current issues with different environments (vercel edge, netlify edge, Deno and cloudflare workers).

PS: I recommend you to downgrade to 1.0.0-beta.12 and import everything you want in resources without using i18next-fs-backend.

@mihanc
Copy link

mihanc commented Jan 30, 2023

Any news about this issue?

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

No branches or pull requests

3 participants