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

ERR_MODULE_NOT_FOUND when inlining some modules #2308

Closed
huang-julien opened this issue Mar 24, 2024 · 2 comments
Closed

ERR_MODULE_NOT_FOUND when inlining some modules #2308

huang-julien opened this issue Mar 24, 2024 · 2 comments

Comments

@huang-julien
Copy link
Contributor

Environment


  • Operating System: Windows_NT
  • Node Version: v20.10.0
  • Nuxt Version: -
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.3
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/unjs-nitro-starter-mhus1e?file=module%2Fmod.ts,module%2Fruntime%2Fplugin.ts,nitro.config.ts&title=Nitro%20Starter

Describe the bug

There's currently an issue (again sorry 🙏) with applicationinsights node.

We have a different issue on stackblitz and windows.

On windows we have
315223782-3fba0b2a-3488-4761-bf25-8c048a30cf0e

while on stackblitz the module is not found.

The only way to fix it seems to be to force the resolution of mlly to 1.4.0.

I think it's probably due the strip comment feature for mlly hasEsmSyntax and hasCjsSyntax is behind an experimental feature flag not enabled by default.

Additional context

The issue with windows is that the absolute paths generated in .nitro/dev/index.mjs are generated without file:// for applicationinsights imports.
image

After manually adding them back
image

We have another issue which is the stackblitz one.

Logs

No response

@huang-julien
Copy link
Contributor Author

huang-julien commented Mar 26, 2024

here's the ouput with mlly 1.4.0

import * as ApplicationInsights from 'file://G:/repo/nitro/node_modules/.pnpm/[email protected]/node_modules/applicationinsights/out/applicationinsights.js';
import ApplicationInsights__default, { DistributedTracingModes } from 'file://G:/repo/nitro/node_modules/.pnpm/[email protected]/node_modules/applicationinsights/out/applicationinsights.js';

seems like experimental.legacyExternal solve the issue too !

@pi0
Copy link
Member

pi0 commented Mar 27, 2024

We probably cannot safely enable stripping comments for mlly until next major version that uses AST-aware stripping.

I know it is a pain for some legacy modules but making changes to CJS/ESM detection that can fixes one legacy module can break other legacy modules.

I am closing this issue because the only common reported case is applicationinsights but if there are more common legacy packages that having issues, i would be happy to see what we can do for Nitro v2 fix.

Made a tracker issue in huang-julien/nitro-applicationinsights#59 for an alternative suggestion.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
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

2 participants