Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Adding noParse on module
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Sachs committed May 17, 2017
1 parent 40971b1 commit ef829fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Module.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const ChainedMap = require('./ChainedMap');
const ChainedSet = require('./ChainedSet');
const Rule = require('./Rule');

module.exports = class extends ChainedMap {
constructor(parent) {
super(parent);
this.rules = new ChainedMap(this);
this.noParse = new ChainedSet(this);
}

rule(name) {
Expand All @@ -17,7 +19,8 @@ module.exports = class extends ChainedMap {

toConfig() {
return this.clean(Object.assign(this.entries() || {}, {
rules: this.rules.values().map(r => r.toConfig())
rules: this.rules.values().map(r => r.toConfig()),
noParse: this.noParse.values()
}));
}

Expand All @@ -33,6 +36,9 @@ module.exports = class extends ChainedMap {
.keys(value)
.forEach(name => this.rule(name).merge(value[name]));
}
case 'noParse': {
return this.noParse.merge(value);
}

default: {
this.set(key, value);
Expand Down
12 changes: 11 additions & 1 deletion test/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ test('toConfig with values', t => {
const module = new Module();

module.rule('compile').test(/\.js$/);
module.noParse.add(/.min.js/);

t.deepEqual(module.toConfig(), { rules: [{ test: /\.js$/ }] });
t.deepEqual(module.toConfig(), { rules: [{ test: /\.js$/ }], noParse: [/.min.js/]});
});

test('noParse', t => {
const module = new Module();
const instance = module.noParse.add(/.min.js/).end();

t.is(instance, module);
t.deepEqual(module.noParse.values()[0], /.min.js/);
});

0 comments on commit ef829fe

Please sign in to comment.