Skip to content

Commit

Permalink
[change] Compile using Babel 7
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Dec 20, 2018
1 parent 4b3f6ef commit f0f3236
Show file tree
Hide file tree
Showing 7 changed files with 2,838 additions and 450 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function(api) {
api.cache(true);

return {
presets: ['./scripts/babel/preset']
};
};
2 changes: 1 addition & 1 deletion docs/guides/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ If you're using `skpm`, you can rely on an [undocumented
feature](https://github.com/sketch-pm/skpm/blob/master/lib/utils/webpackConfig.js)
which will merge your `webpack.config.js`, `.babelrc`, or `package.json` Babel
config into its internal webpack config. The simplest option may be to use the
[babel-plugin-module-alias](https://www.npmjs.com/package/babel-plugin-module-alias)
[babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver)
and configure it in your `package.json`.
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"website:release": "cd packages/website && yarn release",
"flow": "flow",
"fmt": "prettier --write \"**/*.js\"",
"jest": "BABEL_ENV=commonjs jest --config ./scripts/jest/config.js",
"jest": "jest --config ./scripts/jest/config.js",
"lint": "yarn lint:check --fix",
"lint:check": "eslint packages scripts",
"precommit": "lint-staged",
Expand All @@ -25,18 +25,19 @@
"test": "yarn flow && yarn lint:check && yarn jest --runInBand"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.10",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.0",
"babel-jest": "^23.4.2",
"babel-loader": "^8.0.0",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.21",
"babel-preset-react-native": "^4.0.1",
"caniuse-api": "^2.0.0",
"del-cli": "^1.1.0",
"enzyme": "^3.6.0",
Expand All @@ -49,7 +50,7 @@
"flow-bin": "^0.63.1",
"glob": "^7.1.2",
"husky": "^0.14.3",
"jest": "^22.4.3",
"jest": "^23.6.0",
"jest-canvas-mock": "^1.0.2",
"lint-staged": "^7.1.0",
"npm-run-all": "^4.1.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"release": "yarn build && git checkout gh-pages && rm -rf ../../examples && mv dist ../../examples && git add -A && git commit -m \"Examples deploy\" && git push origin gh-pages && git checkout -"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.2.0",
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-native-web": "0.9.9"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.2.0",
"babel-plugin-react-native-web": "0.9.9",
"babel-plugin-transform-runtime": "^6.23.0",
"file-loader": "^1.1.11",
"webpack": "^4.8.1",
"webpack-bundle-analyzer": "^2.11.1",
Expand Down
17 changes: 9 additions & 8 deletions scripts/babel/preset.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const createConfig = ({ modules }) => ({
presets: [
[
'babel-preset-env',
'@babel/preset-env',
{
loose: true,
modules,
exclude: ['transform-es2015-typeof-symbol'],
exclude: ['transform-typeof-symbol'],
targets: {
browsers: [
'chrome 38',
Expand All @@ -24,17 +24,18 @@ const createConfig = ({ modules }) => ({
}
}
],
'babel-preset-react',
'babel-preset-flow'
'@babel/preset-react',
'@babel/preset-flow'
],
plugins: [
['babel-plugin-transform-class-properties', { loose: true }],
['babel-plugin-transform-object-rest-spread', { useBuiltIns: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
['babel-plugin-transform-react-remove-prop-types', { mode: 'wrap' }]
].concat(modules ? ['babel-plugin-add-module-exports'] : [])
});

module.exports =
process.env.BABEL_ENV === 'commonjs'
module.exports = function() {
return process.env.BABEL_ENV === 'commonjs' || process.env.NODE_ENV === 'test'
? createConfig({ modules: 'commonjs' })
: createConfig({ modules: false });
};
Loading

0 comments on commit f0f3236

Please sign in to comment.