nitro
nitro copied to clipboard
Preset cloudflare not ignoring optional require()
Environment
node v16.14.2 nitropack 0.4.7
Reproduction
https://stackblitz.com/edit/github-dfijad?file=nuxt.config.ts
run npm run build
Describe the bug
Default preset works well when building with package with optional require() (in my case, mogodb)., but not with preset cloudflare.
It throws
ERROR Rollup error: Cannot resolve "snappy/package.json" from "/home/projects/github-dfijad/node_modules/mongodb/lib/deps.js" and externals are not allowed!
ERROR Cannot resolve "snappy/package.json" from "/home/projects/github-dfijad/node_modules/mongodb/lib/deps.js" and externals are not allowed!
Additional context
Code snap from mongodb sdk
try {
// Ensure you always wrap an optional require in the try block NODE-3199
Snappy = require('snappy');
try {
(Snappy as any)[PKG_VERSION] = parsePackageVersion(require('snappy/package.json'));
} catch {} // eslint-disable-line
} catch {} // eslint-disable-line
Logs
No response
I am experiencing thesame issue as above . thing is i can not even tell what is causing the error. the package referred to does not exist in my project
Same issue with the Cloudflare preset here :/
Same issue when upgraded nuxt to 3.0.0-rc.8-27699522.e38e1de https://stackblitz.com/edit/github-dfijad-x7236k?file=nuxt.config.ts,app.vue,package.json
MongoDB is not compatible with worker platforms. Please follow up via #949