Skip to content

Commit 153f682

Browse files
beefancohenljharb
authored andcommitted
Transform/polyfill Object.assign and support node version 0.10 and 0.12.
- Only run linting in node > 6 - Dont run prepublish on install.
1 parent 2f6a9aa commit 153f682

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

.babelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"presets": ["es2015"]
2+
"presets": ["es2015"],
3+
"plugins": [
4+
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
5+
],
36
}

.travis.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
language: node_js
22
node_js:
3-
- 4
4-
- 5
5-
- 6
3+
- "12"
4+
- "10"
5+
- "8"
6+
- "6"
7+
- "4"
8+
- "0.12"
9+
- "0.10"
610
cache:
7-
yarn: true
811
directories:
912
- node_modules
1013
after_success:

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "AST utility module for statically analyzing JSX",
55
"main": "lib/index.js",
66
"scripts": {
7-
"build": "rimraf lib && babel src --out-dir lib",
8-
"prepublish": "npm run lint && npm run test && npm run build",
7+
"prebuild": "rimraf lib",
8+
"build": "babel src --out-dir lib",
9+
"prepublish": "not-in-publish || (npm test && npm run build)",
910
"coveralls": "cat ./reports/lcov.info | coveralls",
10-
"lint": "eslint --config .eslintrc .",
11-
"lint:fix": "npm run lint -- --fix",
11+
"lint": "eslint .",
1212
"pretest": "npm run lint",
1313
"test": "jest --coverage",
1414
"test:watch": "npm test -- --watch"
@@ -19,13 +19,15 @@
1919
"babel-core": "^6.26.3",
2020
"babel-eslint": "^7.2.3",
2121
"babel-jest": "^20.0.3",
22+
"babel-plugin-transform-replace-object-assign": "^2.0.0",
2223
"babel-polyfill": "^6.26.0",
2324
"babel-preset-es2015": "^6.24.1",
2425
"babylon": "^6.18.0",
2526
"coveralls": "^2.13.3",
2627
"eslint": "^5.16.0",
2728
"eslint-config-airbnb-base": "^13.1.0",
2829
"eslint-plugin-import": "^2.17.2",
30+
"in-publish": "^2.0.0",
2931
"jest": "^20.0.4",
3032
"jest-cli": "^20.0.4",
3133
"rimraf": "^2.6.3"
@@ -56,6 +58,7 @@
5658
]
5759
},
5860
"dependencies": {
59-
"array-includes": "^3.0.3"
61+
"array-includes": "^3.0.3",
62+
"object.assign": "^4.1.0"
6063
}
6164
}

src/values/expressions/ObjectExpression.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import assign from 'object.assign';
2+
13
/**
24
* Extractor function for an ObjectExpression type value node.
35
* An object expression is using {}.
@@ -12,7 +14,7 @@ export default function extractValueFromObjectExpression(value) {
1214
// Support types: SpreadProperty and ExperimentalSpreadProperty
1315
if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) {
1416
if (property.argument.type === 'ObjectExpression') {
15-
return Object.assign(object, extractValueFromObjectExpression(property.argument));
17+
return assign(object, extractValueFromObjectExpression(property.argument));
1618
}
1719
} else {
1820
object[getValue(property.key)] = getValue(property.value);

0 commit comments

Comments
 (0)