mirror of https://github.com/status-im/metro.git
[react-packager] kill non-standard RAW_SOURCE_MAP
This commit is contained in:
parent
bef3d46cee
commit
ec1b9ec735
|
@ -68,10 +68,9 @@ Package.prototype._getSource = function() {
|
||||||
Package.prototype._getInlineSourceMap = function() {
|
Package.prototype._getInlineSourceMap = function() {
|
||||||
if (this._inlineSourceMap == null) {
|
if (this._inlineSourceMap == null) {
|
||||||
var sourceMap = this.getSourceMap({excludeSource: true});
|
var sourceMap = this.getSourceMap({excludeSource: true});
|
||||||
this._inlineSourceMap = '\nRAW_SOURCE_MAP = ' +
|
var encoded = new Buffer(JSON.stringify(sourceMap)).toString('base64');
|
||||||
JSON.stringify(sourceMap) + ';';
|
this._inlineSourceMap = 'data:application/json;base64,' + encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._inlineSourceMap;
|
return this._inlineSourceMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,13 +84,14 @@ Package.prototype.getSource = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var source = this._getSource();
|
var source = this._getSource();
|
||||||
|
source += '\n\/\/@ sourceMappingURL=';
|
||||||
|
|
||||||
if (options.inlineSourceMap) {
|
if (options.inlineSourceMap) {
|
||||||
source += this._getInlineSourceMap();
|
source += this._getInlineSourceMap();
|
||||||
|
} else {
|
||||||
|
source += this._sourceMapUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
source += '\n\/\/@ sourceMappingURL=' + this._sourceMapUrl;
|
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,10 @@ describe('Package', function() {
|
||||||
ppackage.addModule('transformed foo;', 'source foo', 'foo path');
|
ppackage.addModule('transformed foo;', 'source foo', 'foo path');
|
||||||
ppackage.addModule('transformed bar;', 'source bar', 'bar path');
|
ppackage.addModule('transformed bar;', 'source bar', 'bar path');
|
||||||
ppackage.finalize({});
|
ppackage.finalize({});
|
||||||
expect(ppackage.getSource({inlineSourceMap: true})).toBe([
|
expect(ppackage.getSource()).toBe([
|
||||||
'transformed foo;',
|
'transformed foo;',
|
||||||
'transformed bar;',
|
'transformed bar;',
|
||||||
'RAW_SOURCE_MAP = "test-source-map";',
|
'\/\/@ sourceMappingURL=test_url'
|
||||||
'\/\/@ sourceMappingURL=test_url',
|
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,11 +41,10 @@ describe('Package', function() {
|
||||||
ppackage.addModule('transformed bar;', 'source bar', 'bar path');
|
ppackage.addModule('transformed bar;', 'source bar', 'bar path');
|
||||||
ppackage.setMainModuleId('foo');
|
ppackage.setMainModuleId('foo');
|
||||||
ppackage.finalize({runMainModule: true});
|
ppackage.finalize({runMainModule: true});
|
||||||
expect(ppackage.getSource({inlineSourceMap: true})).toBe([
|
expect(ppackage.getSource()).toBe([
|
||||||
'transformed foo;',
|
'transformed foo;',
|
||||||
'transformed bar;',
|
'transformed bar;',
|
||||||
';require("foo");',
|
';require("foo");',
|
||||||
'RAW_SOURCE_MAP = "test-source-map";',
|
|
||||||
'\/\/@ sourceMappingURL=test_url',
|
'\/\/@ sourceMappingURL=test_url',
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
});
|
});
|
||||||
|
|
|
@ -98,7 +98,7 @@ Server.prototype._rebuildPackages = function() {
|
||||||
packages[key] = buildPackage(options).then(function(p) {
|
packages[key] = buildPackage(options).then(function(p) {
|
||||||
// Make a throwaway call to getSource to cache the source string.
|
// Make a throwaway call to getSource to cache the source string.
|
||||||
p.getSource({
|
p.getSource({
|
||||||
inlineSourceMap: options.dev,
|
inlineSourceMap: options.inlineSourceMap,
|
||||||
minify: options.minify,
|
minify: options.minify,
|
||||||
});
|
});
|
||||||
return p;
|
return p;
|
||||||
|
@ -228,7 +228,7 @@ Server.prototype.processRequest = function(req, res, next) {
|
||||||
function(p) {
|
function(p) {
|
||||||
if (requestType === 'bundle') {
|
if (requestType === 'bundle') {
|
||||||
res.end(p.getSource({
|
res.end(p.getSource({
|
||||||
inlineSourceMap: options.dev,
|
inlineSourceMap: options.inlineSourceMap,
|
||||||
minify: options.minify,
|
minify: options.minify,
|
||||||
}));
|
}));
|
||||||
Activity.endEvent(startReqEventId);
|
Activity.endEvent(startReqEventId);
|
||||||
|
@ -264,6 +264,11 @@ function getOptionsFromUrl(reqUrl) {
|
||||||
dev: getBoolOptionFromQuery(urlObj.query, 'dev', true),
|
dev: getBoolOptionFromQuery(urlObj.query, 'dev', true),
|
||||||
minify: getBoolOptionFromQuery(urlObj.query, 'minify'),
|
minify: getBoolOptionFromQuery(urlObj.query, 'minify'),
|
||||||
runModule: getBoolOptionFromQuery(urlObj.query, 'runModule', true),
|
runModule: getBoolOptionFromQuery(urlObj.query, 'runModule', true),
|
||||||
|
inlineSourceMap: getBoolOptionFromQuery(
|
||||||
|
urlObj.query,
|
||||||
|
'inlineSourceMap',
|
||||||
|
false
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue