diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index c18fe04a..2b589d52 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -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, }; }