Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Upgrade babel and reduce bundles size #715

Merged
merged 1 commit into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .babelrc

This file was deleted.

24 changes: 12 additions & 12 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"lib/packages/recompose/dist/Recompose.umd.js": {
"bundled": 85724,
"minified": 31665,
"gzipped": 10051
"bundled": 46995,
"minified": 16584,
"gzipped": 4651
},
"lib/packages/recompose/dist/Recompose.min.js": {
"bundled": 82164,
"minified": 30382,
"gzipped": 9658
"bundled": 43433,
"minified": 15304,
"gzipped": 4220
},
"lib/packages/recompose/dist/Recompose.esm.js": {
"bundled": 32374,
"minified": 16118,
"gzipped": 3577,
"bundled": 31344,
"minified": 14863,
"gzipped": 3459,
"treeshaked": {
"rollup": {
"code": 601,
"import_statements": 472
"code": 364,
"import_statements": 364
},
"webpack": {
"code": 2248
"code": 1893
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
plugins: [['@babel/proposal-class-properties', { loose: true }]],
presets: [['@babel/env', { loose: true, modules: false }], '@babel/react'],
}

if (process.env.NODE_ENV === 'cjs' || process.env.NODE_ENV === 'test') {
module.exports.plugins.push(
'@babel/transform-runtime',
'@babel/transform-modules-commonjs'
)
}
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@
]
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.5.2",
"@babel/cli": "^7.0.0-beta.55",
"@babel/core": "^7.0.0-beta.55",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.55",
"@babel/plugin-transform-modules-commonjs": "^7.0.0-beta.55",
"@babel/plugin-transform-runtime": "^7.0.0-beta.55",
"@babel/preset-env": "^7.0.0-beta.55",
"@babel/preset-react": "^7.0.0-beta.55",
"@babel/runtime": "^7.0.0-beta.55",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^6.0.4",
"babel-jest": "^22.4.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"baconjs": "^0.7.84",
"chalk": "^1.1.1",
"change-case": "^2.3.1",
Expand Down Expand Up @@ -73,7 +74,7 @@
"react-dom": "^16.3.1",
"readline-sync": "^1.2.21",
"rollup": "^0.62.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-babel": "^4.0.0-beta.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
Expand Down
17 changes: 11 additions & 6 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const input = `./${path.join(PACKAGES_SRC_DIR, packageName, 'index.js')}`

const outDir = path.join(PACKAGES_OUT_DIR, packageName, 'dist')

const isExternal = id => !id.startsWith('.') && !id.startsWith('/')
const isExternal = id =>
!id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/')

const getBabelOptions = () => ({
const getBabelOptions = ({ useESModules }) => ({
exclude: '**/node_modules/**',
runtimeHelpers: true,
plugins: [['@babel/transform-runtime', { useESModules, useBuiltIns: true }]],
})

const matchSnapshot = process.env.SNAPSHOT === 'match'
Expand All @@ -40,7 +42,7 @@ export default [
external: ['react'],
plugins: [
nodeResolve(),
babel(getBabelOptions()),
babel(getBabelOptions({ useESModules: true })),
commonjs(),
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),
sizeSnapshot({ matchSnapshot }),
Expand All @@ -60,7 +62,7 @@ export default [
external: ['react'],
plugins: [
nodeResolve(),
babel(getBabelOptions()),
babel(getBabelOptions({ useESModules: true })),
commonjs(),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
sizeSnapshot({ matchSnapshot }),
Expand All @@ -75,7 +77,7 @@ export default [
format: 'cjs',
},
external: isExternal,
plugins: [babel(getBabelOptions())],
plugins: [babel(getBabelOptions({ useESModules: false }))],
},

{
Expand All @@ -85,6 +87,9 @@ export default [
format: 'es',
},
external: isExternal,
plugins: [babel(getBabelOptions()), sizeSnapshot({ matchSnapshot })],
plugins: [
babel(getBabelOptions({ useESModules: true })),
sizeSnapshot({ matchSnapshot }),
],
},
]
2 changes: 1 addition & 1 deletion src/packages/recompose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "dist/Recompose.cjs.js",
"module": "dist/Recompose.esm.js",
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0-beta.55",
"change-emitter": "^0.1.2",
"fbjs": "^0.8.1",
"hoist-non-react-statics": "^2.3.1",
Expand Down
26 changes: 13 additions & 13 deletions src/packages/recompose/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# yarn lockfile v1


"@babel/runtime@^7.0.0-beta.55":
version "7.0.0-beta.55"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0-beta.55.tgz#0bc33aa5a6ac0b012f37e25b9e6aaa2e489a916b"
dependencies:
core-js "^2.5.7"
regenerator-runtime "^0.12.0"

asap@~2.0.3:
version "2.0.5"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"

babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"

change-emitter@^0.1.2:
version "0.1.6"
resolved "https://registry.yarnpkg.com/change-emitter/-/change-emitter-0.1.6.tgz#e8b2fe3d7f1ab7d69a32199aff91ea6931409515"
Expand All @@ -21,9 +21,9 @@ core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"

core-js@^2.4.0:
version "2.5.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.5.tgz#b14dde936c640c0579a6b50cabcc132dd6127e3b"
core-js@^2.5.7:
version "2.5.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"

encoding@^0.1.11:
version "0.1.12"
Expand Down Expand Up @@ -93,9 +93,9 @@ react-lifecycles-compat@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.2.tgz#7279047275bd727a912e25f734c0559527e84eff"

regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
regenerator-runtime@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.0.tgz#8052ac952d85b10f3425192cd0c53f45cf65c6cb"

setimmediate@^1.0.5:
version "1.0.5"
Expand Down
Loading