Closed timriley closed 1 year ago
Lastly, apologies for the messy commit history here. This took a few twists and turns (and some of the usual "Tim figures out how to JavaScript again") before I got everything settled.
This is going to be squashed on merge anyway, and I'll make sure there's a good single commit message then. In the meantime, please see my overview in the PR description for the best way of inspecting the changes in this PR.
Introduce a new
assets.run
entrypoint function that is:Here's what a default
config/assets.mjs
file would look like using this API:And here's how it would look to add a custom esbuild plugin:
I've tested this exact config above in a real Hanami app and can confirm it actually works in terms of activating esbuild plugins.
In terms of code changes here, they are fairly wide-ranging. Sorry for the messy diff.
Let me guide you through the new landscape, however:
run
function that serves as the main entry point, as shown above in thoseconfig/assets.mjs
examples. This accepts an object of options so that they can all be optional.node config/assets.mjs
inside Hanami apps. This makes sure t things are nicely typed when passing anesbuildOptionsFn
per the second example above.buildOptions
andwatchOptions
functions that return the combined set of options for the two modes that we use.That really sums it up! If you spend most of your time checking out
index.ts
,args.ts
and skimmingesbuild.ts
, you'll be up to speed with the changes.There are a few other things I took care of while I was here:
config/assets.mjs
script is now the one and only way to use this package.compilerOptions
to use"module": "NodeNext"
. Per their relevant docs:For full context of how this will be used within a full Hanami app, see https://github.com/hanami/cli/pull/109.