mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 22:56:11 +03:00
fix(es): Allow extra comments after sourceMappingURL
(#7262)
This commit is contained in:
parent
5f0660667f
commit
219a738a75
@ -309,7 +309,15 @@ impl Compiler {
|
||||
let read_sourcemap = || -> Result<Option<sourcemap::SourceMap>, Error> {
|
||||
let s = "sourceMappingURL=";
|
||||
let idx = fm.src.rfind(s);
|
||||
let data_url = idx.map(|idx| &fm.src[idx + s.len()..]);
|
||||
|
||||
let data_url = idx.map(|idx| {
|
||||
let data_idx = idx + s.len();
|
||||
if let Some(end) = fm.src[data_idx..].find('\n').map(|i| i + data_idx + 1) {
|
||||
&fm.src[data_idx..end]
|
||||
} else {
|
||||
&fm.src[data_idx..]
|
||||
}
|
||||
});
|
||||
|
||||
match read_inline_sourcemap(data_url) {
|
||||
Ok(r) => Ok(r),
|
||||
|
@ -74,6 +74,11 @@ fn case_inline() {
|
||||
inline("tests/srcmap/case-inline/index.js");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn case_inline_extra_content() {
|
||||
inline("tests/srcmap/case-inline-extra-content/index.js");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_622() {
|
||||
file("tests/srcmap/issue-622/index.js", Default::default()).unwrap();
|
||||
|
3
crates/swc/tests/srcmap/case-inline-extra-content/.swcrc
Normal file
3
crates/swc/tests/srcmap/case-inline-extra-content/.swcrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"inputSourceMap": true,
|
||||
}
|
27
crates/swc/tests/srcmap/case-inline-extra-content/index.js
Normal file
27
crates/swc/tests/srcmap/case-inline-extra-content/index.js
Normal file
@ -0,0 +1,27 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
}());
|
||||
var Bar = /** @class */ (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Bar;
|
||||
}(Foo));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O0FBQUE7SUFBQTtJQUVBLENBQUM7SUFBRCxVQUFDO0FBQUQsQ0FBQyxBQUZELElBRUM7QUFFRDtJQUFrQix1QkFBRztJQUFyQjs7SUFFQSxDQUFDO0lBQUQsVUFBQztBQUFELENBQUMsQUFGRCxDQUFrQixHQUFHLEdBRXBCIn0=
|
||||
// extra content
|
Loading…
Reference in New Issue
Block a user