Skip to content

Commit

Permalink
build(bundler): introduced rollup to do an ES6 modules build
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcabrera committed Jul 17, 2017
1 parent 2ed9127 commit eb485e4
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 27 deletions.
14 changes: 11 additions & 3 deletions enriched/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "telus-thorium-enriched",
"version": "0.18.1",
"main": "lib/index.js",
"main": "dist/tds.cjs.js",
"module": "dist/tds.es.js",
"scripts": {
"start": "npm run deploy && npm run dev",
"clean": "rimraf lib && rimraf dist && mkdirp lib && mkdirp dist",
Expand All @@ -14,7 +15,8 @@
"build:umd:min": "webpack -p --config webpack.config.umd.min.js",
"build": "npm run clean && npm run build:lib && npm run build:umd && npm run build:umd:min",
"test": "jest",
"test:watch": "npm run test -- --watch"
"test:watch": "npm run test -- --watch",
"rollup": "rollup -c"
},
"dependencies": {
"@telusdigital/redux-contentful": "^2.2.1",
Expand All @@ -33,6 +35,7 @@
"babel-core": "^6.17.0",
"babel-jest": "^16.0.0",
"babel-loader": "^6.2.5",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.17.0",
Expand Down Expand Up @@ -67,6 +70,11 @@
"react-dom": "^15.3.2",
"react-test-renderer": "^15.3.2",
"rimraf": "^2.5.4",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-sass": "^0.5.3",
"sass-loader": "^3.1.1",
"sinon": "^2.3.6",
"style-loader": "^0.12.3",
Expand Down Expand Up @@ -96,4 +104,4 @@
},
"setupTestFrameworkScriptFile": "<rootDir>/../node_modules/jest-enzyme/lib/index.js"
}
}
}
38 changes: 38 additions & 0 deletions enriched/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import path from 'path';

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import sass from 'rollup-plugin-sass';

export default {
entry: path.resolve('./src/rollup-main.js'),
targets: [
{ format: 'cjs', dest: path.resolve('./dist/tds.cjs.js') },
{ format: 'es', dest: path.resolve('./dist/tds.es.js') }
],
sourceMap: true,

external: ['react', 'prop-types'],
plugins: [
resolve({
extensions: ['.js', '.jsx']
}),
commonjs({
include: 'node_modules/**'
}),
sass({
output: path.resolve('./dist/tds.css')
}),
babel({
babelrc: false,
presets: [
['es2015', { modules: false }],
'react',
'stage-2'
],
plugins: ['external-helpers'],
exclude: 'node_modules/**'
})
]
};
4 changes: 1 addition & 3 deletions enriched/src/components/Card/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import classNames from 'classnames';

import { warn } from '../../deprecate';

if (process.env.BROWSER) {
require('./Card.scss');
}
import './Card.scss';

const Card = ({ className, children, ...rest }) => {
if (className) {
Expand Down
2 changes: 1 addition & 1 deletion enriched/src/components/Card/Card.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~telus-thorium-core/scss/settings/variables';
@import '../../../../core/scss/settings/variables';

.card {
border: 0;
Expand Down
4 changes: 1 addition & 3 deletions enriched/src/components/ExpandCollapse/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

if (process.env.BROWSER) {
require('./Panel.scss');
}
import './Panel.scss';

class Panel extends Component {

Expand Down
4 changes: 2 additions & 2 deletions enriched/src/components/ExpandCollapse/Panel.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '~telus-thorium-core/scss/settings/variables';
@import '~telus-thorium-core/scss/utility/mixins';
@import '../../../../core/scss/settings/variables';
@import '../../../../core/scss/utility/mixins';


.icon-core-caret-up {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { mount } from 'enzyme';
import ExpandCollapse from '../';
import ExpandCollapse from '../ExpandCollapse';

const { Group, Panel } = ExpandCollapse;

describe('<ExpandCollaps e/>', () => {
describe('<ExpandCollapse/>', () => {
it('handles disabled panels', () => {
const wrapper = mount(
<Group disabledKeys={['p1']}>
Expand Down
2 changes: 1 addition & 1 deletion enriched/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SelectorCounter from './components/SelectorCounter';
import Icon from './components/Icon';
import * as Grid from './components/Grid';
import ExpandCollapse from './components/ExpandCollapse';
import ExpandCollapse from './components/ExpandCollapse/ExpandCollapse';
import Card from './components/Card/Card';
import Notification from './components/Notification/Notification';
import Steps from './components/Steps';
Expand Down
2 changes: 2 additions & 0 deletions enriched/src/rollup-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Card } from './components/Card/Card';
export { default as ExpandCollapse } from './components/ExpandCollapse/ExpandCollapse';
Loading

0 comments on commit eb485e4

Please sign in to comment.