diff --git a/package.json b/package.json index 3b65cc8..ffb5d48 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,14 @@ ], "dependencies": { "convert-source-map": "^1.1.3", - "offset-sourcemap-lines": "^0.1.0", + "offset-sourcemap-lines": "^0.1.1", "oss-license-name-to-url": "^1.2.1", "through2": "^2.0.0", "type-name": "^2.0.0" }, "devDependencies": { + "babel-plugin-transform-es2015-classes": "^6.8.0", + "babelify": "^7.3.0", "browserify": "^13.0.0", "event-stream": "^3.3.1", "intelli-espower-loader": "^1.0.0", diff --git a/test/test-babel-class/index.js b/test/test-babel-class/index.js new file mode 100644 index 0000000..d670a75 --- /dev/null +++ b/test/test-babel-class/index.js @@ -0,0 +1,8 @@ +class Entry { + constructor(name) { + this.name = name; + } + toString() { + return this.name; + } +} diff --git a/test/test-babel-class/package.json b/test/test-babel-class/package.json new file mode 100644 index 0000000..b1fe8da --- /dev/null +++ b/test/test-babel-class/package.json @@ -0,0 +1,6 @@ +{ + "name": "test-babel-class", + "description": "", + "version": "0.1.0", + "license": "MIT" +} diff --git a/test/test.js b/test/test.js index 07b0061..c766288 100644 --- a/test/test.js +++ b/test/test.js @@ -380,3 +380,33 @@ describe('multiple common licenses', function () { }); }); }); + + +describe('repro case for #17 : sourcemap generated by babel class', function () { + var expectedModules = [ + 'test-babel-class' + ]; + describe('sourcemap should be generated', function () { + var header; + before(function (done) { + var save = saveFirstChunk(); + var entryPath = path.normalize(path.join(__dirname, 'test-babel-class', 'index.js')); + var b = browserify(entryPath, { debug: true }); + b.transform('babelify', { + plugins: ['transform-es2015-classes'] + }); + b.plugin(licensify); + b.bundle().pipe(save).pipe(es.wait(function(err, data) { + assert(!err); + header = save.firstChunk; + done(); + })); + }); + expectedModules.forEach(function (moduleName) { + var re = new RegExp(' \* ' + moduleName + '\:$', 'gm'); + it('ensure header includes [' + moduleName + ']', function () { + assert(re.test(header)); + }); + }); + }); +});