webpack / webpack-sources

Source code handling classes for webpack
MIT License
262 stars 71 forks source link

`RawSource.node` fails if `source` is a `Buffer` #26

Closed EECOLOR closed 4 years ago

EECOLOR commented 7 years ago

Which can easily happen in webpack, file-loader for example emits files as buffer instances.

alexander-akait commented 6 years ago

@EECOLOR problem still exists?

EECOLOR commented 6 years ago

Yes:

https://github.com/webpack/webpack-sources/blob/master/lib/RawSource.js#L26 https://github.com/mozilla/source-map/blob/0.6.1/lib/source-node.js#L43 https://github.com/mozilla/source-map/blob/0.6.1/lib/source-node.js#L184

EECOLOR commented 6 years ago

Example:

https://github.com/webpack-contrib/file-loader/blob/master/src/index.js#L85 https://github.com/webpack-contrib/file-loader/blob/master/src/index.js#L79 https://github.com/webpack/webpack/blob/master/lib/NormalModule.js#L191 https://github.com/webpack/webpack/blob/master/lib/NormalModule.js#L138

alexander-akait commented 6 years ago

@EECOLOR can you create minimum reproducible test repo?

EECOLOR commented 6 years ago

@evilebottnawi Just create a RawSource with a buffer as value and call node on it

alexander-akait commented 4 years ago

@EECOLOR sorry for big delay, I think it is expected, you need to use RawSource(Buffer.from('test'), true)

EECOLOR commented 4 years ago

@evilebottnawi The issue seems to have been fixed 11 months ago: https://github.com/webpack/webpack-sources/commit/4e1ea6d9be702d822078b0494b192ad06ecfbd11#diff-80d25e3b0eed8830fe06f2bad53a54b6R46