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

Adding noParse on module #27

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 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 @@ -34,6 +37,10 @@ module.exports = class extends ChainedMap {
.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/);
});