Open pckhoi opened 4 years ago
Merging #291 (3fcc7a2) into master (2448e13) will decrease coverage by
6.17%
. The diff coverage is30.43%
.
@@ Coverage Diff @@
## master #291 +/- ##
==========================================
- Coverage 76.35% 70.17% -6.18%
==========================================
Files 6 7 +1
Lines 148 171 +23
Branches 52 62 +10
==========================================
+ Hits 113 120 +7
- Misses 30 44 +14
- Partials 5 7 +2
Impacted Files | Coverage Δ | |
---|---|---|
src/runtime/crossOrigin.js | 0.00% <0.00%> (ø) |
|
src/index.js | 95.34% <100.00%> (+0.11%) |
:arrow_up: |
src/utils.js | 88.37% <100.00%> (+1.88%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 2448e13...3fcc7a2. Read the comment docs.
@evilebottnawi how is my solution? If you think it is good then I'll try to improve code coverage.
Hello. Any plans on going forward with this one? 💔
Could use my fork for now?
@pckhoi I don't seem to be able to use a relative path here.
options: {
crossOrigin: '/static-proxy/'
}
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL '/static-proxy/worker.aeb45db0.worker.js' is invalid.
Assuming my page is http://reddit.com
, I would like to add /static-proxy/
as my originPath
.
This would result in using http://reddit.com/static-proxy/${fileName}
as the path to the worker.
Can this be achieved? Unfortunately, the URL of my page is dynamic, and therefore the originPath
has to be relative.
@mwanago Yep, we need thinking more about this and solve this in more general way
@evilebottnawi Maybe allowing a function to be used as the crossOrigin
(or another name we come up with) would help.
I could use ${window.location.origin}/static-proxy
as the return of the function.
Instead of
options: {
crossOrigin: '/static-proxy/'
}
do
options: {
crossOrigin: () => (
`${window.location.origin}/static-proxy/`
)
}
We should use currentScript
here, webpack supports publicPath: 'auto'
...
@evilebottnawi My public path is set to something else and I need it to stay this way. I need to override it only for the worker path.
@mwanago Just for information, can you provide real use case?
@mwanago this PR is meant to solve cross origin use cases. I think you might be able to do what you want with existing options already. What have you tried so far? Would changing __webpack_public_path__
before importing worker script not work?
Also just noticed we also have a publicPath
option. This is confusing. Does it only override Webpack's publicPath
?
@pckhoi This is precisely due to me wanting to solve my cross-origin issue.
@evilebottnawi I've created a small proxy on my Node.js backend that is in the same origin and under the hood loads content from the CDN. Now I want to use this proxy to load my worker.
@pckhoi
Changing the __webpack_public_path__
before importing the worker script didn't work well for me because I wasn't able to change it back to the previous value.
Trying to change it back caused it to work like I never changed __webpack_public_path__
before importing.
sounds resonable, I will thinking about this deeply in near future, right now I am focused on webpack-dev-server
updating, so ping me at this Friday and we try to solve this
ping me at this Friday and we try to solve this
@alexander-akait I am pinging you 👀
ping me at this Friday and we try to solve this
@alexander-akait Is there any hope for tackling this issue?
Sorry for delay, deadline + a lot of issues, I remember about this, try to return to this in near future, sorry again
Sorry for delay, deadline + a lot of issues, I remember about this, try to return to this in near future, sorry again
Is there any way I can help you with that?
As minimum we need better name for this option
@alexander-akait
I think workerChunkUrl
sounds fine, as long as we allow it to be a relative path.
This PR contains a:
Motivation / Use-Case
Solving https://github.com/webpack-contrib/worker-loader/issues/281 according to this comment
Breaking Changes
No breaking changes.
Additional Info