Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[added] Build step for compiling to CommonJS modules #417

Merged
merged 15 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ engines:
javascript:
ratings:
paths:
- lib/**
- src/**
- "**.js"
exclude_paths:
- "specs/"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ _book
*.diff
examples/__build__
coverage
yarn.lock

## Built folders
lib
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lib can't be ignored. You can remove es.

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ karma.conf.js
script
specs
.idea/
src
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ docs: build-docs

# Rules for build and publish

build:
compile:
@echo "[Compiling source]"
babel src --out-dir lib

build: compile
@echo "[Building dists]"
@./node_modules/.bin/webpack --config webpack.dist.config.js

Expand Down Expand Up @@ -120,5 +124,8 @@ publish-docs: deps-docs build-docs

publish-all: publish publish-docs

clean:
clean-sources:
@rm -rf lib/* dist/* _book

clean: clean-sources
@rm -rf .version .branch ./coverage/*
2 changes: 1 addition & 1 deletion examples/basic/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Modal from '../../lib/index';
import Modal from '../../src/index';

const appElement = document.getElementById('example');

Expand Down
2 changes: 0 additions & 2 deletions lib/index.js

This file was deleted.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
"scripts": {
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
"test": "cross-env NODE_ENV=test karma start",
"lint": "eslint lib/"
"lint": "eslint src/"
},
"authors": [
"Ryan Florence"
],
"license": "MIT",
"devDependencies": {
"babel-core": "^6.7.4",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"codeclimate-test-reporter": "^0.4.0",
"coveralls": "^2.13.1",
Expand Down Expand Up @@ -55,17 +56,14 @@
"react-addons-test-utils": "^15.0.0",
"react-dom": "^15.0.0",
"rf-release": "0.4.0",
"rimraf": "^2.5.4",
"sinon": "next",
"uglify-js": "2.4.24",
"webpack": "^1.12.14",
"webpack-dev-server": "1.11.0"
},
"dependencies": {
"create-react-class": "^15.5.2",
"element-class": "^0.2.0",
"exenv": "1.2.0",
"lodash.assign": "^4.2.0",
"prop-types": "^15.5.7",
"react-dom-factories": "^1.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion specs/Modal.events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Modal from '../lib/components/Modal';
import Modal from '../src/components/Modal';
import {
moverlay, mcontent,
clickAt, mouseDownAt, mouseUpAt, escKeyDown, tabKeyDown,
Expand Down
24 changes: 12 additions & 12 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import expect from 'expect';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import createReactClass from 'create-react-class';
import Modal from '../lib/components/Modal';
import * as ariaAppHider from '../lib/helpers/ariaAppHider';
import Modal from '../src/components/Modal';
import * as ariaAppHider from '../src/helpers/ariaAppHider';
import {
isBodyWithReactModalOpenClass,
contentAttribute,
Expand Down Expand Up @@ -57,7 +56,7 @@ describe('State', () => {

it('renders into the body, not in context', () => {
const node = document.createElement('div');
const App = createReactClass({
class App extends Component {
render() {
return (
<div>
Expand All @@ -67,7 +66,7 @@ describe('State', () => {
</div>
);
}
});
}
Modal.setAppElement(node);
ReactDOM.render(<App />, node);
expect(
Expand Down Expand Up @@ -357,22 +356,23 @@ describe('State', () => {
const node = document.createElement('div');
let modal = null;

const App = createReactClass({
getInitialState() {
return { testHasChanged: false };
},
class App extends Component {
constructor(props) {
super(props);
this.state = { testHasChanged: false };
}

componentDidMount() {
expect(modal.node.className).toEqual('myPortalClass');

this.setState({
testHasChanged: true
});
},
}

componentDidUpdate() {
expect(modal.node.className).toEqual('myPortalClass-modifier');
},
}

render() {
const portalClassName = this.state.testHasChanged === true ?
Expand All @@ -389,7 +389,7 @@ describe('State', () => {
</div>
);
}
});
}

Modal.setAppElement(node);
ReactDOM.render(<App />, node);
Expand Down
4 changes: 2 additions & 2 deletions specs/Modal.style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Modal from '../lib/components/Modal';
import * as ariaAppHider from '../lib/helpers/ariaAppHider';
import Modal from '../src/components/Modal';
import * as ariaAppHider from '../src/helpers/ariaAppHider';
import {
mcontent, moverlay,
renderModal, emptyDOM
Expand Down
2 changes: 1 addition & 1 deletion specs/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Modal from '../lib/components/Modal';
import Modal from '../src/components/Modal';
import TestUtils from 'react-addons-test-utils';

const divStack = [];
Expand Down
2 changes: 1 addition & 1 deletion specs/spec_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ testsContext.keys().forEach((path) => {
}
});

const componentsContext = require.context('../lib', true, /\.js$/);
const componentsContext = require.context('../src', true, /\.js$/);
componentsContext.keys().forEach((path) => {
try {
componentsContext(path);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Modal from './components/Modal';

export default Modal;
4 changes: 2 additions & 2 deletions webpack.dist.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var reactDOMExternal = {
module.exports = {

entry: {
'react-modal': './lib/index.js',
'react-modal.min': './lib/index.js'
'react-modal': './src/index.js',
'react-modal.min': './src/index.js'
},

externals: {
Expand Down
2 changes: 1 addition & 1 deletion webpack.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (process.env.CONTINUOUS_INTEGRATION || process.env.COVERAGE) {
commonConfig.module.postLoaders = commonConfig.module.postLoaders || [];
commonConfig.module.postLoaders.push({
test: /\.js$/,
include: path.resolve('lib'),
include: path.resolve('src'),
loader: 'istanbul-instrumenter'
});
}
Expand Down
Loading