Skip to content

Commit

Permalink
chore: update rollup with new sourcemap option
Browse files Browse the repository at this point in the history
Since rollup 0.48.0, the source map options has been renamed
from `sourceMap` to `sourcemap`. This commit add the compatibility
with rollup by detecting one of these two options.
  • Loading branch information
mjeanroy committed Aug 21, 2017
1 parent 7a7c234 commit 5ef69b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ module.exports = (options = {}) => {
* @return {void}
*/
options(opts) {
if (opts && opts.sourceMap) {
if (!opts) {
return;
}

// Rollup >= 0.48 replace `sourceMap` with `sourcemap`.
if (opts.sourceMap || opts.sourcemap) {
plugin.enableSourceMap();
}
},
Expand Down
12 changes: 12 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ describe('rollup-plugin-license', () => {
expect(LicensePlugin.prototype.enableSourceMap).toHaveBeenCalledWith();
});

it('should enable sourceMap if options.sourcemap (lowercase) is true', () => {
spyOn(LicensePlugin.prototype, 'enableSourceMap').and.callThrough();

const instance = plugin();
const result = instance.options({
sourcemap: true,
});

expect(result).not.toBeDefined();
expect(LicensePlugin.prototype.enableSourceMap).toHaveBeenCalledWith();
});

it('should not enable sourceMap if options.sourceMap is false', () => {
spyOn(LicensePlugin.prototype, 'enableSourceMap').and.callThrough();

Expand Down

0 comments on commit 5ef69b5

Please sign in to comment.