question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite >=3.1.5 breaks Jotai babel plugins

See original GitHub issue

Describe the bug

Vite 3.1.5 changed the processing of package exports. This breaks two Jotai plugins (debug-label and react-refresh).

vite dev chokes with the following error:

image

Reverting to 3.1.4 makes the error go away.

The author of Jotai thinks this may be a vite problem, not a problem with Jotai itself.

See discussion with initial analysis here: https://github.com/pmndrs/jotai/issues/1475

Reproduction

https://github.com/gunters63/jotei-vite-import-error

Steps to reproduce

pnpm install, then pnpm dev

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 AMD Ryzen 9 6900HS with Radeon Graphics        
    Memory: 6.27 GB / 31.26 GB
  Binaries:
    Node: 18.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.608.0), Chromium (106.0.1370.37)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vite: 3.1.7 => 3.1.4

Used Package Manager

pnpm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
aleclarsoncommented, Nov 14, 2022

Isn’t this issue about config bundling only?

Ah ok, my mistake!

I think the plan is to allow users to omit “module” from the resolve.conditions option in order to prevent it from being used (assuming I fully understand the intent of #10683).

I implemented in a way that we could do like that in future. But that is not the main intent of that PR. The intent was to make module not be used when config bundling.

Yeah, I worded my comment poorly. I wasn’t saying that it was the only or even the main intent of #10683, but I noticed it was implied in the overrideConditions description.

1reaction
sapphi-redcommented, Nov 14, 2022

I think the plan is to allow users to omit “module” from the resolve.conditions option in order to prevent it from being used (assuming I fully understand the intent of https://github.com/vitejs/vite/pull/10683).

I implemented in a way that we could do like that in future. But that is not the main intent of that PR. The intent was to make module not be used when config bundling.

I think removing module condition from the normal Vite pipeline is a different thing from this issue. (IMO Vite should use module condition for isRequire: false because of the intent of this condition: https://github.com/webpack/webpack/issues/11014, https://github.com/rollup/rollup/issues/3514, https://github.com/rollup/plugins/tree/master/packages/node-resolve#exportconditions)

About chaging the resolve.conditions, I’ve left explanations about it in #10917.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vite 3.1.5 breaks Jotai babel plugins · Issue #1475 - GitHub
Using the debug label and react refresh plugins does not work anymore starting with Vite 3.1.5. vite dev chokes with the following error:....
Read more >
Vite — Jotai, primitive and flexible state management for React
Vite. You can use the plugins from the jotai/babel bundle to enhance your developer experience when using Vite and Jotai. In your vite.config.ts...
Read more >
Babel - Storybook
Babel. Storybook's webpack config by default sets up Babel for ES6 transpiling. It has three different modes: CRA - the mode for Create...
Read more >
docs/guides/vite.mdx | jotai@v1.6.5 - Deno
You can use the plugins from the `jotai/babel` bundle to enhance your developer experience when using Vite and Jotai. In your `vite.config.ts`: ```tsimport ......
Read more >
How to combine Webpack 4 and Babel 7 to create a fantastic ...
Babel introduced a breaking change (for the greater good, ... @babel/plugin-syntax-dynamic-import This is what helps with code splitting.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found