import.meta.url and Webpack 5: avoiding absolute paths #299
PhilippWendler
started this conversation in
General
Replies: 2 comments 9 replies
This comment has been hidden.
This comment has been hidden.
-
It's fixed in the version 2.4.0. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using this great library for some time and recently have started using Webpack 5 (via create-react-app). I am interested only in unzipping and I do not want web workers, so I use the following in my code:
Everything works fine.
However: When I bundle my application with Webpack, Webpack inserts the absolute path to
codec-pool-worker.js
into the generated code, because that file usesimport.meta.url
:zip.js/lib/core/codecs/codec-pool-worker.js
Line 112 in f83228c
This is highly undesired for me, because it leaks my user name and directory names and it leads to the build being different depending on where I build it, for example on my machine vs. in CI (everything else in the build is deterministic and reproducible). From what I understand from the Webpack issue tracker this is by design and not changeable.
I can work around this if I copy
codec-pool-worker.js
to my app, deletecreateWebWorkerInterface
and tell Webpack to use my copy of the file instead of the original one. However, this is fragile and I of course would prefer to avoid this.Given that the code in
createWebWorkerInterface
should not be used anyway when using any oflib/zip-no-worker*
AFAIU, I wondered whether there is a possibility for the library to be restructured in a way such thatcreateWebWorkerInterface
can be removed by tree shaking whenlib/zip-no-worker*
is imported? This would also reduce the bundle size by a few bytes, of course. This is why I am raising this here.Alternatively, if
createWebWorkerInterface
would be in a separate file this would be easy for me, though I could understand if you don't want to make such adjustments for purely external reasons.Or does anybody have an idea what else I could do to avoid ending up with the absolute path in my bundle, without having to copy and change the code? I am not really an expert in this.
Beta Was this translation helpful? Give feedback.
All reactions