Skip to content

Commit

Permalink
Added module entry point - refactored build process, removed grunt in…
Browse files Browse the repository at this point in the history
… favor of npm scripts (Hacker0x01#1115)
  • Loading branch information
Andarist authored and martijnrusschen committed Nov 4, 2017
1 parent ebc6109 commit d28aa97
Show file tree
Hide file tree
Showing 17 changed files with 1,300 additions and 1,130 deletions.
17 changes: 1 addition & 16 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"development": {
"plugins": [
"transform-class-properties",
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}]
}],
"add-react-displayname"
]
}
}
"presets": ["./.babelrc.js"]
}
29 changes: 29 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var NODE_ENV = process.env.NODE_ENV
var MODULES = process.env.MODULES

var modules = MODULES === 'false' || NODE_ENV === 'test' ? 'commonjs' : false

var config = {
presets: [['env', {
loose: true,
modules: modules,
forceAllTransforms: NODE_ENV === 'production'
}], 'stage-0', 'react'],
plugins: []
}

if (NODE_ENV === 'development') {
config.plugins = config.plugins.concat([
'transform-class-properties',
['react-transform', {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}]
}],
'add-react-displayname'
])
}

module.exports = config
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ npm-debug.log
.vscode
dist
lib
es
tmp
coverage
docs-site/bundle.js
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ addons:
packages:
- g++-4.8
before_install:
- npm install -g grunt-cli
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- yarn test
- yarn check
after_success:
- yarn run codecov
notifications:
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies:

test:
override:
- yarn test
- yarn check
147 changes: 0 additions & 147 deletions gruntfile.js

This file was deleted.

49 changes: 32 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"version": "0.59.0",
"license": "MIT",
"homepage": "https://github.com/Hacker0x01/react-datepicker",
"main": "lib/datepicker",
"main": "lib",
"module": "es",
"unpkg": "dist/react-datepicker.min.js",
"style": "dist/react-datepicker.min.css",
"files": [
"*.md",
"dist",
"lib",
"es",
"src/stylesheets"
],
"keywords": [
Expand All @@ -33,11 +35,12 @@
"babel-eslint": "^7.2.2",
"babel-loader": "^6.2.10",
"babel-plugin-add-react-displayname": "^0.0.4",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-react-remove-prop-types": "0.3.2",
"babel-preset-airbnb": "^2.2.3",
"babel-preset-es2015": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.22.0",
"chai": "^3.5.0",
Expand All @@ -52,15 +55,6 @@
"eslint-plugin-standard": "^2.0.1",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^1.0.1",
"grunt": "1.0.1",
"grunt-babel": "^6.0.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-watch": "1.0.0",
"grunt-eslint": "^19.0.0",
"grunt-karma": "^2.0.0",
"grunt-sass": "2.0.0",
"grunt-sass-lint": "^0.2.2",
"grunt-webpack": "^1.0.11",
"highlight.js": "^9.9.0",
"isparta-loader": "^2.0.0",
"karma": "^1.4.1",
Expand All @@ -73,13 +67,21 @@
"karma-webpack": "^1.8.1",
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"node-sass": "^4.5.0",
"node-sass": "^4.5.3",
"npm-run-all": "^4.1.1",
"react": "^15.5.4",
"react-addons-test-utils": "^15.5.1",
"react-docgen": "^2.19.0",
"react-dom": "^15.5.4",
"react-test-renderer": "^15.5.4",
"react-transform-hmr": "^1.0.4",
"rimraf": "^2.6.2",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"sass-lint": "^1.12.1",
"sass-loader": "^4.1.1",
"sinon": "^2.3.2",
"style-loader": "^0.13.1",
Expand All @@ -100,11 +102,24 @@
"react-popper": "^0.7.4"
},
"scripts": {
"build": "cross-env NODE_ENV=production grunt build",
"start": "node server.js",
"test": "cross-env NODE_ENV=test grunt travis",
"eslint": "eslint **/*.jsx",
"start": "cross-env MODULES=false node server.js",
"test": "cross-env NODE_ENV=test karma start karma.conf.js --single-run",
"eslint": "eslint {src,test,docs-site/src}/**/*.{js,jsx} *.js",
"sass-lint": "sass-lint --config .sass-lint.yml 'src/stylesheets/*.scss, docs-site/src/*.scss' -i 'docs-site/src/higlight.scss, docs-site/src/reset.scss'",
"lint": "run-p eslint sass-lint",
"check": "npm run lint && npm run test",
"prepublish": "npm run build",
"codecov": "cat coverage/*/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js"
"prepare": "npm run build",
"codecov": "cat coverage/*/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js",
"prebuild": "rimraf es lib dist",
"build": "run-p build:** && run-p css:**",
"css:prod": "node-sass --output-style compressed src/stylesheets/datepicker.scss > dist/datepicker.min.css",
"css:modules:prod": "node-sass --output-style compressed src/stylesheets/datepicker-cssmodules.scss > dist/datepicker-cssmodules.min.css",
"css:dev": "node-sass --output-style expanded src/stylesheets/datepicker.scss > dist/datepicker.css",
"css:modules:dev": "node-sass --output-style expanded src/stylesheets/datepicker-cssmodules.scss > dist/datepicker-cssmodules.css",
"build:es": "cross-env BABEL_ENV=es rollup -c -i src/index.jsx -o es/index.js",
"build:cjs": "cross-env BABEL_ENV=cjs rollup -c -i src/index.jsx -o lib/index.js",
"build:umd:prod": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c rollup.umd.config.js -i src/index.jsx -o dist/react-datepicker.min.js",
"build:umd:dev": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c rollup.umd.config.js -i src/index.jsx -o dist/react-datepicker.js"
}
}
26 changes: 26 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import { list as babelHelpersList } from 'babel-helpers'
import pkg from './package.json'

const config = {
output: {
format: process.env.BABEL_ENV
},
plugins: [
nodeResolve({
jsnext: true,
extensions: ['.js', '.jsx']
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
externalHelpersWhitelist: babelHelpersList.filter(helperName => helperName !== 'asyncGenerator')
}),
commonjs()
],
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies))
}

export default config
34 changes: 34 additions & 0 deletions rollup.umd.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import config from './rollup.config.js'
import uglify from 'rollup-plugin-uglify'

const env = process.env.NODE_ENV

const umdConfig = Object.assign({}, config, {
output: Object.assign({}, config.output, {
format: 'umd',
name: 'DatePicker'
}),
globals: {
react: 'React',
'prop-types': 'PropTypes',
'react-onclickoutside': 'onClickOutside',
'react-popper': 'ReactPopper',
'moment': 'moment',
'classnames': 'classNames'
}
})

if (env === 'production') {
config.plugins.push(
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
}
})
)
}

export default umdConfig
File renamed without changes.
2 changes: 1 addition & 1 deletion test/datepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'
import TestUtils from 'react-addons-test-utils'
import { mount, ReactWrapper } from 'enzyme'
import defer from 'lodash/defer'
import DatePicker from '../src/datepicker.jsx'
import DatePicker from '../src/index.jsx'
import Day from '../src/day'
import TestWrapper from './test_wrapper.jsx'
import PopperComponent from '../src/popper_component.jsx'
Expand Down
Loading

0 comments on commit d28aa97

Please sign in to comment.