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

rollup resolve issue for commonJS packages (applicationinsights) #1726

Open
huang-julien opened this issue Sep 14, 2023 · 13 comments
Open

rollup resolve issue for commonJS packages (applicationinsights) #1726

huang-julien opened this issue Sep 14, 2023 · 13 comments

Comments

@huang-julien
Copy link
Contributor

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

https://stackblitz.com/edit/nuxt-starter-z1b17v?file=server%2Futils%2Fapplicationinsights.ts,server%2Fmiddleware%2Fapplicationinsights.ts

  • try npm run dev
  • RollupError: Could not resolve "./AutoCollection/CorrelationContextManager" from ./AutoCollection/CorrelationContextManager?commonjs-external"

Describe the bug

Hi 👋

Since 3.7, importing applicationinsights breaks the whole app. This was working with 3.6.5.
I believe this is probably an issue with Nitro instead of Nuxt.

Why didn't microsoft release ESM for this package ? 😱

Additional context

cloned from nuxt/nuxt#23200

Logs

No response

@huang-julien
Copy link
Contributor Author

this issue seems to be introduced in 2.6
nuxt/nuxt#23200 (comment)

@pi0
Copy link
Member

pi0 commented Sep 14, 2023

Thanks for reporting it here! If you had a chance to scope it down to a minimal nitro only reproduction that would be great otherwise will check it soon if can find a solution for esm compatibility.

@pi0 pi0 changed the title rollup resolve issue for commonJS packages rollup resolve issue for commonJS packages (applicationinsights) Sep 14, 2023
@huang-julien
Copy link
Contributor Author

huang-julien commented Sep 14, 2023

Here's the nitro reproduction 😃
https://stackblitz.com/edit/unjs-nitro-9kdgkw?file=package.json,utils%2Fapplicationinsights.ts,middleware%2Fapplicationinsights.ts,nitro.config.ts&title=Nitro%20Starter

We have some issues:

  • on at least >=2.4.0 __dirname being not defined. However it is not reproduced on nuxt 3.6.5 with 2.5.2. On the reproduction, this can be fixed with a replace to import.meta.url
  • on >=2.6.0 the current resolve issue

@huang-julien
Copy link
Contributor Author

huang-julien commented Sep 22, 2023

Finally found the commit. Seems like upgrading mlly from 1.4.0 to 1.4.1 causes this issue

well the current workaround for nitro and nuxt projects is to set the resolution of mlly to 1.4.0

f76f0da

https://stackblitz.com/edit/unjs-nitro-hf1ez1?file=package.json,utils%2Fapplicationinsights.ts,tsconfig.json&title=Nitro%20Starter

@alimozdemir
Copy link

Any news on it?

@huang-julien
Copy link
Contributor Author

@alimozdemir you can set the resolution of mlly to 1.4.0 for now.

@rymdkapten
Copy link

Finally found the commit. Seems like upgrading mlly from 1.4.0 to 1.4.1 causes this issue

well the current workaround for nitro and nuxt projects is to set the resolution of mlly to 1.4.0

f76f0da

https://stackblitz.com/edit/unjs-nitro-hf1ez1?file=package.json,utils%2Fapplicationinsights.ts,tsconfig.json&title=Nitro%20Starter

Maybe I'm misunderstanding something, but your linked stackblitz seem to throw the same exception in the terminal.

image

The same happens when I try it on my local machine.

@huang-julien
Copy link
Contributor Author

Can you try with pnpm or yarn ? forcing the resolution of mlly to 1.4.0 doesn't seems to work with npm :(

@rymdkapten
Copy link

Can you try with pnpm or yarn ? forcing the resolution of mlly to 1.4.0 doesn't seems to work with npm :(

Ah, that's unfortunate. In my case, I'm unable to use any other package manager.

Thanks for the quick reply!

@rymdkapten
Copy link

Just popping by again to mention that the same can be achieved in npm by adding the following to package.json:

"overrides": {
    "mlly": "1.4.0"
}

and then running npm install.

I'll get back if I figure out some better solution though!

ipatate added a commit to double-slash-podcast/website that referenced this issue Nov 16, 2023
ipatate added a commit to double-slash-podcast/website that referenced this issue Nov 16, 2023
* update all dependencies and add resolution for error from package nitrojs/nitro#1726

* fix og:image
@goodpixels
Copy link

Downgrading mlly to 1.4.0 doesn't work for me either. Unable to deploy our app :/

@huang-julien
Copy link
Contributor Author

do you have a small reproduction please ?
Try to see if mlly has really been downgraded to 1.4.0 with pnpm/yarn/npm why

@goodpixels
Copy link

Hey! Thanks for a quick reply. I don't have a reproduction, but it's definitely a problem with an import of Sheet JS. Disabling the import completely fixes the build.

import * as XLSX from "xlsx"

package.json

"devDependencies": {
    "@iconify/json": "^2.2.152",
    "@nuxt/content": "^2.9.0",
    "@nuxt/devtools": "latest",
    "@nuxt/image": "^1.1.0",
    "@nuxtjs/i18n": "^8.0.0-rc.7",
    "@tailwindcss/typography": "^0.5.10",
    "@types/node": "^20.10.3",
    "mapbox-gl": "^3.0.0",
    "nuxt": "^3.8.2",
    "nuxt-gtag": "^1.1.1",
    "nuxt-icon": "^0.6.6",
    "prettier": "^3.1.0"
  },
  "dependencies": {
    "@googleapis/sheets": "^5.0.5",
    "@kgierke/nuxt-basic-auth": "^1.3.1",
    "@medusajs/medusa-js": "^6.1.4",
    "@nuxt/ui": "^2.11.0",
    "@nuxtjs/algolia": "^1.10.1",
    "@nuxtjs/google-fonts": "^3.1.0",
    "@pinia/nuxt": "^0.5.1",
    "@vueuse/components": "^10.7.0",
    "@vueuse/core": "^10.7.0",
    "@zag-js/editable": "^0.17.0",
    "@zag-js/range-slider": "^0.17.0",
    "@zag-js/tabs": "^0.17.0",
    "@zag-js/vue": "^0.17.0",
    "color": "^4.2.3",
    "csvtojson": "^2.0.10",
    "lodash": "^4.17.21",
    "lodash-es": "^4.17.21",
    "nuxt-mapbox": "^1.5.5",
    "nuxt-svgo": "^3.7.0",
    "pinia": "^2.1.7",
    "postcss-custom-properties": "^13.3.2",
    "slugify": "^1.6.6",
    "typescript": "^5.3.2",
    "vite-plugin-inspect": "^0.8.1",
    "vue-tsc": "^1.8.25",
    "xlsx": "^0.18.5",
    "yup": "^1.3.2",
    "yup-password": "^0.2.2"
  },
  "overrides": {
    "vite-plugin-inspect": "0.7.38",
    "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz"
  }

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

5 participants