phoenixframework / esbuild Goto Github PK
View Code? Open in Web Editor NEWAn installer for esbuild
License: MIT License
An installer for esbuild
License: MIT License
The esbuild executable isn't called "esbuild" but rather "esbuild.exe", which was causing exceptions when attempting to run it. I modified install/0 :
case :os.type() do
{:win32, _} ->
File.cp!(Path.join([tmp_dir, "package", "esbuild.exe"]), bin_path)
_ ->
File.cp!(Path.join([tmp_dir, "package", "bin", "esbuild"]), bin_path)
end
This way the correct binary is placed in the _build folder. It seems that modifying bin_path/0 and the mix.exs aliases isn't necessary (to add the .exe suffix) as everything seems to be running fine and changes in the stylesheets are being correctly rebuilt.
Line 310 in ad8255f
I've updated to v0.3 and now downloading seems to hang both in CI and locally:
> mix assets.deploy
> deploy
> NODE_ENV=production tailwindcss --postcss --minify -i css/app.css -o ../priv/static/assets/app.css
warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
Done in 195ms.
20:56:51.524 [debug] Downloading esbuild from https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.12.18.tgz
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
^Cโ
In docker locally:
> docker build .
[+] Building 128.8s (22/29)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.14.0 0.7s
=> [internal] load metadata for docker.io/hexpm/elixir:1.12.2-erlang-24.0.5-alpine-3.14.0 0.7s
=> [internal] load build context 0.1s
=> => transferring context: 279.97kB 0.1s
=> [build 1/18] FROM docker.io/hexpm/elixir:1.12.2-erlang-24.0.5-alpine-3.14.0@sha256:cc9af8777d0b7c02c 0.0s
=> [app 1/6] FROM docker.io/library/alpine:3.14.0@sha256:adab3844f497ab9171f070d4cae4114b5aec565ac772e2f 0.0s
=> => resolve docker.io/library/alpine:3.14.0@sha256:adab3844f497ab9171f070d4cae4114b5aec565ac772e2f2579 0.0s
=> CACHED [build 2/18] RUN apk add --no-cache --update git build-base nodejs npm 0.0s
=> CACHED [build 3/18] RUN mkdir /app 0.0s
=> CACHED [build 4/18] WORKDIR /app 0.0s
=> CACHED [build 5/18] RUN mix local.hex --force && mix local.rebar --force 0.0s
=> CACHED [build 6/18] COPY mix.exs mix.lock ./ 0.0s
=> [build 7/18] COPY config/config.exs config/prod.exs config/ 0.0s
=> [build 8/18] RUN mix deps.get 2.2s
=> [build 9/18] RUN mix deps.compile 69.6s
=> [build 10/18] COPY priv priv 0.0s
=> [build 11/18] COPY lib lib 0.0s
=> [build 12/18] RUN mix sentry_recompile 7.0s
=> [build 13/18] COPY config/runtime.exs config/ 0.0s
=> [build 14/18] COPY assets assets 0.6s
=> [build 15/18] RUN cd assets && npm ci && npm run deploy 4.2s
=> CANCELED [build 16/18] RUN mix esbuild default --minify 44.1s
context canceled
On CI: https://github.com/ruslandoga/test3/runs/3536635132?check_suite_focus=true
With phoenixframework/phoenix#4468 (No secret key base fallback) we will again have the trouble
that running esbuild will fail if used with MIX_ENV=prod and default Phoenix config.
** (RuntimeError) environment variable SECRET_KEY_BASE is missing.
Any ideas how we can get around this?
All I did was bump my version from 0.7.1 -> 0.8.0 and now my docker gets this in my docker build:
[+] Building 179.6s (26/32)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.72kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 1.29kB 0.0s
=> [internal] load metadata for docker.io/library/debian:bullseye-20230612-slim 2.7s
=> [internal] load metadata for docker.io/hexpm/elixir:1.15.0-erlang-26.0.1-debian-bullseye-20230612-slim 2.7s
=> [auth] library/debian:pull token for registry-1.docker.io 0.0s
=> [auth] hexpm/elixir:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.4s
=> => transferring context: 10.29MB 0.4s
=> [builder 1/18] FROM docker.io/hexpm/elixir:1.15.0-erlang-26.0.1-debian-bullseye-20230612-slim@sha256:07ff00556152df811ba6845f1b45a74212cfcce5ef11b23562118152918f43c7 35.1s
=> => resolve docker.io/hexpm/elixir:1.15.0-erlang-26.0.1-debian-bullseye-20230612-slim@sha256:07ff00556152df811ba6845f1b45a74212cfcce5ef11b23562118152918f43c7 0.0s
=> => sha256:92ad4775570054c645678402c8b75eb489b8e05313c9ccd7867bb591266db4d8 30.06MB / 30.06MB 20.2s
=> => sha256:a0d99302275cc3763220005cdf5d58dd533bb1c5a3bf98918d819963dc2b399c 1.31MB / 1.31MB 1.9s
=> => sha256:1649804df033abfe27976b94f1cd64d76c31687781a2fa74e7dd37cad7457535 45.01MB / 45.01MB 33.9s
=> => sha256:07ff00556152df811ba6845f1b45a74212cfcce5ef11b23562118152918f43c7 772B / 772B 0.0s
=> => sha256:e18edcf6040b46444642dc0c653205fe39665510d8b3caa7fed49344e38b030a 1.16kB / 1.16kB 0.0s
=> => sha256:b9c1df386622d9d3d95f60363c43077525a90fa85553e23a370651888b94592b 1.58kB / 1.58kB 0.0s
=> => sha256:e598a9612cadb779d21a377c0d46b62a4ed865626fa17aeda2eaac1465bf85fa 5.35MB / 5.35MB 7.0s
=> => extracting sha256:92ad4775570054c645678402c8b75eb489b8e05313c9ccd7867bb591266db4d8 0.9s
=> => extracting sha256:a0d99302275cc3763220005cdf5d58dd533bb1c5a3bf98918d819963dc2b399c 0.1s
=> => extracting sha256:1649804df033abfe27976b94f1cd64d76c31687781a2fa74e7dd37cad7457535 0.9s
=> => extracting sha256:e598a9612cadb779d21a377c0d46b62a4ed865626fa17aeda2eaac1465bf85fa 0.1s
=> [stage-1 1/7] FROM docker.io/library/debian:bullseye-20230612-slim@sha256:924df86f8aad741a0134b2de7d8e70c5c6863f839caadef62609c1be1340daf5 21.2s
=> => resolve docker.io/library/debian:bullseye-20230612-slim@sha256:924df86f8aad741a0134b2de7d8e70c5c6863f839caadef62609c1be1340daf5 0.0s
=> => sha256:924df86f8aad741a0134b2de7d8e70c5c6863f839caadef62609c1be1340daf5 1.85kB / 1.85kB 0.0s
=> => sha256:d4724cfc4538bc3fa98c398d271c6d8b26f637f34ca4b3d75de0d72d1574d4c2 529B / 529B 0.0s
=> => sha256:c87d48b9fd2b59de1f0c975a9c4a49e4177c9a2d36c1f8fa612f5c86814a82f2 1.48kB / 1.48kB 0.0s
=> => sha256:92ad4775570054c645678402c8b75eb489b8e05313c9ccd7867bb591266db4d8 30.06MB / 30.06MB 20.2s
=> => extracting sha256:92ad4775570054c645678402c8b75eb489b8e05313c9ccd7867bb591266db4d8 0.9s
=> [stage-1 2/7] RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales ffmpeg && apt-get clean && rm -f /var/lib/apt/lists/*_* 39.8s
=> [builder 2/18] RUN apt-get update -y && apt-get install -y build-essential git curl && apt-get clean && rm -f /var/lib/apt/lists/*_* 20.5s
=> [builder 3/18] WORKDIR /app 0.0s
=> [builder 4/18] RUN mix local.hex --force && mix local.rebar --force 2.6s
=> [builder 5/18] COPY mix.exs mix.lock ./ 0.0s
=> [builder 6/18] RUN mix hex.repo add petal https://petal.build/repo --fetch-public-key SHA256:6Ff7LeQCh4464psGV3w4a8WxReEwRl+xWmgtuHdHsjs --auth-key 7PZAF7iuSGrFFgWrpBx_bLv5Q4Tv62acQ3nTnXQSHrYGh0Q2vy 1.2s
=> [builder 7/18] RUN mix deps.get --only prod 7.8s
=> [stage-1 3/7] RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen 1.0s
=> [stage-1 4/7] WORKDIR /app 0.0s
=> [stage-1 5/7] RUN chown nobody /app 0.2s
=> [builder 8/18] RUN mkdir config 0.2s
=> [builder 9/18] COPY config/config.exs config/prod.exs config/ 0.0s
=> [builder 10/18] RUN mix deps.compile 83.7s
=> [builder 11/18] COPY priv priv 0.0s
=> [builder 12/18] COPY lib lib 0.0s
=> [builder 13/18] COPY assets assets 0.0s
=> ERROR [builder 14/18] RUN mix assets.deploy 25.3s
------
> [builder 14/18] RUN mix assets.deploy:
#26 0.705
#26 0.705 22:12:16.833 [debug] Downloading tailwind from https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.1/tailwindcss-linux-arm64
#26 19.90
#26 19.90 Rebuilding...
#26 22.26
#26 22.26 Done in 2441ms.
#26 22.89
#26 22.89 Rebuilding...
#26 25.22
#26 25.22 Done in 2398ms.
#26 25.27 ** (exit) exited in: GenServer.call(Esbuild.Supervisor, {:start_child, %{id: Esbuild.Installer, restart: :transient, start: {Task, :start_link, [#Function<0.45081244/0 in Esbuild.install>]}}}, :infinity)
#26 25.27 ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
#26 25.27 (elixir 1.15.0) lib/gen_server.ex:1063: GenServer.call/3
#26 25.27 (esbuild 0.8.0) lib/esbuild.ex:188: Esbuild.start_unique_install_worker/0
#26 25.27 (esbuild 0.8.0) lib/esbuild.ex:208: Esbuild.install_and_run/2
#26 25.27 (esbuild 0.8.0) lib/mix/tasks/esbuild.ex:55: Mix.Tasks.Esbuild.install_and_run/1
#26 25.27 (mix 1.15.0) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
#26 25.27 (mix 1.15.0) lib/mix/task.ex:506: Mix.Task.run_alias/6
#26 25.27 (mix 1.15.0) lib/mix/cli.ex:92: Mix.CLI.run_task/2
------
executor failed running [/bin/sh -c mix assets.deploy]: exit code: 1
config :esbuild,
version: "0.18.6",
Where does this number come from? The version of esbuild
in hex and in this repository is 0.7x
Hi, can you please add "armv7a" to your list of supported archs. This is the arch I need for my IMX7 arm 32bit board, which happens to be running a musl toolchain
The following patch works for me:
--- lib/esbuild.ex.orig
+++ lib/esbuild.ex
@@ -239,6 +239,7 @@
# TODO: remove when we require OTP 24
"arm" when osname == :darwin -> "darwin-arm64"
"arm" -> "#{osname}-arm"
+ "armv7a" -> "#{osname}-arm"
"armv7l" -> "#{osname}-arm"
_ -> raise "esbuild is not available for architecture: #{arch_str}"
end
Without this I see the error:
** (Mix) Could not start application esbuild: exited in: Esbuild.start(:normal, [])
** (EXIT) an exception was raised:
** (RuntimeError) esbuild is not available for architecture: armv7a-unknown-linux-musleabihf
(esbuild 0.4.0) lib/esbuild.ex:243: Esbuild.target/0
(esbuild 0.4.0) lib/esbuild.ex:128: Esbuild.bin_path/0
(esbuild 0.4.0) lib/esbuild.ex:145: Esbuild.bin_version/0
(esbuild 0.4.0) lib/esbuild.ex:75: Esbuild.start/2
(kernel 8.2) application_master.erl:293: :application_master.start_it_old/4
Big thanks to all the maintainers who pour in countless hours improving the build pipeline for Elixir developers! I cannot say enough how awesome this project is and just how much it's already improved my life โค๏ธ ๐ ๐ ๐ ๐
In a work project recently I ran into a sticky issue w/ 1 package that isn't very browser friendly. I've since learned how others are working around this in webpack 5 and vite but it would appear esbuild might have an escape hatch as well labeled plugins which would allow someone to swap process, zlib, stream and others with this handy esbuild node polyfill. The last step to test this on my local seems to be that the config/config.exs args
don't support plugins
> error: Invalid build flag: "--plugins:./node-plugin.js"
I didn't see an explicit issue for this yet but forgive my duplicate question if this pull request is identical. Again - big thanks, love this project and happy new year ๐
edit: I just saw this in the readme ๐
You can use esbuild plugins (requires npm). See Phoenix' official guide on using them.
The package currently fetches a tarball from npmjs.com without verifying that the package has not been tampered with. Luckily, the npm public registry provides plenty of metadata for packages via its REST API, including a digital signature and a hashsum of the package. It seems like a good idea to make use of this information.
The chapter on Verifying the PGP signature of a package from the npm public registry explains how to go about doing that. Luckily, it doesn't seem to be a lot of effort:
https://registry.npmjs.org/esbuild-darwin-arm64/0.14.0
. The returned document contains (among other things) the effective URL from where to download the package as well as its hash sum, the uncompressed file size and a PGP key to verify the package description.I believe no extra dependency would be needed here (at least I hope that Erlang's :public_key
and :crypto
can be used for everything related to integrity checking), except for a JSON parser.
Does this seem like a worthwhile improvement? If so, I'd be happy to look into implementing this improvement!
Hi ๐,
I'm creating a design system for building Phoenix apps, and I was wondering if it'd be a good idea to extend the functionality of this package to be able to resolve assets that live in Elixir packages, for example in a conventional directory that packages need to comply with.
I could take control of the ESBuild configuration myself and do a custom configuration but I thought it'd be useful to have it as functionality in this package, specially for use cases similar to mine.
As an alternative, I could set up another asset pipeline in my package to flatten and give consumers of the package a single CSS and JS, but the process of serving them as static assets from their project endpoints doesn't seem that straightforward (unless I'm missing something).
Thanks folks! If you think it'd make sense to bring that functionality, I'd be happy to make the code contribution myself.
Not exactly an issue, so apologize for using this as a forum for a question - but I came to the issues section of this repo to find an answer, so perhaps other will as well.
Is it possible to configure :esbuild
such that it will watch assets in multiple phoenix umbrella apps? Right now I'm defining multiple profiles such like:
config :esbuild,
version: "0.12.18",
app_one: [
args:
~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../apps/app_one_web/assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
],
app_two: [
args:
~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../apps/app_two_web/assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
Then I am adding to my Endpoint configurations like:
config :app_one_web, AppOneWeb.Endpoint,
# ...
watchers: [
esbuild: {Esbuild, :install_and_run, [:app_one, ~w(--sourcemap=inline --watch)]}
]
config :app_two_web, AppTwoWeb.Endpoint,
# ...
watchers: [
esbuild: {Esbuild, :install_and_run, [:app_two, ~w(--sourcemap=inline --watch)]}
]
Running mix phx.server
doesn't seem to start these watchers.
It's also worth noting that the Endpoint configs for both of these Phoenix applications have server: false
since I am using :master_proxy
to route requests to the appropriate endpoint in my umbrella application.
Building my phoenix app as docker container fails on 32bit armv7 alpine linux (Raspberry Pi Host).
erlang identifies architecture as armv7
iex(1)> :erlang.system_info(:system_architecture)
'armv7-alpine-linux-musleabihf'
Debian identifies same platform as 'arm-unknown-linux-gnueabihf'
From my point of view, an extra line before
Line 252 in e90b75f
"armv7" -> "#{osname}-arm"
With 0.4.0, we get the following error:
+ mix esbuild default
** (File.Error) could not make directory (with -p) "/.cache/phx-esbuild": no such file or directory
(elixir 1.12.3) lib/file.ex:316: File.mkdir_p!/1
(esbuild 0.4.0) lib/esbuild.ex:200: Esbuild.install/0
(esbuild 0.4.0) lib/esbuild.ex:185: Esbuild.install_and_run/2
(esbuild 0.4.0) lib/mix/tasks/esbuild.ex:49: Mix.Tasks.Esbuild.install_and_run/1
(mix 1.12.3) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.12.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2
The fix is to set XDG_CACHE_HOME
, but it took me a bit of work to figure that out. I found the GH issue where the switch from System.tmp_dir
happened - #33 - and ironically it looks like the change was introduced to avoid a permissions issue.
I think what's going on in my situation is we're running our build on a jenkins server in docker and
a) XDG_CACHE_HOME
is not set in the container by default - this might be pretty common in docker
b) It defaults to /.cache/phx-esbuild
and for some reason (security set up of our docker environment probably?) I can't access that directory properly inside the container.
I don't think this is strictly an issue with this library, but I thought I'd report it in case anyone else experiences the same error and/or someone has an idea how to deal with this more elegantly (a better error message? a different default? just a callout in the docs?).
Thanks!
I was trying to get esbuild installed in our Phoenix project, but ran into the following error:
> mix esbuild.install
19:39:04.401 [debug] Downloading esbuild from https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.10.tgz
19:39:04.570 [info] TLS :client: In state :certify at ssl_handshake.erl:1895 generated CLIENT ALERT: Fatal - Unknown CA
** (RuntimeError) couldn't fetch https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.10.tgz: {:error, {:failed_connect, [{:to_address, {'registry.npmjs.org', 443}}, {:inet, [:inet], {:tls_alert, {:unknown_ca, 'TLS client: In state certify at ssl_handshake.erl:1895 generated CLIENT ALERT: Fatal - Unknown CA\n'}}}]}}
lib/esbuild.ex:282: Esbuild.fetch_body!/1
lib/esbuild.ex:200: Esbuild.install/0
(mix 1.12.1) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.12.1) lib/mix/cli.ex:84: Mix.CLI.run_task/2
Our company uses a MitM firewall application (yay ๐ ), so we need to specify our own certificate bundle when making outbound requests. I was able to work around this by adding my own :cacertfile
config parameter (and setting it appropriately):
config :esbuild,
version: "0.13.10",
default: [
args: ~w(js/phoenix.js),
cd: Path.expand("../assets", __DIR__)
],
ssl: [cacertfile: "/etc/ssl/certs/ca-bundle.crt"]
And then edited lib/esbuild.ex
with the following in place of esbuild.ex:#L266-L275:
default_ssl_options = [
verify: :verify_peer,
cacertfile: cacertfile,
depth: 2,
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
]
]
ssl_options = Keyword.merge(default_ssl_options, Application.get_env(:esbuild, :ssl, []))
http_options = [ssl: ssl_options]
Is this configuration something that could be included in the project? I'd be happy to submit this as a PR and address review comments.
Let me know if you need any more details.
Versions:
nodejs: 16.13
phoenix: 1.6.0
elixir: 1.12.3
esbuild: 0.3.4
docker: 20.10.6
We're using the elixir:1.12.3-alpine docker image to assemble our release. Up until recently this worked fine but now we're getting the following mysterious error code when running
> mix assets.deploy
** (Mix) `mix esbuild default --minify` exited with 8
On our dev machines, this works fine with the same phoenix, elixir, esbuild and nodejs versions and we haven't changed the contents of the docker image. The only possible difference that is left after our long debugging session is that the docker image which works, was built and cached by an earlier docker version. But without knowing what exited with 8
means, we're stuck at this point.
Our docker file looks as follows:
FROM elixir:1.12.3-alpine
LABEL maintainer "hukl"
ENV PHOENIX_VERSION=1.6.0
ENV POSTGRES_HOST=host.docker.internal
ENV MIX_ENV=container
RUN apk add git bash curl wget make gcc alpine-sdk graphicsmagick
RUN apk add nodejs npm --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
RUN mix local.hex --force && \
mix local.rebar --force
WORKDIR /app
COPY . .
RUN mix deps.get
RUN mix deps.compile
RUN mix compile
RUN npm install --prefix ./assets
RUN mix assets.deploy # this is where the error happens and which works locally
โฆ
Any clues would be appreciated!
I have problems running a phoenix liveview demo behind a proxy server which needs username and Password for Auth.
I export the proxy server env
export https_proxy=http://{USER}:{PASSW}@{PROXYSERVER}:{PORT}
Then I get:
~/phoenixHi/my_app$ mix phx.server
warning: the :gettext compiler is no longer required in your mix.exs.
Please find the following line in your mix.exs and remove the :gettext entry:
compilers: [..., :gettext, ...] ++ Mix.compilers(),
(gettext 0.20.0) lib/mix/tasks/compile.gettext.ex:5: Mix.Tasks.Compile.Gettext.run/1
(mix 1.13.4) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.13.4) lib/mix/tasks/compile.all.ex:92: Mix.Tasks.Compile.All.run_compiler/2
(mix 1.13.4) lib/mix/tasks/compile.all.ex:72: Mix.Tasks.Compile.All.compile/4
(mix 1.13.4) lib/mix/tasks/compile.all.ex:59: Mix.Tasks.Compile.All.with_logger_app/2
(mix 1.13.4) lib/mix/tasks/compile.all.ex:36: Mix.Tasks.Compile.All.run/1
[info] Running MyAppWeb.Endpoint with cowboy 2.9.0 at 127.0.0.1:4000 (http)
[debug] Downloading esbuild from https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.29.tgz
[debug] Using HTTPS_PROXY: http://<USER>:<PASSWORD>@<PROXYSERVER>:8080
[info] Access MyAppWeb.Endpoint at http://localhost:4000
[error] Task #PID<0.542.0> started from MyAppWeb.Endpoint terminating
** (RuntimeError) couldn't fetch https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.29.tgz: {:error, {:could_not_establish_ssl_tunnel, {'HTTP/1.1', 407, 'Proxy Authentication Required'}}}
(esbuild 0.5.0) lib/esbuild.ex:302: Esbuild.fetch_body!/1
(esbuild 0.5.0) lib/esbuild.ex:209: Esbuild.install/0
(esbuild 0.5.0) lib/esbuild.ex:189: Esbuild.install_and_run/2
(phoenix 1.6.11) lib/phoenix/endpoint/watcher.ex:19: Phoenix.Endpoint.Watcher.watch/2
(elixir 1.13.4) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/2
Args: ["esbuild", {Esbuild, :install_and_run, [:default, ["--sourcemap=inline", "--watch"]]}]
The out log HTTPS_PROXY Value is right (but also with user and password included).
I discussed this on the libera IRC channel ... but find no solution. They pointed me here to create an issue.
By the way: Downloading the requested file/package with curl / wget works fine.
๐ Hello
Esbuild 0.16 changed the locations from
esbuild-TARGET
https://registry.npmjs.org/esbuild-linux-64@esbuild/TARGET
https://registry.npmjs.org/@esbuild/linux-x64Relevant code:
Lines 207 to 208 in ac400e7
Is it okay to raise a PR to permanently change this location and bump the @latest_version
to 0.16.3?
The JS pipeline is only one part of the whole asset management. How will this pattern fit in with the other parts of static asset management?
For example, this is currently how I've been integrating Esbuild + Postcss
watchers: [
"#{esbuild}": [
"./js/app.js",
"--target=es2020",
"--bundle",
"--outdir=../priv/static/js",
"--color=true",
"--log-level=debug",
"--sourcemap",
"--watch",
cd: Path.expand("../assets", __DIR__)
],
"#{postcss}": [
"./css/app.css",
"--dir",
"../priv/static/css",
"--verbose",
"-w",
"-m",
cd: Path.expand("../assets", __DIR__),
env: [{"NODE_ENV", "development"}, {"TAILWIND_MODE", "watch"}]
],
"#{cpx}": [
"./static/**/*",
"../priv/static",
"-v",
"--watch",
cd: Path.expand("../assets", __DIR__)
]
]
The only real issue I've run into are zombie processes left by cpx. This has been called out before and I believe there is even a PR to fix it.
Back to my question, how should postcss and other asset management needs integrate following this pattern?
It looks like there is support for 64bit arm (arch aarch64) but not 32bit arm (arm, arm7, etc) I think it would be as simple as adding a clause for "arm".
I tried this out and it appears to work: https://github.com/phoenixframework/esbuild/compare/main...hez:feature/linux-arm?expand=1#diff-817be7445555ff97e4b7a5c8139e8e7e953cd62b9175b157793e979ad85dd79dR193
Hello, I'm trying to run the following:
mix esbuild --no-runtime-config default --minify --define:process.env.NODE_ENV='production' error.js
and getting the following error:
> error: Missing "=": "process.env.NODE_ENV"
1 error
** (Mix) `mix esbuild default --minify --define:process.env.NODE_ENV 'production' error.js` exited with 1
It works fine if I skipe the --define option, i.e mix esbuild --no-runtime-config default --minify error.js
. Also, calling esbuild directly with the --define works:
esbuild assets\error.js --define:process.env.NODE_ENV='development' --bundle --minify
Is it possible to pass the NODE_ENV somehow ?
If not how can I differentiate between prod and dev (or other environments I may compile my assets on) ?
TIA !
Steps to reproduce
mix esbuild default
Expected
Command fails with ** (ArgumentError) unknown esbuild profile. Make sure the profile is defined in your config/config.exs file, such as:...
Actual
Command never returns
This is only reproducible with the default
profile. When using other profile names, the error message appears correctly.
This is a heads up that I'm planning on changing esbuild's package names in an upcoming release. The packages are being moved under the @esbuild/
scope to avoid name collisions. I'm also changing the os
and cpu
strings to be exactly equal to the ones returned by node (previously a few of them weren't consistent). You can find the work-in-progress change that does this here: evanw/esbuild#2508.
More context: I've had a problem with people trying to add support for a new platform to esbuild and then registering the package name themselves, which doesn't work because then I don't control the package name. Using a scope prevents this problem.
In an environment where registry.npm.org is not available, e.g. behind a corporate firewall where registry.npm.org is replaced by another npm registry, install/0 fails with:
[error] Task #PID<0.459.0> started from LiveviewDemoWeb.Endpoint terminating
** (RuntimeError) couldn't fetch https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.12.18.tgz: {:error, {:failed_connect, [{:to_address, {'registry.npmjs.org', 443}}, {:inet, [:inet], :nxdomain}]}}
(esbuild 0.3.1) lib/esbuild.ex:226: Esbuild.fetch_body!/1
(esbuild 0.3.1) lib/esbuild.ex:157: Esbuild.install/0
(esbuild 0.3.1) lib/esbuild.ex:140: Esbuild.install_and_run/2
(phoenix 1.6.0) lib/phoenix/endpoint/watcher.ex:19: Phoenix.Endpoint.Watcher.watch/2
(elixir 1.12.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/2
Args: ["esbuild", {Esbuild, :install_and_run, [:default, ["--sourcemap=inline", "--watch"]]}]
to prevent this, the host part of the url variable here
Line 157 in d4cf71f
Or should I add a --update-only
flag?
What do you thing?
Given the following config.exs
:
config :project, ProjectWeb.Endpoint,
http: [ip: {0, 0, 0, 0}, port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
check_origin: false,
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
another: {Esbuild, :install_and_run, [:another, ~w(--sourcemap=inline --watch)]}
]
When the application is started with iex -S mix phx.server
,
the watchers are started concurrently and they try to download and install esbuild at the same time.
My educated guess is that one of them succeeds, but the other one encounters the installed binary and raises this error:
[error] Task #PID<0.1147.0> started from ProjectWeb.Endpoint terminating
** (File.CopyError) could not copy from "/home/work/.cache/phx-esbuild/package/bin/esbuild" to "/home/work/src/project/_build/esbuild-linux-x64": text file or pseudo-device busy
(elixir 1.14.2) lib/file.ex:838: File.cp!/3
(esbuild 0.7.0) lib/esbuild.ex:192: Esbuild.install_and_run/2
(phoenix 1.6.15) lib/phoenix/endpoint/watcher.ex:19: Phoenix.Endpoint.Watcher.watch/2
(elixir 1.14.2) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(stdlib 3.17.2.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/2
Args: ["another", {Esbuild, :install_and_run, [:another, ["--sourcemap=inline", "--watch"]]}]
The two esbuild profiles exist because they are separate and produce different outputs and therefore cannot be handled by one esbuild invocation.
When setting up/installing a phoenix application on a multi-user system, the path of the /tmp location for esbuild should not cause permission issues if the directory already exists from another user account. This could possibly be addressed by using a user specifc named directory or prefix inside /tmp for the phx-esbuild directory.
Although this isn't a common scenario I'm guessing (shared computers or computer lab environments would be affected), when one user on a system is developing phoenix apps, esbuild package gets downloaded to /tmp/phx-esbuild and is set for that user's user/group ownership. If another user then logs into the same system and attempts to start or run a phoenix application, the application fails to start because that /tmp/phx-esbuild directory is owned by the other user:
[error] Task #PID<0.534.0> started from MyAppWeb.Endpoint terminating
** (File.Error) could not remove files and directories recursively from "/tmp/phx-esbuild": permission denied
Thanks for the awesome work on this library!
I wanted to propose that a flag be added to allow mix esbuild
to run without loading the application configuration.
In particular, I'm trying to build my static assets inside of a container in a continuous deployment pipeline. My config/runtime.exs
file throws an exception if any of a number of environment variables aren't set, and typically none of those variables are set during the build process.
I'm currently working around this by calling mix esbuild
before copying the runtime configuration file into the container, but it would be nice if I could specify all configuration via arguments to the mix task and specify that the configuration shouldn't be used just when running in my build pipeline.
It looks like this PR changed the path from which esbuild
is fetched from the npm registry, which has broken my ability to install it via mix esbuild.install
.
The path it attempts to reach is https://registry.npmjs.org/@esbuild/linux-x64/0.19.8
But the path it should be fetching from is e.g. https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.8.tgz
(You can see this path in the registry.npmjs.org JSON under versions > [num] > dist > tarball.)
Is this is in anticipation of build file changes that haven't been released yet?
This will avoid depending on the npm registry to fetch the binaries on demand
I have css that I want added separately from tailwind, and esbuild pulls it into priv/static/assets the way I need.
I then have the tailwind standalone separately manage tailwind in a separate tailwind.css file, and the html simply links to both.
For some reason though, esbuild seems to be automatically deleting the line import "../css/app.css"
from app.js in my assets folder? Is this something that's part of this package, esbuild itself, or is something weird going on?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.