Fix esbuild vendor bundle error by marking chart.js as external

The Docker build was failing because the Chart.js date adapter was trying
to require("chart.js") but esbuild couldn't resolve it since Chart.js is
loaded as a UMD file, not a CommonJS module.

Added --external:chart.js to the vendor esbuild configuration to tell
esbuild not to try bundling chart.js when it encounters require("chart.js")
in the date adapter. This is correct because Chart.js is already loaded
globally from the UMD file.

This fixes the "Could not resolve 'chart.js'" error during production builds.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2025-07-21 10:11:26 -05:00
parent 74767345fd
commit c932abb434
No known key found for this signature in database

View file

@ -87,7 +87,7 @@ config :esbuild,
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
],
vendor: [
args: ~w(js/vendor.js --bundle --target=es2017 --outdir=../priv/static/assets --minify),
args: ~w(js/vendor.js --bundle --target=es2017 --outdir=../priv/static/assets --external:chart.js --minify),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]