Skip to content

Commit

Permalink
fix(bundler): avoid appending alias after comment (sourceMap line).
Browse files Browse the repository at this point in the history
This fixes tracing npm package "noty".
  • Loading branch information
3cp committed Apr 6, 2019
1 parent 24e2d88 commit 621bda7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/build/amodro-trace/write/defines.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function defines(options) {
if (packageName && namedModule && namedModule !== packageName) {
// for main module, if named module name doesn't match package name
// make an alias from moduleName (not packageName) to namedModule
contents += 'define("' + moduleName + '", ["' + namedModule + '"], function(m){return m;});\n';
contents += '\n;define("' + moduleName + '", ["' + namedModule + '"], function(m){return m;});\n';
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/build/bundled-source.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export {t};
it('transforms npm package js file with named AMD module', () => {
let file = {
path: path.resolve(cwd, 'node_modules/foo/index.js'),
contents: "define('M', ['a', 'b'], function(){});\n"
contents: "define('M', ['a', 'b'], function(){});"
};

let bs = new BundledSource(bundler, file);
Expand All @@ -321,8 +321,8 @@ export {t};
let deps = bs.transform();
expect(deps).toEqual(['a', 'b']);
expect(bs.requiresTransform).toBe(false);
expect(bs.contents.replace(/\r|\n/g, ''))
.toBe("define('M', ['a', 'b'], function(){});define(\"foo/index\", [\"M\"], function(m){return m;});");
expect(bs.contents)
.toBe("define('M', ['a', 'b'], function(){});\n;define(\"foo/index\", [\"M\"], function(m){return m;});\n");
});

it('transforms npm package js file with more than one named AMD module', () => {
Expand Down Expand Up @@ -355,8 +355,8 @@ export {t};
expect(deps).toEqual(['a', 'b', 'c']);
expect(bs.requiresTransform).toBe(false);
// the alias targets first named module 'M'
expect(bs.contents.replace(/\r|\n/g, ''))
.toBe("define('M', ['a', 'b'], function(){});define('N', ['c'], function(){});define(\"foo/index\", [\"M\"], function(m){return m;});");
expect(bs.contents)
.toBe("define('M', ['a', 'b'], function(){});define('N', ['c'], function(){});\n\n;define(\"foo/index\", [\"M\"], function(m){return m;});\n");
});

it('transforms npm package js file by force cjs wrapper', () => {
Expand Down

0 comments on commit 621bda7

Please sign in to comment.