Infer platform from extension

Summary: public
Aparently this used to work on 0.11, lets fix it :)

Reviewed By: foghina

Differential Revision: D2557719

fb-gh-sync-id: dcbca077431c1356c89dfc55b71eecff64c7ad3d
This commit is contained in:
Martín Bigio 2015-10-27 17:44:59 -07:00 committed by facebook-github-bot-6
parent abeaa5bc9b
commit c5c4dc94b1
1 changed files with 14 additions and 1 deletions

View File

@ -11,6 +11,7 @@
const Activity = require('../Activity');
const AssetServer = require('../AssetServer');
const FileWatcher = require('../FileWatcher');
const getPlatformExtension = require('../lib/getPlatformExtension');
const Bundler = require('../Bundler');
const Promise = require('promise');
@ -173,6 +174,10 @@ class Server {
buildBundle(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = bundleOpts(options);
return this._bundler.bundle(
opts.entryFile,
@ -191,6 +196,10 @@ class Server {
getDependencies(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = dependencyOpts(options);
return this._bundler.getDependencies(
opts.entryFile,
@ -432,6 +441,10 @@ class Server {
const sourceMapUrlObj = _.clone(urlObj);
sourceMapUrlObj.pathname = pathname.replace(/\.bundle$/, '.map');
// try to get the platform from the url
const platform = urlObj.query.platform ||
getPlatformExtension(pathname);
return {
sourceMapUrl: url.format(sourceMapUrlObj),
entryFile: entryFile,
@ -443,7 +456,7 @@ class Server {
'inlineSourceMap',
false
),
platform: urlObj.query.platform,
platform: platform,
};
}