From b907f40957bbd822cfab3a56d82363ffd58d2e78 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Tue, 10 Nov 2015 10:51:51 -0800 Subject: [PATCH] Fix breakages when upgrading to babel 6 Reviewed By: vjeux Differential Revision: D2628092 fb-gh-sync-id: 077a3572fe8b261d390be2bdc32d9d06c2b80a01 --- Libraries/Animated/src/Easing.js | 4 ++-- local-cli/bundle/__tests__/saveBundleAndMap-test.js | 6 ++---- packager/react-packager/src/Bundler/index.js | 13 +++++++------ .../src/Cache/__tests__/Cache-test.js | 11 ++++------- .../__tests__/babel-plugin-system-import-test.js | 6 +++--- packager/transformer.js | 1 + 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Libraries/Animated/src/Easing.js b/Libraries/Animated/src/Easing.js index a8c816d3b..46c30aed0 100644 --- a/Libraries/Animated/src/Easing.js +++ b/Libraries/Animated/src/Easing.js @@ -11,7 +11,7 @@ */ 'use strict'; -var bezier = require('bezier'); +var _bezier = require('bezier'); /** * This class implements common easing functions. The math is pretty obscure, @@ -114,7 +114,7 @@ class Easing { epsilon = (1000 / 60 / duration) / 4; } - return bezier(x1, y1, x2, y2, epsilon); + return _bezier(x1, y1, x2, y2, epsilon); } static in( diff --git a/local-cli/bundle/__tests__/saveBundleAndMap-test.js b/local-cli/bundle/__tests__/saveBundleAndMap-test.js index 1d155e273..4bd516a05 100644 --- a/local-cli/bundle/__tests__/saveBundleAndMap-test.js +++ b/local-cli/bundle/__tests__/saveBundleAndMap-test.js @@ -8,12 +8,10 @@ */ 'use strict'; -jest - .dontMock('../saveBundleAndMap') - .dontMock('os-tmpdir') - .dontMock('temp'); +jest.autoMockOff(); jest.mock('fs'); +jest.mock('../sign'); const saveBundleAndMap = require('../saveBundleAndMap'); const fs = require('fs'); diff --git a/packager/react-packager/src/Bundler/index.js b/packager/react-packager/src/Bundler/index.js index 2b0c5ff2d..82a0282be 100644 --- a/packager/react-packager/src/Bundler/index.js +++ b/packager/react-packager/src/Bundler/index.js @@ -140,7 +140,8 @@ class Bundler { dev: isDev, platform, }) { - const bundle = new Bundle(sourceMapUrl); + // Const cannot have the same name as the method (babel/babel#2834) + const bbundle = new Bundle(sourceMapUrl); const findEventId = Activity.startEvent('find dependencies'); let transformEventId; @@ -158,11 +159,11 @@ class Bundler { }); } - bundle.setMainModuleId(response.mainModuleId); + bbundle.setMainModuleId(response.mainModuleId); return Promise.all( response.dependencies.map( module => this._transformModule( - bundle, + bbundle, response, module, platform @@ -178,11 +179,11 @@ class Bundler { Activity.endEvent(transformEventId); transformedModules.forEach(function(moduleTransport) { - bundle.addModule(moduleTransport); + bbundle.addModule(moduleTransport); }); - bundle.finalize({runBeforeMainModule, runMainModule}); - return bundle; + bbundle.finalize({runBeforeMainModule, runMainModule}); + return bbundle; }); } diff --git a/packager/react-packager/src/Cache/__tests__/Cache-test.js b/packager/react-packager/src/Cache/__tests__/Cache-test.js index 89c3196e6..ee06dd221 100644 --- a/packager/react-packager/src/Cache/__tests__/Cache-test.js +++ b/packager/react-packager/src/Cache/__tests__/Cache-test.js @@ -16,21 +16,18 @@ jest .dontMock('../../lib/getCacheFilePath'); jest - .mock('os') - .mock('fs'); + .mock('fs') + .setMock('os', { + tmpDir() { return 'tmpDir'; } + }); var Promise = require('promise'); var fs = require('fs'); -var os = require('os'); var _ = require('underscore'); var Cache = require('../'); describe('JSTransformer Cache', () => { - beforeEach(() => { - os.tmpDir.mockImpl(() => 'tmpDir'); - }); - describe('getting/setting', () => { pit('calls loader callback for uncached file', () => { fs.stat.mockImpl((file, callback) => { diff --git a/packager/react-packager/src/transforms/babel-plugin-system-import/__tests__/babel-plugin-system-import-test.js b/packager/react-packager/src/transforms/babel-plugin-system-import/__tests__/babel-plugin-system-import-test.js index ddf8f2403..43aa4b56b 100644 --- a/packager/react-packager/src/transforms/babel-plugin-system-import/__tests__/babel-plugin-system-import-test.js +++ b/packager/react-packager/src/transforms/babel-plugin-system-import/__tests__/babel-plugin-system-import-test.js @@ -46,9 +46,9 @@ describe('System.import', () => { function transform(source) { return babel.transform(source, { - plugins: [require('../')], - blacklist: ['strict'], - extra: { bundlesLayout: layout }, + plugins: [ + [require('../'), { bundlesLayout: layout }] + ], }).code; } diff --git a/packager/transformer.js b/packager/transformer.js index e7368cc63..f194c4406 100644 --- a/packager/transformer.js +++ b/packager/transformer.js @@ -47,6 +47,7 @@ function transform(src, filename, options) { 'transform-flow-strip-types', 'transform-object-assign', 'transform-object-rest-spread', + 'transform-object-assign', 'transform-react-display-name', 'transform-react-jsx', 'transform-regenerator',