You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I'd like to shed some light on this issue here, where I seem to be doing a minimal modern web app file and URL structure and using parcel with its defaults (and also not with defaults) and the results seem to be buggy. Let me show you what I mean.
So, I have parcel-bundler v1.6.2.
src/index.html is just
<body><script src="index.js"></script></body>
src/index.js is just:
document.body.innerHTML = '<h1>pass</h1>'
Now I run the command npx parcel build src/index.html and the resulting dist/index.html is:
So, the script element's src attribute's value is wrong. I expect it to be /93a004a8b369dc9199ccd961ac405894.js, instead.
Now, regarding the --public-url option, I'd like to say two things: One is that I consider the above use case the most sane/reasonable use case. So, the for this use case, the defaults should suffice. Second, that I wasn't able to solve this by specifying --public-url. For example, with --public-url /, the script's src attribute is as I would expect it, /93a004a8b369dc9199ccd961ac405894.js. But then, with the serve command something is broken. When I do npx parcel serve --public-url / src/index.html and request http://localhost:1234/, I get a 404. When I request http://localhost:1234/index.html it works.
So, my suggestion is that --public-url will be / by default.
Also, there seems to be a bug when --public-url is /, here: /~https://github.com/parcel-bundler/parcel/blob/v1.6.2/src/Server.js#L46. The following: !req.url.startsWith(bundler.options.publicURL) resolves to false and the default HTML index is not sent. Instead it tries the static files and sends a 404.
In summary, the --public-url / seems like a bug. Yet, please also fix the default. Because I do not see a reason for /dist to be the default or for the default to be whatever the output directory is.
My deployment workflow is that the contents of dist are the deployed files. They are served by a static file server (with support for 200.html) at /. This seems to me like it should be considered the common (and most straightforward) use case and thus the defaults should be based on that. Specifically, --public-url should be / by default (instead of whatever the output directory is).
This is a 🐛 bug report.
So, I'd like to shed some light on this issue here, where I seem to be doing a minimal modern web app file and URL structure and using parcel with its defaults (and also not with defaults) and the results seem to be buggy. Let me show you what I mean.
So, I have parcel-bundler
v1.6.2
.src/index.html
is justsrc/index.js
is just:Now I run the command
npx parcel build src/index.html
and the resultingdist/index.html
is:And the resulting file structure is:
So, the
script
element'ssrc
attribute's value is wrong. I expect it to be/93a004a8b369dc9199ccd961ac405894.js
, instead.Now, regarding the
--public-url
option, I'd like to say two things: One is that I consider the above use case the most sane/reasonable use case. So, the for this use case, the defaults should suffice. Second, that I wasn't able to solve this by specifying--public-url
. For example, with--public-url /
, thescript
'ssrc
attribute is as I would expect it,/93a004a8b369dc9199ccd961ac405894.js
. But then, with theserve
command something is broken. When I donpx parcel serve --public-url / src/index.html
and requesthttp://localhost:1234/
, I get a 404. When I requesthttp://localhost:1234/index.html
it works.So, my suggestion is that
--public-url
will be/
by default.Also, there seems to be a bug when
--public-url
is/
, here: /~https://github.com/parcel-bundler/parcel/blob/v1.6.2/src/Server.js#L46. The following:!req.url.startsWith(bundler.options.publicURL)
resolves tofalse
and the default HTML index is not sent. Instead it tries the static files and sends a 404.In summary, the
--public-url /
seems like a bug. Yet, please also fix the default. Because I do not see a reason for/dist
to be the default or for the default to be whatever the output directory is.My deployment workflow is that the contents of
dist
are the deployed files. They are served by a static file server (with support for 200.html) at/
. This seems to me like it should be considered the common (and most straightforward) use case and thus the defaults should be based on that. Specifically,--public-url
should be/
by default (instead of whatever the output directory is).Here is example code: /~https://github.com/mightyiam/parcel-bug-repro/tree/ac41eafa397f948dbcea35e3600aa43b52b1fdef.
The text was updated successfully, but these errors were encountered: