Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
63 stars 19 forks source link

Vite production bundling issue #375

Open dysfunc opened 9 months ago

dysfunc commented 9 months ago

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.

jamesmengo commented 2 months ago

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