fix(config): don't use module condition (fixes #10430)#10495
fix(config): don't use module condition (fixes #10430)#10495sapphi-red wants to merge 1 commit intovitejs:mainfrom
module condition (fixes #10430)#10495Conversation
module conditionmodule condition (fixes #10430)
bluwy
left a comment
There was a problem hiding this comment.
I've also been thinking of a few ways to fix this, and this is much much elegant!
| if (result.external) { | ||
| return { path: result.path, external: true } | ||
| } | ||
| const absolutePath = path.resolve(importer, '..', result.path) |
There was a problem hiding this comment.
| const absolutePath = path.resolve(importer, '..', result.path) | |
| const absolutePath = path.resolve(path.dirname(importer), result.path) |
I'm not sure if it makes a difference, but I usually use path.dirname. But the .. trick here seems to work too.
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
|
@sapphi-red vite-plugin-ssr and SvelteKit are also failing in main, but the Vitest fail seems to be related to this PR 🤔 |
|
Could we add a test to ensure we don't revert #10430 in the future? |
|
It seems Vitest is failing because esbuild uses Sure. I'll add tests when we decided the approach. 👍 @bluwy What way did you have in mind? |
|
You might hate me for this, but I really like the esbuild solution, but otherwise we may have to use |
|
That's neat. But unfortunately I guess that will break scripts using |
|
Hmm yeah maybe an alternative for now is to go with no1. The initial idea I had was to introduce a If it happens to be a lot of work, |
|
superseded by #10528 |
Description
node does not use
modulecondition. But Vite was using that when bundling (replacing specifier with absolute path) config.This PR uses esbuild to resolve specifier instead of Vite's internal resolver.
I came up with three solutions for this.
noModuleConditionoption to vite's internal resolver and use that for config bundling (similar to fix(config): don't resolve by exports.module field #10442)import.meta.resolve/import-meta-resolve(ponyfill)import-meta-resolveis only 63.3kB and adding this won't affect the package size much. We could perfectly imitate node's resolver by using this. But I think we could just use esbuild's resolver as it's reliable enough and could be more performant.superseds #10442
fixes #10430
refs #10254 #10347 #10420
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).