Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit e1c6aa2

Browse files
committed
Merge pull request react-bootstrap#621 from react-bootstrap/babelrc
Use .babelrc for babel configuration
2 parents 480944b + 62f536e commit e1c6aa2

16 files changed

Lines changed: 62 additions & 74 deletions

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"optional": [
3+
"es7.objectRestSpread"
4+
]
5+
}

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint no-var: 0 */
2-
require('./register-babel');
2+
require('babel/register');
33

44
var webpackConfig = require('./webpack/test.config.js');
55
var isCI = process.env.CONTINUOUS_INTEGRATION === 'true';
@@ -46,7 +46,7 @@ module.exports = function (config) {
4646
browsers: [ isCI ? 'PhantomJS' : 'Chrome' ],
4747

4848
captureTimeout: 60000,
49-
browserNoActivityTimeout: 30000,
49+
browserNoActivityTimeout: 45000,
5050

5151
singleRun: isCI
5252
});

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
},
99
"homepage": "http://react-bootstrap.github.io/",
1010
"scripts": {
11-
"build": "node run-babel tools/build.js",
11+
"build": "babel-node tools/build-cli.js",
1212
"test-watch": "karma start",
1313
"test": "npm run lint && npm run build && karma start --single-run",
1414
"lint": "eslint src test docs ie8 tools webpack karma.conf.js webpack.config.js webpack.docs.js",
15-
"docs-build": "node run-babel tools/build.js --docs-only",
16-
"docs": "node run-babel docs/server.js",
17-
"docs-prod": "webpack --config webpack.docs.js -p --progress && NODE_ENV=production node run-babel docs/server.js",
18-
"ie8": "node run-babel ie8/server.js"
15+
"docs-build": "babel-node tools/build-cli.js --docs-only",
16+
"docs": "babel-node docs/server.js",
17+
"docs-prod": "webpack --config webpack.docs.js -p --progress && NODE_ENV=production babel-node docs/server.js",
18+
"ie8": "babel-node ie8/server.js"
1919
},
2020
"main": "lib/index.js",
2121
"directories": {

register-babel.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

run-babel

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/amd/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const bowerJson = path.join(bowerRoot, 'bower.json');
1313
const readme = path.join(__dirname, 'README.md');
1414
const license = path.join(repoRoot, 'LICENSE');
1515

16-
const babelOptions = '--modules amd --optional es7.objectRestSpread';
16+
const babelOptions = '--modules amd';
1717

1818
const factoriesDestination = path.join(bowerRoot, 'factories');
1919

@@ -35,7 +35,7 @@ export default function BuildBower() {
3535
.then(() => fsp.mkdirs(factoriesDestination))
3636
.then(() => Promise.all([
3737
bowerConfig(),
38-
generateFactories(babelOptions, factoriesDestination),
38+
generateFactories(factoriesDestination, babelOptions),
3939
exec(`babel ${babelOptions} ${srcRoot} --out-dir ${bowerRoot}`),
4040
copy(readme, bowerRoot),
4141
copy(license, bowerRoot)

tools/build-cli.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint no-process-exit: 0 */
2+
3+
import 'colors';
4+
import build from './build';
5+
import docs from '../docs/build';
6+
import { setExecOptions } from './exec';
7+
8+
import yargs from 'yargs';
9+
10+
const argv = yargs
11+
.option('docs-only', {
12+
demand: false,
13+
default: false
14+
})
15+
.option('verbose', {
16+
demand: false,
17+
default: false,
18+
describe: 'Increased debug output'
19+
})
20+
.argv;
21+
22+
setExecOptions(argv);
23+
24+
let buildProcess = argv.docsOnly ? docs() : build();
25+
26+
buildProcess
27+
.catch(err => {
28+
console.error(err.toString().red);
29+
if (err.stack) {
30+
console.error(err.stack.red);
31+
}
32+
process.exit(1);
33+
});

tools/build.js

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,26 @@
1-
/* eslint no-process-exit: 0 */
2-
31
import 'colors';
42
import bower from './amd/build';
53
import lib from './lib/build';
6-
import docs from '../docs/build';
74
import dist from './dist/build';
85
import { copy } from './fs-utils';
96
import { distRoot, bowerRoot } from './constants';
10-
import { exec, setExecOptions } from './exec';
11-
12-
import yargs from 'yargs';
13-
14-
const argv = yargs
15-
.option('docs-only', {
16-
demand: false,
17-
default: false
18-
})
19-
.option('verbose', {
20-
demand: false,
21-
default: false,
22-
describe: 'Increased debug output'
23-
})
24-
.argv;
7+
import { exec } from './exec';
258

26-
setExecOptions(argv);
27-
28-
function forkAndBuildDocs(fork) {
9+
function forkAndBuildDocs(verbose) {
2910
console.log('Building: '.cyan + 'docs'.green);
3011

31-
let options = argv.verbose ? ' -- --verbose' : '';
12+
let options = verbose ? ' -- --verbose' : '';
3213

3314
return exec(`npm run docs-build${options}`)
3415
.then(() => console.log('Built: '.cyan + 'docs'.green));
3516
}
3617

37-
export default function Build(noExitOnFailure) {
38-
if (argv.docsOnly) {
39-
return docs();
40-
} else {
41-
let result = Promise.all([
18+
export default function Build(verbose) {
19+
return Promise.all([
4220
lib(),
4321
bower(),
4422
dist(),
45-
forkAndBuildDocs()
23+
forkAndBuildDocs(verbose)
4624
])
4725
.then(() => copy(distRoot, bowerRoot));
48-
49-
if (!noExitOnFailure) {
50-
result = result
51-
.catch(err => {
52-
console.error(err.toString().red);
53-
if (err.stack) {
54-
console.error(err.stack.red);
55-
}
56-
process.exit(1);
57-
});
58-
}
59-
60-
return result;
61-
}
6226
}

tools/generateFactories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const templatePath = path.join(srcRoot, 'templates');
99
const factoryTemplatePath = path.join(templatePath, 'factory.js.template');
1010
const indexTemplatePath = path.join(templatePath, 'factory.index.js.template');
1111

12-
export default function generateFactories(babelOptions, destination) {
12+
export default function generateFactories(destination, babelOptions='') {
1313

1414
let generateCompiledFile = function (file, content) {
1515
let outpath = path.join(destination, `${file}.js`);

tools/lib/build.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ import { srcRoot, libRoot } from '../constants';
66
import generateFactories from '../generateFactories';
77

88
const factoryDestination = path.join(libRoot, 'factories');
9-
const babelOptions = '--optional es7.objectRestSpread';
109

1110
export default function BuildCommonJs() {
1211
console.log('Building: '.cyan + 'npm module'.green);
1312

1413
return exec(`rimraf ${libRoot}`)
1514
.then(() => fsp.mkdirs(factoryDestination))
1615
.then(() => Promise.all([
17-
generateFactories(babelOptions, factoryDestination),
18-
exec(`babel ${babelOptions} ${srcRoot} --out-dir ${libRoot}`)
16+
generateFactories(factoryDestination),
17+
exec(`babel ${srcRoot} --out-dir ${libRoot}`)
1918
]))
2019
.then(() => console.log('Built: '.cyan + 'npm module'.green));
2120
}

0 commit comments

Comments
 (0)