Skip to content

Commit 9cb8441

Browse files
Update bundling scheme (#347)
* Update bundling scheme This commit sets things up to work properly when publishing to npm. Prior to publishing the package items from the src/ folder will be processed with Babel and stored in the lib/ folder. The lib/ folder will not be present in the repository. The src/ folder similarly will not be available when looking at the installed package. In addition this commit also fixes #332 by adding the `babel-plugin-transform-object-assign` plugin and removing `lodash.assign` * Update linting dependencies This temporarily disables react/require-default-props until it can be addressed in a separate commit. * Make sure tests run using the proper source
1 parent 37a6ceb commit 9cb8441

File tree

16 files changed

+954
-981
lines changed

16 files changed

+954
-981
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["react", "latest", "stage-2"]
2+
"presets": ["react", "latest", "stage-2"],
3+
"plugins": ["babel-plugin-transform-object-assign"]
34
}

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
"no-plusplus": [0],
2121
"space-before-function-paren": [2, "always"],
2222
"import/no-extraneous-dependencies": [2, {"devDependencies": true}],
23-
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}]
23+
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}],
24+
"react/require-default-props": [0]
2425
},
2526
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
.idea/
44
_book
55
coverage
6+
lib

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ karma.conf.js
55
script
66
specs
77
.idea/
8+
src

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,31 @@
2323
"docs:build": "gitbook build -g reactjs/react-modal",
2424
"docs:build:watch": "gitbook serve",
2525
"docs:publish": "cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push [email protected]:reactjs/react-modal gh-pages --force",
26-
"lint": "eslint lib/ specs/"
26+
"lint": "eslint src/ specs/",
27+
"prepublish": "babel src -d lib"
2728
},
2829
"authors": [
2930
"Ryan Florence"
3031
],
3132
"license": "MIT",
3233
"devDependencies": {
34+
"babel-cli": "^6.23.0",
3335
"babel-core": "^6.7.4",
3436
"babel-eslint": "^7.1.1",
3537
"babel-loader": "^6.2.4",
38+
"babel-plugin-transform-object-assign": "^6.22.0",
3639
"babel-preset-es2015": "^6.6.0",
3740
"babel-preset-latest": "^6.16.0",
3841
"babel-preset-react": "^6.5.0",
3942
"babel-preset-stage-2": "^6.18.0",
4043
"codeclimate-test-reporter": "^0.4.0",
4144
"coveralls": "^2.11.15",
4245
"envify": "^3.4.1",
43-
"eslint": "^3.9.1",
44-
"eslint-config-airbnb": "latest",
45-
"eslint-plugin-import": "^2.1.0",
46-
"eslint-plugin-jsx-a11y": "^2.2.3",
47-
"eslint-plugin-react": "^6.6.0",
46+
"eslint": "^3.15.0",
47+
"eslint-config-airbnb": "^14.1.0",
48+
"eslint-plugin-import": "^2.2.0",
49+
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
50+
"eslint-plugin-react": "^6.9.0",
4851
"expect": "1.10.0",
4952
"gitbook-cli": "^2.3.0",
5053
"istanbul-instrumenter-loader": "0.2.0",
@@ -72,8 +75,7 @@
7275
},
7376
"dependencies": {
7477
"element-class": "^0.2.0",
75-
"exenv": "1.2.0",
76-
"lodash.assign": "^4.2.0"
78+
"exenv": "1.2.0"
7779
},
7880
"peerDependencies": {
7981
"react": "^0.14.0 || ^15.0.0",

specs/Modal.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import React from 'react';
1010
import sinon from 'sinon';
1111
import expect from 'expect';
1212
import ReactDOM from 'react-dom';
13-
import Modal from '../lib/components/Modal';
14-
import * as ariaAppHider from '../lib/helpers/ariaAppHider';
13+
import Modal from '../src/components/Modal';
14+
import * as ariaAppHider from '../src/helpers/ariaAppHider';
1515
import { renderModal, unmountModal, emptyDOM } from './helper';
1616

1717
const Simulate = TestUtils.Simulate;

specs/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* eslint react/no-render-return-value: "warn" */
44
import React from 'react';
55
import ReactDOM from 'react-dom';
6-
import Modal from '../lib/components/Modal';
6+
import Modal from '../src/components/Modal';
77

88
const divStack = [];
99

specs/spec_index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ testsContext.keys().forEach((path) => {
88
}
99
});
1010

11-
const componentsContext = require.context('../lib', true, /\.js$/);
11+
const componentsContext = require.context('../src', true, /\.js$/);
1212
componentsContext.keys().forEach((path) => {
1313
try {
1414
componentsContext(path);
File renamed without changes.

lib/components/ModalPortal.js renamed to src/components/ModalPortal.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { Component, PropTypes } from 'react';
2-
import Assign from 'lodash.assign';
32
import scopeTab from '../helpers/scopeTab';
43
import {
54
returnFocus,
@@ -211,12 +210,12 @@ export default class ModalPortal extends Component {
211210
<div
212211
ref={(c) => { this.overlay = c; }}
213212
className={this.buildClassName('overlay', this.props.overlayClassName)}
214-
style={Assign({}, overlayStyles, this.props.style.overlay || {})}
213+
style={Object.assign({}, overlayStyles, this.props.style.overlay || {})}
215214
onClick={this.handleOverlayOnClick}
216215
>
217216
<div
218217
ref={(c) => { this.content = c; }}
219-
style={Assign({}, contentStyles, this.props.style.content || {})}
218+
style={Object.assign({}, contentStyles, this.props.style.content || {})}
220219
className={this.buildClassName('content', this.props.className)}
221220
tabIndex={-1}
222221
onKeyDown={this.handleKeyDown}

0 commit comments

Comments
 (0)