bem / webpack-bem-loader

Webpack BEM loader
Other
25 stars 14 forks source link

Update inputSourceMap according to loader transformations #78

Open tsufiev opened 6 years ago

tsufiev commented 6 years ago

Since bem-loader expands certain require()-s in the beginning of the module, all subsequent source maps need to be adjusted by the introduced line offset. Do a correct mapping as well for the transformed require()-s themselves.

Source map adjustments take place when the 'devtool' option passed into webpack toplevel config is not false.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.3%) to 92.593% when pulling 9a9978b6fdd2cfe3e5a449a488a8b7891bf949fe on tsufiev:transform-with-source-maps into d509488d5397d53286dbec68a17f052e28e618b1 on bem:master.

tsufiev commented 6 years ago

This is a tentative fix for the source maps issues introduced by webpack-bem-loader when it is used in chain with babel-loader (babel-loader comes rightmost in the loaders array and is applied first, then comes the webpack-bem-loader). It might be that a case of empty inputSourceMap should be addressed as well, though I'm not sure if anybody uses webpack-bem-loader without babel-loader.

awinogradov commented 6 years ago

@tsufiev thank you so much for this PR! But can you provide some example or test to reproduce the bug and ensure that this PR fixes it?