[react-packager] Sourcemap url should include the same args as the bundle url

Summary:
Sourcemap urls were generated as just the pathname (no options) which meant that they generated source for the wrong bundle.

Even worse, there exists a race condition when multiple request to the same bundle has different types of paltform arguments (in this case one could be 'ios' and the other is undefined). The fix will this will come later as it's more involved -- will need to refactor the dependency resolver to have a per-request state.
This commit is contained in:
Amjad Masad 2015-09-02 15:40:26 -07:00
parent c48ce25de6
commit 672b7b0070
2 changed files with 6 additions and 3 deletions

View File

@ -125,7 +125,7 @@ describe('processRequest', () => {
expect(Bundler.prototype.bundle).toBeCalledWith(
'index.js',
true,
'index.map',
'index.map?platform=ios',
true,
'ios',
);
@ -270,7 +270,7 @@ describe('processRequest', () => {
expect(Bundler.prototype.bundle).toBeCalledWith(
'path/to/foo.js',
false,
'/path/to/foo.map',
'/path/to/foo.map?dev=false&runModule=false',
false,
undefined
);

View File

@ -429,8 +429,11 @@ class Server {
return true;
}).join('.') + '.js';
const sourceMapUrlObj = _.clone(urlObj);
sourceMapUrlObj.pathname = pathname.replace(/\.bundle$/, '.map');
return {
sourceMapUrl: pathname.replace(/\.bundle$/, '.map'),
sourceMapUrl: url.format(sourceMapUrlObj),
entryFile: entryFile,
dev: this._getBoolOptionFromQuery(urlObj.query, 'dev', true),
minify: this._getBoolOptionFromQuery(urlObj.query, 'minify'),