Skip to content

Commit

Permalink
Merge branch 'master' into fix/non-web-target
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Mar 22, 2021
2 parents 790f08f + 2496110 commit 353a1af
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 51 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"tcp-port-used": "^1.0.2",
"typescript": "^4.2.3",
"url-loader": "^4.1.1",
"webpack": "^5.26.2",
"webpack": "^5.27.1",
"webpack-cli": "^4.5.0",
"webpack-merge": "^5.7.3"
},
Expand Down
28 changes: 12 additions & 16 deletions test/e2e/DevServer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('DevServer', () => {
const webpack5Test = isWebpack5 ? it : it.skip;

it('should add devServer entry points to a single entry point', (done) => {
testBin('--config ./test/fixtures/dev-server/default-config.js')
testBin(null, './test/fixtures/dev-server/default-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('client/default/index.js?');
Expand All @@ -19,9 +19,7 @@ describe('DevServer', () => {
webpack5Test(
'should add devServer entry points to a multi entry point object',
(done) => {
testBin(
'--config ./test/fixtures/dev-server/multi-entry.js --stats=verbose'
)
testBin('--stats=verbose', './test/fixtures/dev-server/multi-entry.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('client/default/index.js?');
Expand All @@ -35,7 +33,7 @@ describe('DevServer', () => {
webpack5Test(
'should add devServer entry points to an empty entry object',
(done) => {
testBin('--config ./test/fixtures/dev-server/empty-entry.js')
testBin(null, './test/fixtures/dev-server/empty-entry.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('client/default/index.js?');
Expand All @@ -47,7 +45,8 @@ describe('DevServer', () => {

webpack5Test('should supports entry as descriptor', (done) => {
testBin(
'--config ./test/fixtures/entry-as-descriptor/webpack.config --stats detailed'
'--stats detailed',
'./test/fixtures/entry-as-descriptor/webpack.config'
)
.then((output) => {
expect(output.exitCode).toEqual(0);
Expand All @@ -58,9 +57,7 @@ describe('DevServer', () => {
});

it('should only prepends devServer entry points to "web" target', (done) => {
testBin(
'--config ./test/fixtures/dev-server/default-config.js --target web'
)
testBin('--target web', './test/fixtures/dev-server/default-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('client/default/index.js?');
Expand All @@ -71,9 +68,7 @@ describe('DevServer', () => {
});

it('should not prepend devServer entry points to "node" target', (done) => {
testBin(
'--config ./test/fixtures/dev-server/default-config.js --target node'
)
testBin('--target node', './test/fixtures/dev-server/default-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).not.toContain('client/default/index.js?');
Expand All @@ -85,7 +80,8 @@ describe('DevServer', () => {

it('should prepends the hot runtime to "node" target as well', (done) => {
testBin(
'--config ./test/fixtures/dev-server/default-config.js --target node --hot'
'--target node --hot',
'./test/fixtures/dev-server/default-config.js'
)
.then((output) => {
expect(output.exitCode).toEqual(0);
Expand All @@ -112,7 +108,7 @@ describe('DevServer', () => {
});

it('does not use client.path when default', (done) => {
testBin('--config ./test/fixtures/dev-server/client-default-path-config.js')
testBin(null, './test/fixtures/dev-server/client-default-path-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).not.toContain('&path=/ws');
Expand All @@ -122,7 +118,7 @@ describe('DevServer', () => {
});

it('should use client.path when custom', (done) => {
testBin('--config ./test/fixtures/dev-server/client-custom-path-config.js')
testBin(null, './test/fixtures/dev-server/client-custom-path-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('&path=/custom/path');
Expand All @@ -134,7 +130,7 @@ describe('DevServer', () => {
webpack5Test(
'should prepend devServer entry points depending on targetProperties',
(done) => {
testBin('--config ./test/fixtures/dev-server/target-config.js')
testBin(null, './test/fixtures/dev-server/target-config.js')
.then((output) => {
expect(output.exitCode).toEqual(0);
expect(output.stdout).toContain('client/default/index.js');
Expand Down
16 changes: 3 additions & 13 deletions test/fixtures/cli/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
'use strict';

const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
stats: 'detailed',
context: __dirname,
entry: './foo.js',
plugins: [
{
apply(compiler) {
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
let exitCode = 0;
if (stats.hasErrors()) {
exitCode = 1;
}
setTimeout(() => process.exit(exitCode));
});
},
},
],
plugins: [ExitOnDonePlugin],
};
2 changes: 2 additions & 0 deletions test/fixtures/dev-server/client-custom-path-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { resolve } = require('path');
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
Expand All @@ -15,4 +16,5 @@ module.exports = {
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
2 changes: 2 additions & 0 deletions test/fixtures/dev-server/client-default-path-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { resolve } = require('path');
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
Expand All @@ -15,4 +16,5 @@ module.exports = {
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
2 changes: 2 additions & 0 deletions test/fixtures/dev-server/default-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { resolve } = require('path');
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
Expand All @@ -15,4 +16,5 @@ module.exports = {
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
5 changes: 4 additions & 1 deletion test/fixtures/dev-server/empty-entry.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';

const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
stats: 'detailed',
stats: { orphanModules: true, preset: 'detailed' },
entry: {},
devServer: {
transportMode: {
server: 'sockjs',
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
2 changes: 2 additions & 0 deletions test/fixtures/dev-server/multi-entry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { resolve } = require('path');
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
Expand All @@ -16,4 +17,5 @@ module.exports = {
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
2 changes: 2 additions & 0 deletions test/fixtures/dev-server/target-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { resolve } = require('path');
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
Expand All @@ -21,4 +22,5 @@ module.exports = {
client: 'sockjs',
},
},
plugins: [ExitOnDonePlugin],
};
16 changes: 3 additions & 13 deletions test/fixtures/entry-as-descriptor/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');

module.exports = {
mode: 'development',
context: __dirname,
Expand All @@ -8,19 +10,7 @@ module.exports = {
import: './foo.js',
},
},
plugins: [
{
apply(compiler) {
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
let exitCode = 0;
if (stats.hasErrors()) {
exitCode = 1;
}
setTimeout(() => process.exit(exitCode));
});
},
},
],
plugins: [ExitOnDonePlugin],
infrastructureLogging: {
level: 'warn',
},
Expand Down
13 changes: 13 additions & 0 deletions test/helpers/ExitOnDonePlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = {
apply(compiler) {
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
let exitCode = 0;
if (stats.hasErrors()) {
exitCode = 1;
}
setTimeout(() => process.exit(exitCode));
});
},
};

0 comments on commit 353a1af

Please sign in to comment.