webpack-contrib / worker-loader

A webpack loader that registers a script as a Web Worker
MIT License
1.46k stars 273 forks source link

TypeScript: loading worker module more simply #317

Closed visvirial closed 3 years ago

visvirial commented 3 years ago

I found a simpler notation for TypeScript.

In this modification, the worker-module! prefix passed to import statement is not required anymore.


This PR contains a:

Motivation / Use-Case

The worker-module! prefix originates from WebPack and which causes a compile error on non-WebPack systems. This makes hard to test the code directly using testing frameworks such as Jest.

(Note: most testing frameworks only work with Node.js and do not support WebWorker. You should polyfill it using some utilities such as https://github.com/astagi/workerloader-jest-transformer.)

Breaking Changes

TypeScript notation simplified.

Additional Info

cf: https://github.com/EllipticPIR/libepir/commit/f328396d85c5421f52ee623fb64a679e3687e457

visvirial commented 3 years ago

Thank you for your review. I revived the old code example.

codecov[bot] commented 3 years ago

Codecov Report

Merging #317 (a357c5f) into master (22275e9) will decrease coverage by 21.47%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #317       +/-   ##
===========================================
- Coverage   75.83%   54.36%   -21.48%     
===========================================
  Files           6        6               
  Lines         149      149               
  Branches       52       52               
===========================================
- Hits          113       81       -32     
- Misses         30       53       +23     
- Partials        6       15        +9     
Impacted Files Coverage Δ
src/supportWebpack5.js 0.00% <0.00%> (-83.34%) :arrow_down:
src/index.js 82.50% <0.00%> (-12.50%) :arrow_down:
src/utils.js 81.57% <0.00%> (-5.27%) :arrow_down:

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 22275e9...a357c5f. Read the comment docs.