lustre-labs / dev-tools

Lustre's CLI and development tooling: zero-config dev server, bundling, and scaffolding.
45 stars 15 forks source link

`build` command does not check for reserved words before building. #5

Closed hayleigh-dot-dev closed 5 months ago

hayleigh-dot-dev commented 5 months ago

In gleam it's entirely possible to have modules and functions that use names that would be reserved in javascript. Eg you can have a function called new even though new is a javascript keyword. This is possible because the gleam compiler will actually name the function new$ when emitting js.

Lustre's build tooling doesn't currently take this into account.

✅ Project compiled successfully
✅ Esbuild installed!
❌ Bundling with esbuild

I ran into an error while trying to create a bundle with esbuild:
✘ [ERROR] No matching export in "build/dev/javascript/shared/shared/components/counter.mjs" for import "new"

    build/.lustre/entry.mjs:2:24:
      2 │          import { name, new as component } from '../dev/javascript/...
        │                         ~~~
        ╵                         new$

  Did you mean to import "new$" instead?

    build/dev/javascript/shared/shared/components/counter.mjs:70:16:
      70 │ export function new$() {
         ╵                 ~~~~

1 error