Browse Source

Merge pull request #382 from rollup/handle-stringified-sourcemaps

Handle stringified sourcemaps
gh-384
Rich Harris 9 years ago
parent
commit
63b518c043
  1. 4
      src/utils/transform.js
  2. 22
      test/function/handles-stringified-sourcemaps/_config.js
  3. 1
      test/function/handles-stringified-sourcemaps/main.js

4
src/utils/transform.js

@ -25,6 +25,10 @@ export default function transform ( source, id, transformers ) {
map: null
};
}
// `result.map` can only be a string if `result` isn't
else if ( typeof result.map === 'string' ) {
result.map = JSON.parse( result.map );
}
sourceMapChain.push( result.map );
ast = result.ast;

22
test/function/handles-stringified-sourcemaps/_config.js

@ -0,0 +1,22 @@
module.exports = {
description: 'handles transforms that return stringified source maps (#377)',
options: {
plugins: [
{
transform: function ( code ) {
return {
code: code,
// just stringify an otherwise acceptable source map
map: JSON.stringify({ mappings: '' })
};
}
}
]
},
// ensure source maps are generated
bundleOptions: {
sourceMap: true
}
};

1
test/function/handles-stringified-sourcemaps/main.js

@ -0,0 +1 @@
export default 42;
Loading…
Cancel
Save