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

Issue building with Vite 5 #288

Closed
lewiswolf opened this issue Nov 19, 2023 · 16 comments
Closed

Issue building with Vite 5 #288

lewiswolf opened this issue Nov 19, 2023 · 16 comments

Comments

@lewiswolf
Copy link

I am getting the below error when I build my project with Vite 5. This issue was not present with Vite 4.5 however.

[commonjs--resolver] Identifier "m" has already been declared
file: /Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/@p5-wrapper/react/dist/component/react.js:17165:364
17163:           if (!g || !g.isTextureShader())
17164:             return this._getLightShader();
17165:         } else if (!g)
                             ^
17166:           return this._getColorShader();
17167:         return g;
error during build:
RollupError: Identifier "m" has already been declared
    at error (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at Module.error (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:12728:16)
    at BlockScope.addDeclaration (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:7522:32)
    at Identifier.declare (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:7193:39)
    at VariableDeclarator.declareDeclarator (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:10169:17)
    at VariableDeclaration.initialise (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:11834:24)
    at new NodeBase (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:4607:14)
    at new VariableDeclaration (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:11806:1)
    at BlockStatement.parseNode (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:4718:27)
    at new NodeBase (file:///Users/lewiswolstanholme/Desktop/lewiswolstanholme/node_modules/rollup/dist/es/shared/node-entry.js:4606:14)
@jamesrweb
Copy link
Collaborator

Can you share your vite config for v4.5 and v5?

@lewiswolf
Copy link
Author

lewiswolf commented Nov 19, 2023

Sure thing. :)

import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'
import { compression } from 'vite-plugin-compression2'
import svgr from 'vite-plugin-svgr'

// https://vitejs.dev/config/
export default defineConfig({
	assetsInclude: ['**/*.md'],
	plugins: [
		compression({
			algorithm: 'gzip',
			include: /\.(js|mjs|json|css|svg)$/i,
		}),
		react(),
		svgr(),
	],
})

@RossKlein
Copy link

I am having the same issue

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})

@jamesrweb
Copy link
Collaborator

@lewiswolf @RossKlein So you're telling me that v4.x vite works fine but v5.x is broken and you didn't change the config between versions or anything? To be honest I haven't looked into v5.x yet myself and I can only think that since its a major version change, perhaps the react plugin hasn't updated yet OR that v5.x introduced breaking changes causing this. It should "just work". I will be making a release tonight or tomorrow but I doubt that will change anything since the repo changes are internal type changes and dependency updates mostly. What do you guys think?

@ZOASR
Copy link

ZOASR commented Nov 20, 2023

Having mostly the same issue

error during build:
RollupError: Identifier "r" has already been declared

error happens at the same line

at error ([project-root]/node_modules/rollup/dist/es/shared/parseAst.js:337:30)

@yevdyko
Copy link
Collaborator

yevdyko commented Nov 20, 2023

@jamesrweb I can try updating vite in my personal project that uses it to build the app including the react p5 wrapper, and reproduce the issue if possible. I will let you know tomorrow

@jamesrweb
Copy link
Collaborator

jamesrweb commented Nov 21, 2023

@jamesrweb I can try updating vite in my personal project that uses it to build the app including the react p5 wrapper, and reproduce the issue if possible. I will let you know tomorrow

Sounds good @yevdyko, thank you 🙏🏻

@RossKlein
Copy link

@jamesrweb for me it is acceptable to use 4.5 so I downgraded vite. With no other changes p5 wrapper worked.

ZOASR added a commit to ZOASR/p5-sketches that referenced this issue Nov 21, 2023
@jamesrweb
Copy link
Collaborator

@RossKlein @lewiswolf @yevdyko it is definitely a breaking change somewhere from Rollup / Vite. I tested upgrading Vite to v5 for this library and the same issue happens as you get also. I guess it's a "read the docs for your own project" scenario guys!

@RossKlein
Copy link

@jamesrweb wait sorry, I don’t understand what you mean. Is this something that you can’t fix?

@jamesrweb
Copy link
Collaborator

@jamesrweb wait sorry, I don’t understand what you mean. Is this something that you can’t fix?

Exactly, it's a Vite 5 or Rollup breaking change. Not related to this library.

@jamesrweb jamesrweb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
@lewiswolf
Copy link
Author

Thanks for your help everyone

@yevdyko
Copy link
Collaborator

yevdyko commented Nov 25, 2023

@lewiswolf I tried to upgrade my app to vite version 5 and got the same rollup build error: rollup/rollup#5259

It looks like they fixed it in rollup version 4.5.1, but it still doesn't work for me and it's definitely not related to this react component

@RossKlein
Copy link

@yevdyko Use version 4.5.0 it works

@yevdyko
Copy link
Collaborator

yevdyko commented Nov 25, 2023

@RossKlein yeah, I meant that there was an attempt to fix the problem in rollup with version 4.5.1, but the previous vite version as 4.5.0 works, that's true

@yevdyko
Copy link
Collaborator

yevdyko commented Dec 4, 2023

FYI: I had a successful build with these versions:

  • @vitejs/plugin-react: 4.2.0
  • vite: 5.0.4

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

No branches or pull requests

5 participants