Skip to content

Commit

Permalink
Upgrade to babel 7
Browse files Browse the repository at this point in the history
In this diff I moved build to babel 7, removed unused packages and made
babel helpers importable from runtime. This allows to reuse these
helpers across many packages and save a few kilobytes in user bundle.
  • Loading branch information
TrySound committed Aug 29, 2018
1 parent 86c24c0 commit 9f34704
Show file tree
Hide file tree
Showing 5 changed files with 751 additions and 444 deletions.
14 changes: 0 additions & 14 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 = {
presets: [['@babel/env', { loose: true }], '@babel/flow'],
plugins: [
['@babel/proposal-class-properties', { loose: true }],
'annotate-pure-calls',
],
};
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"name": "react-window",
"version": "1.1.1",
"description":
"React components for efficiently rendering large, scrollable lists and tabular data",
"author":
"Brian Vaughn <[email protected]> (https://github.com/bvaughn/)",
"description": "React components for efficiently rendering large, scrollable lists and tabular data",
"author": "Brian Vaughn <[email protected]> (https://github.com/bvaughn/)",
"contributors": [
"Brian Vaughn <[email protected]> (https://github.com/bvaughn/)"
],
Expand Down Expand Up @@ -36,7 +34,9 @@
],
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"files": ["dist"],
"files": [
"dist"
],
"scripts": {
"precommit": "lint-staged",
"prettier": "prettier --write '**/*.{js,json,css}'",
Expand All @@ -52,24 +52,29 @@
"website:run": "cd website && yarn start"
},
"lint-staged": {
"{website,src}/**/*.{js,json,css}": ["prettier --write", "git add"],
"{website,src}/**/*.{js,json,css}": [
"prettier --write",
"git add"
],
"**/*.js": "eslint --max-warnings 0"
},
"dependencies": {
"@babel/runtime": "^7.0.0",
"memoize-one": "^3.1.1"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-plugin-annotate-pure-calls": "^0.3.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^5.1.4",
"del-cli": "^1.1.0",
"eslint": "^4.19.1",
Expand All @@ -92,12 +97,9 @@
"react-dom": "^16.4.0",
"react-scripts": "^1.1.1",
"react-test-renderer": "^16.4.0",
"rollup": "^0.59.3",
"rollup-plugin-babel": "^3.0.3",
"rollup": "^0.65.0",
"rollup-plugin-babel": "^4.0.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-postcss": "^1.1.0",
"rollup-plugin-url": "^1.3.0"
"rollup-plugin-node-resolve": "^3.0.2"
}
}
58 changes: 34 additions & 24 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import url from 'rollup-plugin-url';

import nodeResolve from 'rollup-plugin-node-resolve';
import pkg from './package.json';

export default {
input: 'src/index.js',
output: [
{
const input = './src/index.js';

const external = id => !id.startsWith('.') && !id.startsWith('/');

export default [
{
input,
output: {
file: pkg.main,
format: 'cjs',
},
{
external,
plugins: [
babel({
runtimeHelpers: true,
plugins: ['@babel/transform-runtime'],
}),
nodeResolve(),
commonjs(),
],
},

{
input,
output: {
file: pkg.module,
format: 'esm',
},
],
plugins: [
external({ includeDependencies: true }),
postcss({
modules: true,
}),
url(),
babel({
exclude: 'node_modules/**',
}),
resolve(),
commonjs(),
],
};
external,
plugins: [
babel({
runtimeHelpers: true,
plugins: [['@babel/transform-runtime', { useESModules: true }]],
}),
nodeResolve(),
commonjs(),
],
},
];
Loading

0 comments on commit 9f34704

Please sign in to comment.