brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
449 stars 12 forks source link

SyntaxError CLIENT Cannot declare a function that shadows a let/const/class/function variable 'i'. build/node_modules/brisa/jsx-runtime/index.js::1:0 #520

Open swiftcoder opened 1 month ago

swiftcoder commented 1 month ago

I'm not entirely sure how I'm triggering this, but it seems to occur after adding/removing a web component. Once I'm in this situation, build and start work fine, but the dev command fails every page load with some variation on the following:

$ brisa dev
[ info ]   🚀 Brisa 0.1.0: Running on Bun.js 1.1.29
[ wait ]  starting the development server...
[ info ]   ✓   Compiled successfully!
[ info ]   compiled successfully in 753.64ms.
[ info ]   hot reloading enabled
[ info ]   listening on http://localhost:3000
[ error ]   Ops! Error:
[ error ]   --------------------------
[ error ]   SyntaxError: Cannot declare a function that shadows a let/const/class/function variable 'i'.
    at <parse> (/Users/tristam/projects/feersum-brisa/build/node_modules/brisa/jsx-runtime/index.js:2)
    at <anonymous> (:11:43)
    at processTicksAndRejections (:12:39)

Any pointers as to what I might be doing wrong? Is there a web-component cache I need to blow away?

aralroca commented 1 month ago

@swiftcoder Does it happen to you from the beginning when you initialize a project or has it happened to you afterwards? If the latter, could you share some code?

And what platform is your computer?

aralroca commented 1 month ago

Maybe can be related with this Bun issue: https://github.com/oven-sh/bun/issues/12176#issuecomment-2192888603

swiftcoder commented 1 month ago

I figured out the issue eventually, by commenting out code till I isolated it. It looks like an incompatibility with trying to import from a library that does an export *

The easiest repro I have to hand is with THREE.js. If you add Three to your project and then try and import * as THREE from 'three'; or import { GLTFLoader } from "three/examples/jsm/Addons.js";, then brisa dev will choke.

Switching to the old require(...) syntax unbreaks it, as does importing inner modules (rather than the export * re-exports in the top-level files)

$ uname -mprs
Darwin 23.6.0 arm64 arm
aralroca commented 1 month ago

@swiftcoder this Bun issue is fixed in the latest version of Bun, can you check that it does not happen to you anymore? 🙏 Thanks