Open layershifter opened 1 year ago
this.load()
would be the right way to handle it, but currently it's freezing on https://github.com/vitejs/vite/blob/a2e9fb5243874686603814f41410c5b9ba6ac54a/packages/vite/src/node/plugins/optimizedDeps.ts#L48
Our current flow is that we're resolving optimized depedencies eagerly, so you're getting a path that doesn't exist yet. But we're prebundling lazily after every browser requests is settled. We should have some heuristic to prebundle anyway if the waiting has been stucked for X amount of time like in this case, but maybe we're missing something.
@layershifter Are there any updates? ππ
@layershifter Are there any updates? ππ
@kriakiku I think that you tagged a wrong person.
are you satisfied answer?
Has there been any new API that can deal with this? :bow:
It makes it impossible for linaria to work in many projects, more deps = higher chance of this happening...
Another option to get it working is to add:
optimizeDeps: {
disabled: true,
},
to the vite config, however this breaks bundling commonjs dependencies (as they need to be optimized to work with ESM I assume).
So apparently optimizeDeps.disabled
is deprecated and will be removed in vite 5.1
(as per the warning being generated), so the workaround will stop working in newer versions.
Is anyone currently looking at this?
Describe the bug
Hello folks π
I am working on Linaria with @Anber, recently we an issue about the problem in dev mode, https://github.com/callstack/linaria/issues/1246.
To provide context, Linaria performs module evaluation like
vite-node
as we need to transform styles and for that we should know actual values, for example:For that, we will load files on our side, transform, evaluate and get results. The problem that we faced with Vite is that when dependencies are resolved (https://github.com/callstack/linaria/blob/15fa87a5aab54aec0b8294b81a116aa488e4a417/packages/vite/src/index.ts#L116-L123), they don't exist on a disk yet. For example:
(see Stackblitz repro)
The hack that we made is to call
optimizeDeps()
forcefully, https://github.com/callstack/linaria/pull/1358. Another solution is to forcescan
mode:Both options don't seem correct. Is there API to get path to a module in
node_modules
via.resolve()
or is it possible to read resolved file in this case?For example, if we will try to use
.load()
, Vite will be frozen:I am not entirely sure that described issue is a bug as it looks like a thing by design, but I would appreciate your input. Thanks.
Reproduction
https://stackblitz.com/edit/vitejs-vite-xftvql
Steps to reproduce
npm run dev
System Info
Used Package Manager
npm
Logs
No response
Validations