-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
vite tries to resolve dependencies despite they're marked as external #11048
Comments
Are you looking for Vite config |
Ah, configuring rollup exports explicitly does work, I thought I tried that already, so there's a workaround: export default {
build: {
rollupOptions: {
external: ['mod-b']
}
}
} |
I have somewhat similar issue where in I'm trying to use dynamic import. My code looks something like: // src/main.ts
import("./data.json", { assert: { type: 'json' } }).then(data => {
/// use data ///
}); The suggestion of using // dist/assets/index-[hash].js
import("../src/data.json", ...) What I want is to ignore Note that for now, I'm just putting in a dummy |
Could this be related to #13530? But probably not, because your issue also seems to be a problem before Vite 4.3 from April 2023 (https://github.com/vitejs/vite/releases/tag/v4.3.0). |
i have the same issue also. the only difference is that i've upraded vite from EDIT: |
add build rollupOptions external still not work.report Error [ERR_MODULE_NOT_FOUND]: Cannot find module PS:I use sveltekit. |
In case you still want to use the export default defineConfig(({ mode }) => {
return {
plugins: [mode === "development" ? react() : undefined],
...
build: {
rollupOptions: {
external: ["react", "react-dom"],
},
},
};
}); |
Hello, I tried a simpler demo by externalizing
and then in Do I misunderstand the Thanks PS: |
Describe the bug
Hi there,
we're using vite inside a big monorepo and I'm experiencing an unexpected issue when building with libraries marked as external. We're trying to build each module in parallel, but the
vite
build fails because a dependency is not yet built.This should not happen, because the dependency is explicitly flagged as
external
(andvite --ssr
already defaults to having every bare import external by default).vite
reading and interpreting the external dependency somewhat defeats the point of having itexternal
in the first place. It is not bundled in the output (good), but it slows the build down and would introduce unnecessary serialization into the build (that plainrollup
does not require).Reproduction
https://github.com/michael42/vite-verifies-exports-of-externals
Steps to reproduce
npm install
npm run build-a
Error: Failed to resolve entry for package "mod-b". The package may have incorrect main/module/exports specified in its package.json.
npm run build-b
, thennpm run build-a
againimport { test } from "mod-b";console.log(test);
)System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: