Skip to content
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 5 / Rollup 4 build warning in v2.6.0 #2269

Open
Kamahl19 opened this issue Nov 25, 2023 · 14 comments
Open

Vite 5 / Rollup 4 build warning in v2.6.0 #2269

Kamahl19 opened this issue Nov 25, 2023 · 14 comments

Comments

@Kamahl19
Copy link

Kamahl19 commented Nov 25, 2023

The combination of upgrading to Vite 5 (Rollup 4) and Jotai 2.6.0 results in an error during building

node_modules/jotai/esm/react.mjs (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.

This error does not happen in 2.5.1 and also does not happen in Vite 4 + Jotai 2.6.0.

@dai-shi
Copy link
Member

dai-shi commented Nov 25, 2023

@himself65 Was rollup-plugin-banner2 too easy solution??

@himself65
Copy link
Collaborator

@himself65 Was rollup-plugin-banner2 too easy solution??

Might be. I was worried about this before
#2241 (reply in thread)

@himself65
Copy link
Collaborator

Here is the minimum reproduction

https://stackblitz.com/edit/vitejs-vite-v2qh9v?file=src%2Fmain.ts

@himself65
Copy link
Collaborator

@Kamahl19 Hi, would you try to use https://github.com/huozhi/rollup-plugin-swc-preserve-directives to see if the error disappear

@Kamahl19
Copy link
Author

I get even more errors. Maybe I misunderstood. Should I just add it to the vite plugin?

@himself65
Copy link
Collaborator

I get even more errors. Maybe I misunderstood. Should I just add it to the vite plugin?

Could you please share you vite config?

@himself65
Copy link
Collaborator

I just tried, and there's only one warning that won't cause building interrupt.

main.js → output...
(!) Module level directives cause errors when bundled, "use client" in "node_modules/.pnpm/[email protected][email protected]/node_modules/jotai/esm/react.mjs" was ignored.
node_modules/.pnpm/[email protected][email protected]/node_modules/jotai/esm/react.mjs (1:0)
1: 'use client';
   ^
2: import ReactExports, { createContext, useContext, useRef, createElement, useReducer, useEffect, useDebugValue, useCal...
3: import { getDefaultStore, createStore } from 'jotai/vanilla';

@himself65

This comment was marked as outdated.

@dai-shi
Copy link
Member

dai-shi commented Nov 27, 2023

Can this be an upstream issue?

vitejs/vite#15012

@dai-shi
Copy link
Member

dai-shi commented Feb 24, 2024

Any updates on this? Anyone?

@himself65
Copy link
Collaborator

himself65 commented Feb 26, 2024

Error is still here

https://stackblitz.com/edit/vitejs-vite-v2qh9v

~/projects/vitejs-vite-v2qh9v 2s
❯ npm run build

> [email protected] build
> tsc && vite build

vite v5.1.4 building for production...
node_modules/jotai/esm/react.mjs (1:0) Module level directives cause errors when bundled, "use client" in "node_modules/jotai/esm/react.mjs" was ignored.
✓ 12 modules transformed.
dist/index.html                0.38 kB │ gzip: 0.27 kB
dist/assets/index-Kr26tfIY.js  7.35 kB │ gzip: 3.07 kB
✓ built in 462ms

@himself65
Copy link
Collaborator

Related vitejs/vite#15012 (comment)

@dai-shi
Copy link
Member

dai-shi commented Feb 26, 2024

thanks. btw, it's not "error" that stops building, but just "warning", correct?

@himself65
Copy link
Collaborator

himself65 commented Feb 26, 2024

oh yeah, a warning

@dai-shi dai-shi changed the title Vite 5 / Rollup 4 build error in v2.6.0 Vite 5 / Rollup 4 build warning in v2.6.0 Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants