Skip to content

Commit

Permalink
feat(build): upgrade rollup & add esm build
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte authored and Raphaël Benitte committed Mar 21, 2019
1 parent 670d22d commit f6d6480
Show file tree
Hide file tree
Showing 55 changed files with 262 additions and 670 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ package-lock.json

build

/packages/*/cjs
/packages/*/umd
/packages/*/dist

*.lerna_backup

18 changes: 15 additions & 3 deletions conf/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ const commonPlugins = [
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
externalHelpers: true,
presets: [
'@nivo/babel-preset'
]
}),
]

export default [
{
...common,
output: {
file: `./packages/${pkg}/cjs/nivo-${pkg}.js`,
file: `./packages/${pkg}/dist/nivo-${pkg}.cjs.js`,
format: 'cjs',
name: `@nivo/${pkg}`,
},
Expand All @@ -60,7 +63,16 @@ export default [
{
...common,
output: {
file: `./packages/${pkg}/umd/nivo-${pkg}.js`,
file: `./packages/${pkg}/dist/nivo-${pkg}.esm.js`,
format: 'esm',
name: `@nivo/${pkg}`,
},
plugins: commonPlugins,
},
{
...common,
output: {
file: `./packages/${pkg}/dist/nivo-${pkg}.umd.js`,
format: 'umd',
extend: true,
name: 'nivo',
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@babel/core": "^7.4.0",
"@ekino/config": "^0.3.0",
"@nivo/babel-preset": "^0.32.0-9",
"@nivo/babel-preset": "^0.52.0",
"@nivo/generators": "^0.48.0",
"@storybook/addon-actions": "^5.0.3",
"@storybook/addon-info": "^5.0.3",
Expand Down Expand Up @@ -51,10 +51,10 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-test-renderer": "^16.4.2",
"rollup": "^0.64.1",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-prettier": "^0.4.0",
"rollup": "^1.7.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-prettier": "^0.6.0",
"rollup-plugin-strip-banner": "^0.2.0",
"serve": "^10.1.1",
"tslint": "^5.11.0",
Expand Down
1 change: 0 additions & 1 deletion packages/axes/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/axes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
"react",
"axes"
],
"main": "./index.js",
"main": "./dist/nivo-axes.cjs.js",
"module": "./dist/nivo-axes.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/core": "0.52.1",
Expand Down
120 changes: 49 additions & 71 deletions packages/babel-preset/index.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,58 @@
'use strict'

const plugins = [
[
require.resolve('babel-plugin-transform-es2015-template-literals'),
{
loose: true,
},
],
require.resolve('babel-plugin-transform-es2015-literals'),
require.resolve('babel-plugin-transform-es2015-function-name'),
require.resolve('babel-plugin-transform-es2015-arrow-functions'),
require.resolve('babel-plugin-transform-es2015-block-scoped-functions'),
require.resolve('babel-plugin-transform-class-properties'),
[
require.resolve('babel-plugin-transform-es2015-classes'),
{
loose: true,
},
],
require.resolve('babel-plugin-transform-es2015-object-super'),
require.resolve('babel-plugin-transform-es2015-shorthand-properties'),
[
require.resolve('babel-plugin-transform-es2015-computed-properties'),
{
loose: true,
},
],
require.resolve('babel-plugin-check-es2015-constants'),
[
require.resolve('babel-plugin-transform-es2015-spread'),
{
loose: true,
},
],
require.resolve('babel-plugin-transform-es2015-parameters'),
[
require.resolve('babel-plugin-transform-es2015-destructuring'),
{
loose: true,
},
],
require.resolve('babel-plugin-transform-es2015-block-scoping'),
require.resolve('babel-plugin-transform-object-rest-spread'),
require.resolve('babel-plugin-transform-react-jsx'),
require.resolve('babel-plugin-syntax-jsx'),
]

const env = process.env.BABEL_ENV || process.env.NODE_ENV

if (env === 'commonjs') {
plugins.push.apply(plugins, [
module.exports = () => {
const presets = [
[
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
{
loose: true,
},
`@babel/env`,
{}
],
])
}

if (env === 'es') {
plugins.push.apply(plugins, [require.resolve('./use-lodash-es')])
}
[
`@babel/react`,
{}
]
]

if (env === 'test') {
plugins.push.apply(plugins, [
require.resolve('babel-plugin-istanbul'),
const plugins = [
`@babel/proposal-class-properties`,
[
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
`lodash`,
{
loose: true,
},
],
])
}
id: ['lodash', 'recompose']
}
]
]

const env = process.env.BABEL_ENV || process.env.NODE_ENV

if (env === 'commonjs') {
plugins.push.apply(plugins, [
[
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
{
loose: true,
},
],
])
}

if (env === 'es') {
plugins.push.apply(plugins, [require.resolve('./use-lodash-es')])
}

if (env === 'test') {
plugins.push.apply(plugins, [
require.resolve('babel-plugin-istanbul'),
[
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
{
loose: true,
},
],
])
}

module.exports = {
plugins,
return {
presets,
plugins
}
}
27 changes: 3 additions & 24 deletions packages/babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,9 @@
},
"license": "MIT",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-jest": "^20.0.3",
"babel-plugin-check-es2015-constants": "^6.22.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-function-name": "^6.24.1",
"babel-plugin-transform-es2015-literals": "^6.22.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-es2015-object-super": "^6.24.1",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1"
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/preset-env": "^7.4.1",
"babel-plugin-lodash": "^3.3.4"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion packages/bar/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"charts",
"bar-chart"
],
"main": "./index.js",
"main": "./dist/nivo-bar.cjs.js",
"module": "./dist/nivo-bar.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/axes": "0.52.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/bar/src/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import compose from 'recompose/compose'
import { compose } from 'recompose'
import defaultProps from 'recompose/defaultProps'
import withPropsOnChange from 'recompose/withPropsOnChange'
import pure from 'recompose/pure'
Expand Down
1 change: 0 additions & 1 deletion packages/bullet/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/bullet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"charts",
"bullet-chart"
],
"main": "./index.js",
"main": "./dist/nivo-bullet.cjs.js",
"module": "./dist/nivo-bullet.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/core": "0.52.1",
Expand Down
1 change: 0 additions & 1 deletion packages/calendar/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"charts",
"calendar"
],
"main": "./index.js",
"main": "./dist/nivo-calendar.cjs.js",
"module": "./dist/nivo-calendar.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/core": "0.52.1",
Expand Down
1 change: 0 additions & 1 deletion packages/chord/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/chord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
"charts",
"chord-diagram"
],
"main": "./index.js",
"main": "./dist/nivo-chord.cjs.js",
"module": "./dist/nivo-chord.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/core": "0.52.1",
Expand Down
1 change: 0 additions & 1 deletion packages/circle-packing/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/circle-packing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
"charts",
"circle-packing"
],
"main": "./index.js",
"main": "./dist/nivo-circle-packing.cjs.js",
"module": "./dist/nivo-circle-packing.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"@nivo/core": "0.52.1",
Expand Down
1 change: 0 additions & 1 deletion packages/core/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
"name": "Raphaël Benitte",
"url": "https://github.com/plouc"
},
"main": "./index.js",
"main": "./dist/nivo-core.cjs.js",
"module": "./dist/nivo-core.esm.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
"dist/"
],
"dependencies": {
"d3-color": "^1.0.3",
Expand Down
1 change: 0 additions & 1 deletion packages/generators/index.js

This file was deleted.

Loading

0 comments on commit f6d6480

Please sign in to comment.