webpack-bem-loader icon indicating copy to clipboard operation
webpack-bem-loader copied to clipboard

Update inputSourceMap according to loader transformations

Open tsufiev opened this issue 7 years ago • 3 comments

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.

tsufiev avatar Apr 05 '18 09:04 tsufiev

Coverage Status

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

coveralls avatar Apr 05 '18 09:04 coveralls

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.

tsufiev avatar Apr 05 '18 09:04 tsufiev

@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?

awinogradov avatar Apr 06 '18 13:04 awinogradov