theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

Vite production bundling issue

Open dysfunc opened this issue 2 years ago • 1 comments

Describe the bug When building a production bundle using vite build, the @shopify/prettier-plugin-liquid creates an exception:

RollupError: Identifier "x" has already been declared
    at error (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at Module.error (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:12737:16)
    at BlockScope.addDeclaration (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:7520:32)
    at Identifier.declare (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:7188:39)
    at VariableDeclarator.declareDeclarator (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:10178:17)
    at VariableDeclaration.initialise (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:11843:24)
    at new NodeBase (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:4607:14)
    at new VariableDeclaration (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:11815:1)
    at SwitchCase.parseNode (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:4718:27)
    at new NodeBase (file:///Library/WebServer/Documents/opensense/node_modules/rollup/dist/es/shared/node-entry.js:4606:14)

I've created a sample app using stackblitz that reproduces the issue. https://stackblitz.com/edit/vitejs-vite-xivzdt?file=src%2FApp.svelte.

If you run npm run dev, it will compile and work as expected. When you run npm run build, it will try to compile but eventually throws an exception for Identifier "x" has already been declared. I've isolated this issue to this package. If I comment out this package and its usage, my production builds succeed.

dysfunc avatar Nov 27 '23 20:11 dysfunc

Hey @dysfunc, Thanks for raising this - I Just wanted to confirm whether this is still an issue!

jamesmengo avatar Jul 04 '24 23:07 jamesmengo

closing as duplicate of https://github.com/Shopify/theme-tools/issues/240

mgmanzella avatar Oct 17 '24 19:10 mgmanzella