Skip to content

Commit

Permalink
New UMD configuration. Required correct peer React version. (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
suevalov authored Dec 4, 2018
1 parent d25904c commit a0eb187
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 492 deletions.
5 changes: 0 additions & 5 deletions packages/forma-36-react-components/.size-limit
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"react-dom"
]
},
{
"path": "dist/index.umd.js",
"name": "gzipped UMD js",
"limit": "100 KB"
},
{
"path": "dist/styles.css",
"name": "gzipped css",
Expand Down
13 changes: 8 additions & 5 deletions packages/forma-36-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"babel-plugin-css-modules-transform": "^1.6.2",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-inline-react-svg": "^1.0.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.21",
"css-loader": "^1.0.1",
"cz-conventional-changelog": "^2.1.0",
"enzyme": "^3.7.0",
Expand Down Expand Up @@ -66,14 +67,16 @@
"postcss-url": "^8.0.0",
"prettier": "^1.11.1",
"pretty-quick": "^1.4.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-test-renderer": "^16.2.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-test-renderer": "^16.6.3",
"rollup": "^0.67.0",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^3.0.0",
"semantic-release": "^15.1.4",
"sinon": "^6.1.4",
"size-limit": "^0.21.0",
Expand All @@ -95,8 +98,8 @@
"truncate": "^2.0.1"
},
"peerDependencies": {
"react": "^15.3.0 || ^16.0.0",
"react-dom": "^15.3.0 || ^16.0.0"
"react": "^16.3.0",
"react-dom": "^16.3.0"
},
"scripts": {
"start": "start-storybook -p 9001 -c ./tools/.storybook",
Expand Down
66 changes: 43 additions & 23 deletions packages/forma-36-react-components/tools/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,51 @@ import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import localResolve from 'rollup-plugin-local-resolve';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import path from 'path';

const config = {
input: path.resolve(__dirname, '../dist/index.js'),
output: [
{
file: path.resolve(__dirname, '../dist', 'index.umd.js'),
globals: {
react: 'React',
'react-dom': 'ReactDOM',
function getConfig(environment) {
return {
input: path.resolve(__dirname, '../dist/index.js'),
output: [
{
file: path.resolve(
__dirname,
'../dist',
'umd',
`forma-36-react-components.${environment}.min.js`,
),
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
format: 'umd',
name: 'Forma36',
exports: 'named',
},
format: 'umd',
name: 'UIComponentLibrary',
exports: 'named',
},
],
external: ['react', 'react-dom'],
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
localResolve(),
resolve(),
commonjs(),
],
};
],
external: ['react', 'react-dom'],
plugins: [
environment === 'production'
? babel({
babelrc: false,
plugins: [
require.resolve('babel-plugin-transform-react-remove-prop-types'),
],
})
: null,
replace({
'process.env.NODE_ENV': JSON.stringify(environment),
}),
localResolve(),
resolve(),
commonjs(),
terser(),
].filter(_ => _),
};
}

const config = [getConfig('development'), getConfig('production')];

export default config;
Loading

0 comments on commit a0eb187

Please sign in to comment.