-
-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/options' into develop
* feature/options: Closes #46. Add support for babel global options. Remove parsing of booleans.
- Loading branch information
Showing
4 changed files
with
155 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import test from '../../!./test.js'; | ||
import test from './test.js'; | ||
|
||
class App { | ||
constructor(arg='test') { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/*jshint esnext:true*/ | ||
|
||
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; | ||
let n = { x, y, ...z }; | ||
|
||
// Array comprehensions | ||
var results = [ | ||
for(c of customers) | ||
if (c.city == "Seattle") | ||
{ name: c.name, age: c.age } | ||
] | ||
|
||
// Generator comprehensions | ||
var results = ( | ||
for(c of customers) | ||
if (c.city == "Seattle") | ||
{ name: c.name, age: c.age } | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
assign = require('object-assign'), | ||
expect = require('expect.js'), | ||
mkdirp = require('mkdirp'), | ||
rimraf = require('rimraf'), | ||
webpack = require('webpack'); | ||
|
||
describe('Options', function () { | ||
|
||
var outputDir = path.resolve(__dirname, './output'), | ||
babelLoader = path.resolve(__dirname, '../'), | ||
|
||
globalConfig = { | ||
entry: './test/fixtures/basic.js', | ||
output: { | ||
path: outputDir, | ||
filename: '[id].options.js' | ||
}, | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.jsx?/, | ||
loader: babelLoader, | ||
exclude: /node_modules/ | ||
} | ||
] | ||
} | ||
}; | ||
|
||
// Clean generated cache files before each test | ||
// so that we can call each test with an empty state. | ||
beforeEach(function (done) { | ||
rimraf(outputDir, function (err) { | ||
if (err) { return done(err); } | ||
mkdirp(outputDir, done); | ||
}); | ||
}); | ||
|
||
it('should interpret options given to the loader', function (done) { | ||
|
||
var config = assign({}, globalConfig, { | ||
entry: './test/fixtures/experimental.js', | ||
module: { | ||
loaders: [{ | ||
test: /\.jsx?/, | ||
loader: babelLoader + '?experimental', | ||
exclude: /node_modules/ | ||
}] | ||
} | ||
}); | ||
|
||
webpack(config, function (err, stats) { | ||
expect(err).to.be(null); | ||
|
||
fs.readdir(outputDir, function (err, files) { | ||
expect(err).to.be(null); | ||
expect(files).to.not.be.empty(); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should interpret options given globally', function (done) { | ||
|
||
var config = assign({}, globalConfig, { | ||
entry: './test/fixtures/experimental.js', | ||
babel: { | ||
experimental: true | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.jsx?/, | ||
loader: babelLoader, | ||
exclude: /node_modules/ | ||
}] | ||
} | ||
}); | ||
|
||
webpack(config, function (err, stats) { | ||
expect(err).to.be(null); | ||
|
||
fs.readdir(outputDir, function (err, files) { | ||
expect(err).to.be(null); | ||
expect(files).to.not.be.empty(); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should give priority to loader options', function (done) { | ||
var config = assign({}, globalConfig, { | ||
entry: './test/fixtures/experimental.js', | ||
babel: { | ||
experimental: false | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.jsx?/, | ||
loader: babelLoader + '?experimental', | ||
exclude: /node_modules/ | ||
}] | ||
} | ||
}); | ||
|
||
webpack(config, function (err, stats) { | ||
expect(err).to.be(null); | ||
|
||
fs.readdir(outputDir, function (err, files) { | ||
expect(err).to.be(null); | ||
expect(files).to.not.be.empty(); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |