Skip to content

Commit

Permalink
remove support for process.platform
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D3252666

fb-gh-sync-id: af0e4987c34f43ec2472cbdf52fc112b81050513
fbshipit-source-id: af0e4987c34f43ec2472cbdf52fc112b81050513
  • Loading branch information
davidaurelio authored and Facebook Github Bot 5 committed May 4, 2016
1 parent 6c80f88 commit 46d98e1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ function setUpProcess() {
if (!global.process.env.NODE_ENV) {
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';
}

polyfillLazyGlobal('platform', () => require('Platform').OS, global.process);
}

function setUpDevTools() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,6 @@ describe('inline constants', () => {
normalize(code.replace(/process\.env\.NODE_ENV/, '"development"')));
});

it('replaces process.platform in the code', () => {
const code = `function a() {
if (process.platform === 'android') {
return require('./android');
}
return require('./ios');
}`;
const {ast} = inline('arbitrary.js', {code}, {platform: 'ios'});
expect(toString(ast)).toEqual(
normalize(code.replace(/process\.platform\b/, '"ios"')));
});

it('accepts an AST as input', function() {
const code = 'function ifDev(a,b){return __DEV__?a:b;}';
const {ast} = inline('arbitrary.hs', {ast: toAst(code)}, {dev: false});
Expand Down
9 changes: 0 additions & 9 deletions packager/react-packager/src/JSTransformer/worker/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const requirePattern = {name: 'require'};
const env = {name: 'env'};
const nodeEnv = {name: 'NODE_ENV'};
const processId = {name: 'process'};
const platformId = {name: 'platform'};

const dev = {name: '__DEV__'};

Expand Down Expand Up @@ -64,11 +63,6 @@ const isProcessEnvNodeEnv = (node, scope) =>
t.isIdentifier(node.object.object, processId) &&
isGlobal(scope.getBinding(processId.name));

const isProcessPlatform = (node, scope) =>
t.isIdentifier(node.property, platformId) &&
t.isIdentifier(node.object, processId) &&
isGlobal(scope.getBinding(processId.name));

const isDev = (node, parent, scope) =>
t.isIdentifier(node, dev) &&
isGlobal(scope.getBinding(dev.name)) &&
Expand All @@ -90,9 +84,6 @@ const inlinePlugin = {
} else if (isProcessEnvNodeEnv(node, scope)) {
path.replaceWith(
t.stringLiteral(state.opts.dev ? 'development' : 'production'));
} else if (isProcessPlatform(node, scope)) {
path.replaceWith(
t.stringLiteral(state.opts.platform));
}
},
},
Expand Down

0 comments on commit 46d98e1

Please sign in to comment.