From 5f53658fb010a9e7cb4e5797b8bf6e56151a5bee Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Wed, 4 May 2016 02:50:36 -0700 Subject: [PATCH] remove support for `process.platform` Reviewed By: javache Differential Revision: D3252666 fb-gh-sync-id: af0e4987c34f43ec2472cbdf52fc112b81050513 fbshipit-source-id: af0e4987c34f43ec2472cbdf52fc112b81050513 --- .../JSTransformer/worker/__tests__/inline-test.js | 12 ------------ react-packager/src/JSTransformer/worker/inline.js | 9 --------- 2 files changed, 21 deletions(-) diff --git a/react-packager/src/JSTransformer/worker/__tests__/inline-test.js b/react-packager/src/JSTransformer/worker/__tests__/inline-test.js index ab598388..102e39ab 100644 --- a/react-packager/src/JSTransformer/worker/__tests__/inline-test.js +++ b/react-packager/src/JSTransformer/worker/__tests__/inline-test.js @@ -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}); diff --git a/react-packager/src/JSTransformer/worker/inline.js b/react-packager/src/JSTransformer/worker/inline.js index 996ff51f..13e20b0e 100644 --- a/react-packager/src/JSTransformer/worker/inline.js +++ b/react-packager/src/JSTransformer/worker/inline.js @@ -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__'}; @@ -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)) && @@ -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)); } }, },