Skip to content

Commit 321852e

Browse files
committed
Merge branch 'release/6.0.0'
* release/6.0.0: Add @malyw 's guide to upgrade babel Update travis badge url Update dependencies. Change options to query. Increase timeout interval README updated Upgraded to Babel 6 set up Travis CI
2 parents 5992650 + e7565ee commit 321852e

9 files changed

+71
-50
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- stable
4+
- '0'
5+
- '0.10'

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# babel-loader
1+
# babel-loader [![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader)
22
> Babel is a compiler for writing next generation JavaScript.
33
44
This package allows transpiling JavaScript files using [Babel](https://github.com/babel/babel) and [webpack](https://github.com/webpack/webpack).
@@ -8,11 +8,13 @@
88
## Installation
99

1010
```bash
11-
npm install babel-loader --save-dev
11+
npm install babel-loader babel-core babel-preset-es2015 --save-dev
1212
```
1313

1414
__Note:__ [npm](https://npmjs.com) will deprecate [auto-installing of peerDependencies](https://github.com/npm/npm/issues/6565) on the next major release, so required peer dependencies like babel-core and webpack will have to be listed explicitly in your `package.json`.
1515

16+
__Note:__ If you're upgrading from babel 5 to babel 6, please take a look [at this guide](https://medium.com/@malyw/how-to-update-babel-5-x-6-x-d828c230ec53#.yqxukuzdk).
17+
1618
## Usage
1719

1820
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
@@ -35,15 +37,15 @@ module: {
3537

3638
See the `babel` [options](http://babeljs.io/docs/usage/options/).
3739

38-
You can pass options to the loader by writting them as a [query string](https://github.com/webpack/loader-utils):
40+
You can pass options to the loader by writing them as a [query string](https://github.com/webpack/loader-utils):
3941

4042
```javascript
4143
module: {
4244
loaders: [
4345
{
4446
test: /\.jsx?$/,
4547
exclude: /(node_modules|bower_components)/,
46-
loader: 'babel?optional[]=runtime&stage=0'
48+
loader: 'babel?presets[]=es2015'
4749
}
4850
]
4951
}
@@ -59,8 +61,7 @@ module: {
5961
exclude: /(node_modules|bower_components)/,
6062
loader: 'babel',
6163
query: {
62-
optional: ['runtime'],
63-
stage: 0
64+
presets: ['es2015']
6465
}
6566
}
6667
]
@@ -107,7 +108,7 @@ loaders: [
107108
{
108109
test: /\.jsx?$/,
109110
exclude: /(node_modules|bower_components)/,
110-
loader: 'babel?optional[]=runtime'
111+
loader: 'babel?presets[]=es2015'
111112
}
112113
]
113114
```

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@ module.exports = function(source, inputSourceMap) {
6868

6969
result = transpile(source, options);
7070
this.callback(null, result.code, result.map);
71-
7271
};

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
22
"name": "babel-loader",
3-
"version": "5.3.3",
3+
"version": "6.0.0",
44
"description": "babel module loader for webpack",
55
"main": "index.js",
66
"dependencies": {
7-
"babel-core": "^5.4.0",
8-
"loader-utils": "^0.2.9",
9-
"object-assign": "^3.0.0"
7+
"loader-utils": "^0.2.11",
8+
"object-assign": "^4.0.1"
109
},
1110
"peerDependencies": {
12-
"babel-core": "^5.0.0",
11+
"babel-core": "^6.0.0",
1312
"webpack": "*"
1413
},
1514
"devDependencies": {
16-
"babel-core": "^5.5.8",
15+
"babel-core": "^6.0.0",
16+
"babel-preset-es2015": "^6.0.0",
1717
"expect.js": "^0.3.1",
18-
"istanbul": "^0.3.15",
19-
"jscs": "^1.13.1",
18+
"istanbul": "^0.4.0",
19+
"jscs": "^2.5.0",
2020
"jshint": "^2.8.0",
2121
"mkdirp": "^0.5.1",
22-
"mocha": "^2.2.5",
23-
"rimraf": "^2.4.0",
24-
"webpack": "^1.9.11"
22+
"mocha": "^2.3.3",
23+
"rimraf": "^2.4.3",
24+
"webpack": "^1.12.2"
2525
},
2626
"scripts": {
2727
"test": "npm run hint && npm run cs && npm run cov",

test/cache.test.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var webpack = require('webpack');
1111

1212
describe('Filesystem Cache', function() {
1313

14+
this.timeout(3000);
15+
1416
var cacheDir = path.resolve(__dirname, 'output/cache/cachefiles');
1517
var outputDir = path.resolve(__dirname, './output/cache/');
1618
var babelLoader = path.resolve(__dirname, '../');
@@ -42,13 +44,18 @@ describe('Filesystem Cache', function() {
4244

4345
it('should output files to cache directory', function(done) {
4446

47+
var loader = babelLoader;
4548
var config = assign({}, globalConfig, {
4649
module: {
4750
loaders: [
4851
{
4952
test: /\.jsx?/,
50-
loader: babelLoader + '?cacheDirectory=' + cacheDir,
53+
loader: loader,
5154
exclude: /node_modules/,
55+
query: {
56+
cacheDirectory: cacheDir,
57+
presets: ['es2015'],
58+
},
5259
},
5360
],
5461
},
@@ -71,8 +78,12 @@ describe('Filesystem Cache', function() {
7178
loaders: [
7279
{
7380
test: /\.jsx?/,
74-
loader: babelLoader + '?cacheDirectory',
81+
loader: babelLoader,
7582
exclude: /node_modules/,
83+
query: {
84+
cacheDirectory: cacheDir,
85+
presets: ['es2015'],
86+
},
7687
},
7788
],
7889
},
@@ -95,13 +106,18 @@ describe('Filesystem Cache', function() {
95106
});
96107

97108
it('should read from cache directory if cached file exists', function(done) {
109+
var loader = babelLoader;
98110
var config = assign({}, globalConfig, {
99111
module: {
100112
loaders: [
101113
{
102114
test: /\.jsx?/,
103-
loader: babelLoader + '?cacheDirectory=' + cacheDir,
115+
loader: loader,
104116
exclude: /node_modules/,
117+
query: {
118+
cacheDirectory: cacheDir,
119+
presets: ['es2015'],
120+
},
105121
},
106122
],
107123
},
@@ -125,13 +141,18 @@ describe('Filesystem Cache', function() {
125141
});
126142

127143
it('should have one file per module', function(done) {
144+
var loader = babelLoader;
128145
var config = assign({}, globalConfig, {
129146
module: {
130147
loaders: [
131148
{
132149
test: /\.jsx?/,
133-
loader: babelLoader + '?cacheDirectory=' + cacheDir,
150+
loader: loader,
134151
exclude: /node_modules/,
152+
query: {
153+
cacheDirectory: cacheDir,
154+
presets: ['es2015'],
155+
},
135156
},
136157
],
137158
},
@@ -163,6 +184,7 @@ describe('Filesystem Cache', function() {
163184
query: {
164185
cacheDirectory: cacheDir,
165186
cacheIdentifier: 'a',
187+
presets: ['es2015'],
166188
},
167189
},
168190
],
@@ -178,6 +200,7 @@ describe('Filesystem Cache', function() {
178200
query: {
179201
cacheDirectory: cacheDir,
180202
cacheIdentifier: 'b',
203+
presets: ['es2015'],
181204
},
182205
},
183206
],

test/fixtures/experimental.js

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

test/loader.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var webpack = require('webpack');
1010

1111
describe('Loader', function() {
1212

13+
this.timeout(3000); // @TODO this is worrisome
14+
1315
var outputDir = path.resolve(__dirname, './output/loader');
1416
var babelLoader = path.resolve(__dirname, '../');
1517
var globalConfig = {
@@ -23,6 +25,9 @@ describe('Loader', function() {
2325
{
2426
test: /\.jsx?/,
2527
loader: babelLoader,
28+
query: {
29+
presets: ['es2015'],
30+
},
2631
exclude: /node_modules/,
2732
},
2833
],
@@ -46,6 +51,9 @@ describe('Loader', function() {
4651
{
4752
test: /\.jsx?/,
4853
loader: babelLoader,
54+
query: {
55+
presets: ['es2015'],
56+
},
4957
exclude: /node_modules/,
5058
},
5159
],
@@ -79,14 +87,17 @@ describe('Loader', function() {
7987
{
8088
test: /\.jsx?/,
8189
loader: babelLoader,
90+
query: {
91+
presets: ['es2015'],
92+
},
8293
exclude: /node_modules/,
8394
},
8495
],
8596
},
8697
});
8798

8899
webpack(config, function(err, stats) {
89-
expect(stats.compilation.errors).to.have.length();
100+
expect(stats.compilation.errors.length).to.be(1);
90101
expect(stats.compilation.errors[0]).to.be.an(Error);
91102

92103
return done();

test/options.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ describe('Options', function() {
4040

4141
it('should interpret options given to the loader', function(done) {
4242
var config = assign({}, globalConfig, {
43-
entry: './test/fixtures/experimental.js',
43+
entry: './test/fixtures/basic.js',
4444
module: {
4545
loaders: [
4646
{
4747
test: /\.jsx?/,
48-
loader: babelLoader + '?stage=0',
48+
loader: babelLoader + '?presets[]=es2015',
4949
exclude: /node_modules/,
5050
},
5151
],
@@ -67,9 +67,9 @@ describe('Options', function() {
6767
it('should interpret options given globally', function(done) {
6868

6969
var config = assign({}, globalConfig, {
70-
entry: './test/fixtures/experimental.js',
70+
entry: './test/fixtures/basic.js',
7171
babel: {
72-
stage: 0,
72+
presets: ['es2015'],
7373
},
7474
module: {
7575
loaders: [
@@ -96,15 +96,15 @@ describe('Options', function() {
9696

9797
it('should give priority to loader options', function(done) {
9898
var config = assign({}, globalConfig, {
99-
entry: './test/fixtures/experimental.js',
99+
entry: './test/fixtures/basic.js',
100100
babel: {
101-
stage: 4,
101+
presets: [],
102102
},
103103
module: {
104104
loaders: [
105105
{
106106
test: /\.jsx?/,
107-
loader: babelLoader + '?stage=0',
107+
loader: babelLoader + '?presets[]=es2015',
108108
exclude: /node_modules/,
109109
},
110110
],

test/sourcemaps.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('Sourcemaps', function() {
4747
loaders: [
4848
{
4949
test: /\.jsx?/,
50-
loader: babelLoader,
50+
loader: babelLoader + '?presets[]=es2015',
5151
exclude: /node_modules/,
5252
},
5353
],

0 commit comments

Comments
 (0)