webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

fix: fix #111 by generating sourcemaps even when a previous loader didn't pass them #113

Closed benjamin-hodgson closed 2 years ago

benjamin-hodgson commented 2 years ago

This PR contains a:

Motivation / Use-Case

See isse #111. imports-loader was only generating sourcemaps when a previous loader in the chain had already provided one. Webpack itself still generates a sourcemap in these conditions, but it was incorrect due to the missing mappings for the code injected by imports-loader.

There is probably some room for improvement here, would be good to map an artificial source file for the code which was injected by imports-loader.

The existing tests were not very good - they checked that the compilation had run and produced an output JS file, but didn't even check that sourcemaps had been generated, let alone that the sourcemap was correct.

codecov[bot] commented 2 years ago

Codecov Report

Merging #113 (b6c480a) into master (4cbba7a) will increase coverage by 0.21%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   91.81%   92.03%   +0.21%     
==========================================
  Files           3        3              
  Lines         220      226       +6     
  Branches       85       86       +1     
==========================================
+ Hits          202      208       +6     
  Misses         12       12              
  Partials        6        6              
Impacted Files Coverage Δ
src/index.js 100.00% <100.00%> (ø)

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 4cbba7a...b6c480a. Read the comment docs.

benjamin-hodgson commented 2 years ago

Thank you!