New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alpine.js doesn't work with Phoenix 1.6.2 because of too low esbuild target #4579
Comments
I faced the same issue today, you are a lifesaver. Thank you so much. P.S. I wish Petal stack was a standard and would work out of the box, without so many setups. |
still doesn't work even after bump <div x-data="{msg: 'Alpine works!'}">
<span x-text="msg">Alpine does not work</span>
</div> |
It took me a couple of hours to track down the root cause of the following AlpineJS v3.5.0 error:
The default esbuild configuration created by Phoenix 1.6.2 in config :esbuild,
version: "0.12.18",
default: [
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
] This doesn't work with Alpine v3 as it requires support for async/await which is in ECMAScript 2017 (see #2318). Changing the target to config :esbuild,
version: "0.12.18",
default: [
args: ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
] |
@slashdotdash, just curious - why |
To allow support for slightly older browsers. |
Thank you so much. A whole morning.... |
Environment
Expected behavior
Alpine functioning properly
Actual behavior
After spending a day with this issue I finally figured out why it didn't work. Alpine.js doesn't work because of the low target version for esbuild (--target=es2016) in config.exs. Bumping the target to es2018 makes everything work like a charm :)
The text was updated successfully, but these errors were encountered: