From b5d92b27ee8e9dad83dc8b7c3910bc55965b41a8 Mon Sep 17 00:00:00 2001 From: Owen Evans Date: Wed, 4 Nov 2015 10:11:31 +1300 Subject: [PATCH 1/3] update tests to use babel 6 --- .babelrc | 3 +++ package.json | 5 +++-- test/fixtures/classic/.babelrc | 10 +++++----- test/fixtures/customFactoryMethod/.babelrc | 10 +++++----- test/fixtures/modern/.babelrc | 10 +++++----- test/fixtures/vanilla/.babelrc | 11 ++++++----- test/index.js | 2 +- 7 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c13c5f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/package.json b/package.json index f422427..abf2b10 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,15 @@ }, "homepage": "https://github.com/gaearon/babel-plugin-react-transform#readme", "devDependencies": { - "babel": "^5.8.23", + "babel-core": "^6.0.0", + "babel-preset-es2015": "^6.0.15", "mocha": "^2.2.5", "rimraf": "^2.4.3" }, "scripts": { "clean": "rimraf lib", "build": "babel-plugin build", - "test": "mocha --compilers js:babel/register", + "test": "mocha --compilers js:babel-core/register", "test:watch": "npm run test -- --watch", "prepublish": "npm run clean && npm run build" }, diff --git a/test/fixtures/classic/.babelrc b/test/fixtures/classic/.babelrc index c166d04..a23bf02 100644 --- a/test/fixtures/classic/.babelrc +++ b/test/fixtures/classic/.babelrc @@ -1,7 +1,7 @@ { - "plugins": ["../../../src"], - "extra": { - "react-transform": { + "presets": ["es2015"], + "plugins": [ + ["../../../src", { "transforms": [{ "transform": "my-custom-module/wrap", "locals": ["module"], @@ -9,6 +9,6 @@ }, { "transform": "my-other-custom-module/wrap" }] - } - } + }] + ] } diff --git a/test/fixtures/customFactoryMethod/.babelrc b/test/fixtures/customFactoryMethod/.babelrc index 3ca1131..4dd34e5 100644 --- a/test/fixtures/customFactoryMethod/.babelrc +++ b/test/fixtures/customFactoryMethod/.babelrc @@ -1,7 +1,7 @@ { - "plugins": ["../../../src"], - "extra": { - "react-transform": { + "presets": ["es2015"], + "plugins": [ + ["../../../src", { "transforms": [{ "transform": "my-custom-module/wrap", "locals": ["module"], @@ -14,6 +14,6 @@ "createClass", "myComponentFactory" ] - } - } + }] + ] } diff --git a/test/fixtures/modern/.babelrc b/test/fixtures/modern/.babelrc index c166d04..a23bf02 100644 --- a/test/fixtures/modern/.babelrc +++ b/test/fixtures/modern/.babelrc @@ -1,7 +1,7 @@ { - "plugins": ["../../../src"], - "extra": { - "react-transform": { + "presets": ["es2015"], + "plugins": [ + ["../../../src", { "transforms": [{ "transform": "my-custom-module/wrap", "locals": ["module"], @@ -9,6 +9,6 @@ }, { "transform": "my-other-custom-module/wrap" }] - } - } + }] + ] } diff --git a/test/fixtures/vanilla/.babelrc b/test/fixtures/vanilla/.babelrc index c166d04..1565b49 100644 --- a/test/fixtures/vanilla/.babelrc +++ b/test/fixtures/vanilla/.babelrc @@ -1,7 +1,7 @@ { - "plugins": ["../../../src"], - "extra": { - "react-transform": { + "presets": ["es2015"], + "plugins": [ + ["../../../src", { "transforms": [{ "transform": "my-custom-module/wrap", "locals": ["module"], @@ -9,6 +9,7 @@ }, { "transform": "my-other-custom-module/wrap" }] - } - } + + }] + ] } diff --git a/test/index.js b/test/index.js index b2d99a8..fc6ec37 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,7 @@ import path from 'path'; import fs from 'fs'; import assert from 'assert'; -import { transformFileSync } from 'babel'; +import { transformFileSync } from 'babel-core'; import plugin from '../src'; function trim(str) { From 9a832b501a29c533406f4aefd964ef04a75377d9 Mon Sep 17 00:00:00 2001 From: Owen Evans Date: Wed, 4 Nov 2015 11:27:29 +1300 Subject: [PATCH 2/3] fix build process --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index abf2b10..0699623 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "homepage": "https://github.com/gaearon/babel-plugin-react-transform#readme", "devDependencies": { + "babel-cli": "^6.1.1", "babel-core": "^6.0.0", "babel-preset-es2015": "^6.0.15", "mocha": "^2.2.5", @@ -21,7 +22,7 @@ }, "scripts": { "clean": "rimraf lib", - "build": "babel-plugin build", + "build": "babel src --out-dir lib --copy-files", "test": "mocha --compilers js:babel-core/register", "test:watch": "npm run test -- --watch", "prepublish": "npm run clean && npm run build" From 38f40c23f7c0453148f256a1a8a46f50d1c4e1c2 Mon Sep 17 00:00:00 2001 From: Owen Evans Date: Wed, 4 Nov 2015 11:37:36 +1300 Subject: [PATCH 3/3] don't return anything from exit functions --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 737677e..0fb736c 100644 --- a/src/index.js +++ b/src/index.js @@ -230,7 +230,7 @@ export default function ({ types: t }) { const wrapReactComponentId = this.state[wrapComponentIdKey]; const uniqueId = addComponentRecord(node, scope, file, this.state); - return t.callExpression( + t.callExpression( t.callExpression(wrapReactComponentId, [t.stringLiteral(uniqueId)]), [node] ); @@ -278,7 +278,7 @@ export default function ({ types: t }) { // Create one uber function calling each transformation const wrapComponentId = this.state[wrapComponentIdKey]; const wrapComponent = defineWrapComponent(wrapComponentId, initTransformIds); - return t.program([ + t.program([ recordsVar, ...initTransformVars, wrapComponent,