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

Sass imports ignore package.sass if package.exports exists #11947

Closed
7 tasks done
KaelWD opened this issue Feb 6, 2023 · 5 comments · Fixed by #7817
Closed
7 tasks done

Sass imports ignore package.sass if package.exports exists #11947

KaelWD opened this issue Feb 6, 2023 · 5 comments · Fixed by #7817
Labels
p2-to-be-discussed Enhancement under consideration (priority)

Comments

@KaelWD
Copy link
Contributor

KaelWD commented Feb 6, 2023

Describe the bug

Node package with

{
  "name": "vuetify",
  "sass": "lib/styles/main.sass",
  "exports": {
    ".": "./lib/framework.mjs"
  }
}
  • import 'vuetify' in js loads vuetify/lib/framework.mjs
  • @use 'vuetify' in sass should load vuetify/lib/styles/main.sass, but instead throws "Failed to resolve entry for package"

This is caused by #11595, would be helped by #7817

Reproduction

https://stackblitz.com/edit/vitejs-vite-jdslxa?file=src%2Fstyle.scss

Steps to reproduce

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 18.60 GB / 31.28 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.74
    Firefox: 109.0.1
  npmPackages:
    @vitejs/plugin-vue: ^4.0.0 => 4.0.0 
    vite: ^4.1.1 => 4.1.1

Used Package Manager

npm

Logs

Click to expand!
file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:22004
    throw new Error(`Failed to resolve entry for package "${id}". ` +
          ^

Error: Failed to resolve entry for package "vuetify". The package may have incorrect main/module/exports specified in its package.json.
    at packageEntryFailure (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:22004:11)
    at resolvePackageEntry (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:22001:5)
    at tryNodeResolve (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:21736:20)
    at Context.resolveId (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:21487:28)
    at Object.resolveId (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:41587:46)
    at async Object.<anonymous> (file:///home/kael/Documents/vuetifyjs/test-projects/vitejs-vite-jdslxa/node_modules/vite/dist/node/chunks/dep-3007b26d.js:61953:21)

Validations

@juretopolak
Copy link

When upgrading Nuxt 3 to the latest version, it also upgraded its dependency: vite "~3.2.4" > vite "~4.1.1" which is causing me the same error:
[unhandledRejection] Failed to resolve entry for package "vuetify". The package may have incorrect main/module/exports specified in its package.json

@KaelWD do I have to wait for this issue/bug to be resolved or is there a workaround?

@KaelWD
Copy link
Contributor Author

KaelWD commented Feb 6, 2023

You can use vuetify/lib/styles/main.sass instead

@juretopolak
Copy link

@KaelWD thanks. Now it looks like I have another (very similar) problem with vite-plugin-vuetify.

ERROR Failed to resolve import "fsevents" from "node_modules/.vite/deps/vite-plugin-vuetify.js?v=5c4d3b75". Does the file exist?

https://codesandbox.io/p/github/juretopolak/nuxt3-tailwind-vuetify/nuxt-update?file=%2FREADME.md

I just can't get over all the errors with this update :)

@bluwy
Copy link
Member

bluwy commented Feb 11, 2023

Following the usual package resolution, mainFields will always not be used if the exports key exists. It was a bug before when Vite does the other way. I guess we need #7817 to fix this, maybe we can go with it.

@bluwy bluwy added p2-to-be-discussed Enhancement under consideration (priority) and removed pending triage labels Feb 11, 2023
@rcluis
Copy link

rcluis commented Feb 18, 2023

Any update on this?

@bluwy bluwy linked a pull request Feb 25, 2023 that will close this issue
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-to-be-discussed Enhancement under consideration (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants