Add option to bundle server to generate full sourcemaps from babel
Reviewed By: bestander Differential Revision: D3863894 fbshipit-source-id: a282758e022d403743841bc59277196e6741ed18
This commit is contained in:
parent
fa6191f6ac
commit
e6bec9cb80
|
@ -32,10 +32,11 @@ function getSourceMapForUrl(url, onFailure, onSuccess) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedUrl = urlLib.parse(url);
|
const parsedUrl = urlLib.parse(url);
|
||||||
|
const mapPath = parsedUrl.pathname.replace(/\.bundle$/, '.map');
|
||||||
const options = {
|
const options = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: parsedUrl.port,
|
port: parsedUrl.port,
|
||||||
path: parsedUrl.pathname.replace(/\.bundle$/, '.map') + parsedUrl.search,
|
path: mapPath + parsedUrl.search + '&babelSourcemap=true',
|
||||||
};
|
};
|
||||||
|
|
||||||
http.get(options, (res) => {
|
http.get(options, (res) => {
|
||||||
|
|
|
@ -79,10 +79,11 @@ class TreeTransformator {
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedUrl = urlLib.parse(url);
|
const parsedUrl = urlLib.parse(url);
|
||||||
|
const mapPath = parsedUrl.pathname.replace(/\.bundle$/, '.map');
|
||||||
const options = {
|
const options = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: parsedUrl.port,
|
port: parsedUrl.port,
|
||||||
path: parsedUrl.pathname.replace(/\.bundle$/, '.map') + parsedUrl.search,
|
path: mapPath + parsedUrl.search + '&babelSourcemap=true',
|
||||||
};
|
};
|
||||||
|
|
||||||
http.get(options, (res) => {
|
http.get(options, (res) => {
|
||||||
|
|
|
@ -257,6 +257,7 @@ class Bundler {
|
||||||
entryModuleOnly,
|
entryModuleOnly,
|
||||||
resolutionResponse,
|
resolutionResponse,
|
||||||
isolateModuleIDs,
|
isolateModuleIDs,
|
||||||
|
generateSourceMaps,
|
||||||
}) {
|
}) {
|
||||||
const onResolutionResponse = response => {
|
const onResolutionResponse = response => {
|
||||||
bundle.setMainModuleId(response.getModuleId(getMainModule(response)));
|
bundle.setMainModuleId(response.getModuleId(getMainModule(response)));
|
||||||
|
@ -301,6 +302,7 @@ class Bundler {
|
||||||
onResolutionResponse,
|
onResolutionResponse,
|
||||||
finalizeBundle,
|
finalizeBundle,
|
||||||
isolateModuleIDs,
|
isolateModuleIDs,
|
||||||
|
generateSourceMaps,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,6 +354,7 @@ class Bundler {
|
||||||
unbundle,
|
unbundle,
|
||||||
resolutionResponse,
|
resolutionResponse,
|
||||||
isolateModuleIDs,
|
isolateModuleIDs,
|
||||||
|
generateSourceMaps,
|
||||||
onResolutionResponse = noop,
|
onResolutionResponse = noop,
|
||||||
onModuleTransformed = noop,
|
onModuleTransformed = noop,
|
||||||
finalizeBundle = noop,
|
finalizeBundle = noop,
|
||||||
|
@ -385,7 +388,7 @@ class Bundler {
|
||||||
onProgress,
|
onProgress,
|
||||||
minify,
|
minify,
|
||||||
isolateModuleIDs,
|
isolateModuleIDs,
|
||||||
generateSourceMaps: unbundle,
|
generateSourceMaps: unbundle || generateSourceMaps,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,10 @@ const bundleOpts = declareOpts({
|
||||||
resolutionResponse: {
|
resolutionResponse: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
},
|
},
|
||||||
|
generateSourceMaps: {
|
||||||
|
type: 'boolean',
|
||||||
|
required: false,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const dependencyOpts = declareOpts({
|
const dependencyOpts = declareOpts({
|
||||||
|
@ -814,7 +818,7 @@ class Server {
|
||||||
sourceMapUrl: url.format(sourceMapUrlObj),
|
sourceMapUrl: url.format(sourceMapUrlObj),
|
||||||
entryFile: entryFile,
|
entryFile: entryFile,
|
||||||
dev: this._getBoolOptionFromQuery(urlObj.query, 'dev', true),
|
dev: this._getBoolOptionFromQuery(urlObj.query, 'dev', true),
|
||||||
minify: this._getBoolOptionFromQuery(urlObj.query, 'minify'),
|
minify: this._getBoolOptionFromQuery(urlObj.query, 'minify', false),
|
||||||
hot: this._getBoolOptionFromQuery(urlObj.query, 'hot', false),
|
hot: this._getBoolOptionFromQuery(urlObj.query, 'hot', false),
|
||||||
runModule: this._getBoolOptionFromQuery(urlObj.query, 'runModule', true),
|
runModule: this._getBoolOptionFromQuery(urlObj.query, 'runModule', true),
|
||||||
inlineSourceMap: this._getBoolOptionFromQuery(
|
inlineSourceMap: this._getBoolOptionFromQuery(
|
||||||
|
@ -828,11 +832,12 @@ class Server {
|
||||||
'entryModuleOnly',
|
'entryModuleOnly',
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
generateSourceMaps: this._getBoolOptionFromQuery(urlObj.query, 'babelSourcemap'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_getBoolOptionFromQuery(query, opt, defaultVal) {
|
_getBoolOptionFromQuery(query, opt, defaultVal) {
|
||||||
if (query[opt] == null && defaultVal != null) {
|
if (query[opt] == null) {
|
||||||
return defaultVal;
|
return defaultVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue