Skip to content

Commit 0f89936

Browse files
committed
feat: plugin option noSourceMap for N4JS source-map reference
1 parent 814106c commit 0f89936

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ $ babel --plugins transform-n4js-systemjs-commonjs ...
2626
Plugin Options:
2727
- `verbose: [string]` switches on verbose logging of the used module IDs
2828
- `stripPackageID_re: [string|Regexp]` regex to rewrite/strip parts of the package ID by convention
29+
- `noSourceMap: [boolean]` whether the N4JS source-map reference should be dropped; defaults to `true`
2930

3031
## License
3132

index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ module.exports = ({types: t}) => {
9191
let program = path.node,
9292
opts = state.opts || {},
9393
verbose = opts.verbose,
94-
stripPackageID_re = opts.stripPackageID_re;
94+
stripPackageID_re = opts.stripPackageID_re,
95+
noSourceMap = opts.noSourceMap;
9596

97+
if (typeof noSourceMap === "undefined") {
98+
noSourceMap = true;
99+
}
96100
if (stripPackageID_re && !(stripPackageID_re instanceof RegExp)) {
97101
stripPackageID_re = new RegExp(stripPackageID_re);
98102
}
@@ -124,12 +128,14 @@ module.exports = ({types: t}) => {
124128
sysRegExpr.arguments.push(t.stringLiteral(getModuleIdOf(filename, verbose)));
125129
}
126130

127-
let comments = path.container.comments;
128-
comments.forEach(c => {
129-
if (c.value.startsWith("# sourceMappingURL=")) {
130-
c.value = `--${c.value}--`;
131-
}
132-
});
131+
if (noSourceMap) {
132+
let comments = path.container.comments;
133+
comments.forEach(c => {
134+
if (c.value.startsWith("# sourceMappingURL=")) {
135+
c.value = `--${c.value}--`;
136+
}
137+
});
138+
}
133139

134140
// replace all System._nodeRequire calls
135141
path.traverse(_nodeRequireVisitor);

0 commit comments

Comments
 (0)