-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Module resolution of declared exports doesn't work for local package #15412
Comments
|
It seems that |
Thanks for investigating. Does that mean an issue with esbuild should be opened? I’m not quite sure how to use that without vite. Also, is there a workaround for specifying the side effects of the sub-package in the project, so that builds would work? |
Sorry for missing some information due to my negligence. It seems that import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
preserveSymlinks: true
}
}) |
So is this something that should always be set to true when using any local packages? Not sure I understand what's a bug here vs. expected behaviour – for me it is certainly unintuitive that I need to change defaults when switching from a production package to a local package. |
I personally feel that in most cases, if the package manager (excluding |
Even after setting I have changed module type to |
I hope you can open a new issue and provide a reproducible repository, which may make it easier to help you. @AmreeshTyagi |
I tried the reproduction with 5.1.6 and 5.2.0-beta.0. 5.1.6 didn't work but 5.2.0-beta.0 worked. |
Describe the bug
Follow-up to #15319.
I'm having issues with vite not correctly resolving imports when a dependency package is a local package. In that case it seems all information in the package.json of that local package is ignored, including
exports
andsideEffects
, causing various unexpected problems.I think I found a reliable way to reproduce:
In a super basic project like https://stackblitz.com/edit/vitejs-vite-bmmruk, if you clone it locally and switch from
to a local clone of the three.js repo on the r160 tag:
Then you immediately get module resolution errors and nothing works:
... until a
vite.config.js
is added that aliases all of the things already declared in the package.json of three.js:If you, after adding the aliases, do
npm run preview
you'll see that sideEffects specified in three's package.json are also not respected; there is missing functionality / a broken build as described in #15319.My expectation would be that
Reproduction
https://stackblitz.com/edit/vitejs-vite-bmmruk
Steps to reproduce
npm i && npm run dev
System Info
System: OS: macOS 14.1.2 CPU: (12) arm64 Apple M2 Max Memory: 724.88 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.9.0 - /usr/local/bin/node npm: 10.1.0 - /usr/local/bin/npm Browsers: Chrome: 120.0.6099.129 Edge: 115.0.1901.188 Safari: 17.1.2 npmPackages: vite: ^5.0.8 => 5.0.10
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: