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

Commit

Permalink
Merge branch 'master' into config-node-bool
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperOleg39 authored and o.drapeza committed May 24, 2020
2 parents a45b512 + 83db406 commit 69a58a2
Show file tree
Hide file tree
Showing 29 changed files with 2,878 additions and 2,752 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ module.exports = {
'eslint-config-airbnb-base',
'plugin:prettier/recommended',
'prettier/babel',
'plugin:ava/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
],
plugins: ['eslint-plugin-babel', 'eslint-plugin-ava'],
plugins: ['eslint-plugin-babel'],
parser: 'babel-eslint',
env: {
es6: true,
Expand Down
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
dist: xenial
dist: bionic
language: node_js
cache: yarn
node_js:
- '8'
- '10'
- '12'
before_install:
# Required due to: https://github.com/travis-ci/travis-ci/issues/7951
- curl -sSfL https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- '13'
jobs:
include:
# Prettier has dropped support for Node 8, so we have to skip linting and use --ignore-engines.
- node_js: 8
install:
- yarn --frozen-lockfile --ignore-engines
script:
- yarn test
- yarn test:types
install:
- yarn --frozen-lockfile
script:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 28 September 2018
- merge resolve plugins just like config [`c47ee2d`](https://github.com/neutrinojs/webpack-chain/commit/c47ee2d52c1be4fcdbe10adef865e45d6fd729ef)
- linted [`dff82f8`](https://github.com/neutrinojs/webpack-chain/commit/dff82f8494394dcf8c97bff324f877513f44fa56)
- Revert changes to gitignore [`c1250a0`](https://github.com/neutrinojs/webpack-chain/commit/c1250a0fe7ffafa82f529ac8e7262e2c3cdd4729)

#### [v4.11.0](https://github.com/neutrinojs/webpack-chain/compare/v4.10.0...v4.11.0)
Expand Down Expand Up @@ -195,10 +197,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Lock file maintenance [`#60`](https://github.com/neutrinojs/webpack-chain/pull/60)
- Update to ESLint 5 (#89) [`#69`](https://github.com/neutrinojs/webpack-chain/issues/69) [`#77`](https://github.com/neutrinojs/webpack-chain/issues/77) [`#87`](https://github.com/neutrinojs/webpack-chain/issues/87) [`#88`](https://github.com/neutrinojs/webpack-chain/issues/88)
- Update dependency eslint-config-airbnb-base to v13 [`7370962`](https://github.com/neutrinojs/webpack-chain/commit/73709628a6ff6661e478c652d0ff03b99b6c2abb)
- merge resolve plugins just like config [`c47ee2d`](https://github.com/neutrinojs/webpack-chain/commit/c47ee2d52c1be4fcdbe10adef865e45d6fd729ef)
- Fix linting :/ [`30cc11d`](https://github.com/neutrinojs/webpack-chain/commit/30cc11d0d35a5676069a623b180c8e7b00e099e4)
- Fix README bug, test in Node.js v6 [`4a37c74`](https://github.com/neutrinojs/webpack-chain/commit/4a37c74e1f790e118034154da9c32d0e36164f74)
- linted [`dff82f8`](https://github.com/neutrinojs/webpack-chain/commit/dff82f8494394dcf8c97bff324f877513f44fa56)
- Run yarn lint --fix [`9384537`](https://github.com/neutrinojs/webpack-chain/commit/9384537269d60bb80b3330cf44ddbdd9d528c454)

#### [v4.8.0](https://github.com/neutrinojs/webpack-chain/compare/v4.7.0...v4.8.0)
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'node',
testMatch: ['**/test/**/*.js'],
};
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"author": "Eli Perelman <eli@eliperelman.com>",
"license": "MPL-2.0",
"scripts": {
"test": "ava test",
"test": "jest",
"test:types": "tsc -p ./types/test/tsconfig.json",
"lint": "eslint --cache --report-unused-disable-directives --format codeframe \".*.js\" src test",
"lint": "eslint --cache --report-unused-disable-directives --format codeframe \".*.js\" \"*.js\" src test",
"changelog": "auto-changelog --remote upstream --commit-limit false",
"version": "yarn changelog --package && git add CHANGELOG.md"
},
Expand All @@ -36,17 +36,17 @@
"@types/node": "^12.12.17",
"@types/tapable": "^1.0.4",
"@types/webpack": "^4.41.0",
"auto-changelog": "^1.16.2",
"ava": "^1.4.1",
"auto-changelog": "^2.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.7.2",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-ava": "^9.0.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.19.1",
"jest": "^25.3.0",
"prettier": "^2.0.4",
"typescript": "^3.7.3",
"webpack": "^4.41.2"
}
Expand Down
10 changes: 5 additions & 5 deletions src/ChainedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = class extends Chainable {

extend(methods) {
this.shorthands = methods;
methods.forEach(method => {
this[method] = value => this.set(method, value);
methods.forEach((method) => {
this[method] = (value) => this.set(method, value);
});
return this;
}
Expand All @@ -33,7 +33,7 @@ module.exports = class extends Chainable {
const names = Object.keys(entries);
const order = [...names];

names.forEach(name => {
names.forEach((name) => {
if (!entries[name]) {
return;
}
Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports = class extends Chainable {
values() {
const { entries, order } = this.order();

return order.map(name => entries[name]);
return order.map((name) => entries[name]);
}

get(key) {
Expand All @@ -89,7 +89,7 @@ module.exports = class extends Chainable {
}

merge(obj, omit = []) {
Object.keys(obj).forEach(key => {
Object.keys(obj).forEach((key) => {
if (omit.includes(key)) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = class extends ChainedMap {
devServer: this.devServer.toConfig(),
module: this.module.toConfig(),
optimization: this.optimization.toConfig(),
plugins: this.plugins.values().map(plugin => plugin.toConfig()),
plugins: this.plugins.values().map((plugin) => plugin.toConfig()),
performance: this.performance.entries(),
entry: Object.keys(entryPoints).reduce(
(acc, key) =>
Expand All @@ -155,13 +155,13 @@ module.exports = class extends ChainedMap {
];

if (!omit.includes('entry') && 'entry' in obj) {
Object.keys(obj.entry).forEach(name =>
Object.keys(obj.entry).forEach((name) =>
this.entry(name).merge([].concat(obj.entry[name])),
);
}

if (!omit.includes('plugin') && 'plugin' in obj) {
Object.keys(obj.plugin).forEach(name =>
Object.keys(obj.plugin).forEach((name) =>
this.plugin(name).merge(obj.plugin[name]),
);
}
Expand All @@ -175,7 +175,7 @@ module.exports = class extends ChainedMap {
}
}

omissions.forEach(key => {
omissions.forEach((key) => {
if (!omit.includes(key) && key in obj) {
this[key].merge(obj[key]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ module.exports = class extends ChainedMap {
toConfig() {
return this.clean(
Object.assign(this.entries() || {}, {
defaultRules: this.defaultRules.values().map(r => r.toConfig()),
rules: this.rules.values().map(r => r.toConfig()),
defaultRules: this.defaultRules.values().map((r) => r.toConfig()),
rules: this.rules.values().map((r) => r.toConfig()),
}),
);
}

merge(obj, omit = []) {
if (!omit.includes('rule') && 'rule' in obj) {
Object.keys(obj.rule).forEach(name =>
Object.keys(obj.rule).forEach((name) =>
this.rule(name).merge(obj.rule[name]),
);
}

if (!omit.includes('defaultRule') && 'defaultRule' in obj) {
Object.keys(obj.defaultRule).forEach(name =>
Object.keys(obj.defaultRule).forEach((name) =>
this.defaultRule(name).merge(obj.defaultRule[name]),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ module.exports = class extends ChainedMap {
toConfig() {
return this.clean(
Object.assign(this.entries() || {}, {
minimizer: this.minimizers.values().map(plugin => plugin.toConfig()),
minimizer: this.minimizers.values().map((plugin) => plugin.toConfig()),
}),
);
}

merge(obj, omit = []) {
if (!omit.includes('minimizer') && 'minimizer' in obj) {
Object.keys(obj.minimizer).forEach(name =>
Object.keys(obj.minimizer).forEach((name) =>
this.minimizer(name).merge(obj.minimizer[name]),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Orderable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = Class =>
module.exports = (Class) =>
class extends Class {
before(name) {
if (this.__after) {
Expand Down
6 changes: 3 additions & 3 deletions src/Resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = class extends ChainedMap {
mainFields: this.mainFields.values(),
mainFiles: this.mainFiles.values(),
modules: this.modules.values(),
plugins: this.plugins.values().map(plugin => plugin.toConfig()),
plugins: this.plugins.values().map((plugin) => plugin.toConfig()),
}),
);
}
Expand All @@ -58,12 +58,12 @@ module.exports = class extends ChainedMap {
];

if (!omit.includes('plugin') && 'plugin' in obj) {
Object.keys(obj.plugin).forEach(name =>
Object.keys(obj.plugin).forEach((name) =>
this.plugin(name).merge(obj.plugin[name]),
);
}

omissions.forEach(key => {
omissions.forEach((key) => {
if (!omit.includes(key) && key in obj) {
this[key].merge(obj[key]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ResolveLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class extends Resolve {
merge(obj, omit = []) {
const omissions = ['moduleExtensions', 'packageMains'];

omissions.forEach(key => {
omissions.forEach((key) => {
if (!omit.includes(key) && key in obj) {
this[key].merge(obj[key]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ const Rule = Orderable(
Object.assign(this.entries() || {}, {
include: this.include.values(),
exclude: this.exclude.values(),
rules: this.rules.values().map(rule => rule.toConfig()),
oneOf: this.oneOfs.values().map(oneOf => oneOf.toConfig()),
use: this.uses.values().map(use => use.toConfig()),
rules: this.rules.values().map((rule) => rule.toConfig()),
oneOf: this.oneOfs.values().map((oneOf) => oneOf.toConfig()),
use: this.uses.values().map((use) => use.toConfig()),
}),
);

Expand All @@ -92,19 +92,19 @@ const Rule = Orderable(
}

if (!omit.includes('use') && 'use' in obj) {
Object.keys(obj.use).forEach(name =>
Object.keys(obj.use).forEach((name) =>
this.use(name).merge(obj.use[name]),
);
}

if (!omit.includes('rules') && 'rules' in obj) {
Object.keys(obj.rules).forEach(name =>
Object.keys(obj.rules).forEach((name) =>
this.rule(name).merge(obj.rules[name]),
);
}

if (!omit.includes('oneOf') && 'oneOf' in obj) {
Object.keys(obj.oneOf).forEach(name =>
Object.keys(obj.oneOf).forEach((name) =>
this.oneOf(name).merge(obj.oneOf[name]),
);
}
Expand Down
15 changes: 7 additions & 8 deletions test/Chainable.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import test from 'ava';
import Chainable from '../src/Chainable';
const Chainable = require('../src/Chainable');

test('Calling .end() returns parent', t => {
test('calling .end() returns parent', () => {
const parent = { parent: true };
const chain = new Chainable(parent);

t.is(chain.end(), parent);
expect(chain.end()).toBe(parent);
});

test('Using .batch() receives context', t => {
test('using .batch() receives context', () => {
const chain = new Chainable();
const context = chain.batch(current => {
t.is(current, chain);
const context = chain.batch((current) => {
expect(current).toBe(chain);
});

t.is(context, chain);
expect(context).toBe(chain);
});
Loading

0 comments on commit 69a58a2

Please sign in to comment.