bridgetownrb / bridgetown

A next-generation progressive site generator & fullstack framework, powered by Ruby
https://www.bridgetownrb.com
MIT License
1.16k stars 113 forks source link

`config/esbuild.defaults.js` does not support `entryPoints` as an object #920

Closed KonnorRogers closed 1 month ago

KonnorRogers commented 1 month ago

Bridgetown Version: 2.0.0.beta2

To Reproduce

const esbuildOptions = {
  entryPoints: {     
    "javascript/index": "frontend/javascript/index.js",
  }
}

Current behavior

You'll get the following error:

[Frontend] /Users/konnorrogers/projects/oss/content-editable/docs/config/esbuild.defaults.js:342
[Frontend]     entryPoints: [...entryPoints, ...islands],
[Frontend]                      ^
[Frontend]
[Frontend] TypeError: entryPoints is not iterable
[Frontend]     at module.exports (/Users/konnorrogers/projects/oss/content-editable/docs/config/esbuild.defaults.js:342:22)

Expected behavior

Should accept an object.

Screenshots

Computing environment (please complete the following information):

Additional context

jaredcwhite commented 1 month ago

@KonnorRogers So…I'm trying to find esbuild documentation that explains object syntax here vs. array, and all I'm seeing here:

https://esbuild.github.io/api/#entry-points

is out/in syntax which does something very specific (lets you map an input file to a differently named output file). I don't know if "javascript/index": "frontend/javascript/index.js", is a valid option. 🤔

KonnorRogers commented 1 month ago

@jaredcwhite its just poorly documented.

its 100% a valid option.

I use it for Light Pen and Role Components

https://github.com/KonnorRogers/role-components/blob/90976ad2a604b285e0efb2c72a76cf9bdd1b33d6/docs/esbuild.config.js#L29-L32

https://github.com/KonnorRogers/light-pen/blob/96ea7256866132439ca2219fd86890f91c797b3b/docs/esbuild.config.js#L41-L45

jaredcwhite commented 1 month ago

Ah, OK I see some of the entries there. Interesting!

KonnorRogers commented 1 month ago

@jaredcwhite The object syntax is actually more flexible than arrays. So I could do something like:

{
  "my-custom-index-path": "frontend/javascript/index.js"
}

So then frontend/javascript/index.js will turn into my-custom-index-path.[hash].js in your final output.