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

ESM syntax detection and CJS syntax detection goes through comments #195

Closed
huang-julien opened this issue Sep 23, 2023 · 0 comments · Fixed by #196
Closed

ESM syntax detection and CJS syntax detection goes through comments #195

huang-julien opened this issue Sep 23, 2023 · 0 comments · Fixed by #196

Comments

@huang-julien
Copy link
Contributor

huang-julien commented Sep 23, 2023

Environment

Operating System: Windows_NT
Node Version: v16.20.0
Nuxt Version: 3.7.3
CLI Version: 3.8.3
Nitro Version: 2.6.3
Package Manager: yarn@1.22.19
Builder: -
User Config: -
Runtime Modules: -
Build Modules: -

Reproduction

Nuxt (application insights): https://stackblitz.com/edit/nuxt-starter-z1b17v?file=server%2Futils%2Fapplicationinsights.ts,server%2Fmiddleware%2Fapplicationinsights.ts
Nitro (application insights): https://stackblitz.com/edit/unjs-nitro-9kdgkw?file=package.json,utils%2Fapplicationinsights.ts,middleware%2Fapplicationinsights.ts,nitro.config.ts&title=Nitro%20Starter

Mlly only (copy of applicationinsights):https://stackblitz.com/edit/node-gz9scl?file=index.mjs,withoutExportsImportInComment.mjs,applicationInsightTest.mjs

Describe the bug

there's currently a bug with some commonJS package on nitro due to having "esm syntax" within comments because we're using a regex

hasESMSyntax can return true when having export import within a comment for example

Additional context

Nitro issue
Nuxt issue

Logs

No response

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

Successfully merging a pull request may close this issue.

1 participant