Skip to content

Commit 528a23e

Browse files
authored
Merge branch 'next' into feat/analyze-flag
2 parents 82b935d + 305c188 commit 528a23e

File tree

9 files changed

+99
-34
lines changed

9 files changed

+99
-34
lines changed

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ lerna-debug.log
3939
# package-lock file
4040
package-lock.json
4141

42-
# source maps of docs
43-
docs/**/*.map
4442
junit.xml
4543

4644
# typescript source maps
@@ -50,8 +48,3 @@ packages/**/*.map
5048
# cache
5149
.eslintcache
5250

53-
# temporary test files
54-
test-assets/
55-
./lib/
56-
57-
lib/test/loader/error-test/src/index.d.ts

packages/webpack-cli/lib/utils/Compiler.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ class Compiler {
8787
// eslint-disable-next-line no-async-promise-executor
8888
return new Promise(async (resolve) => {
8989
await this.compiler.run((err, stats) => {
90-
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
91-
resolve(content);
90+
if (this.compiler.close) {
91+
this.compiler.close(() => {
92+
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
93+
resolve(content);
94+
});
95+
} else {
96+
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
97+
resolve(content);
98+
}
9299
});
93100
});
94101
}

scripts/cleanupTest.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,27 @@ const rimraf = require('rimraf');
33
const { join } = require('path');
44
const collectTestFolders = require('./utils');
55

6-
const outputDirectories = ['bin', 'binary', 'dist', 'test', 'test-assets', 'test-plugin', 'test-loader', 'stats.json'];
6+
const outputDirectories = [
7+
'bin',
8+
'binary',
9+
'dist',
10+
'test',
11+
'test-assets',
12+
'test-plugin',
13+
'test-loader',
14+
'test-cache-path',
15+
'test-locate-cache',
16+
'stats.json',
17+
];
718

8-
function folderStrategy(stats, file) {
19+
const folderStrategy = (stats, file) => {
920
return stats.isDirectory() && outputDirectories.includes(file);
10-
}
21+
};
1122

12-
function cleanupOutputDirs() {
23+
const cleanupOutputDirs = () => {
1324
for (const outputFolder of collectTestFolders(folderStrategy)) {
1425
outputDirectories.forEach((dir) => rimraf.sync(join(outputFolder, dir)));
1526
}
16-
}
27+
};
1728

1829
module.exports = cleanupOutputDirs;

test/cache/cache.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
const { run, isWebpack5 } = require('../utils/test-utils');
4+
5+
describe('cache related tests', () => {
6+
it('should log warning in case of single compiler', () => {
7+
let { stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js'], false);
8+
// run 2nd compilation
9+
({ stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js'], false));
10+
11+
if (isWebpack5) {
12+
expect(stderr).toContain('starting to restore cache content');
13+
expect(stdout).toContain('[cached] 1 module');
14+
}
15+
});
16+
});

test/cache/src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('tehghgst cache');

test/cache/webpack.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
cache: {
5+
type: 'filesystem',
6+
buildDependencies: {
7+
config: [__filename],
8+
},
9+
},
10+
infrastructureLogging: {
11+
debug: /webpack\.cache/,
12+
},
13+
entry: {
14+
app: './src/main.js',
15+
},
16+
devtool: 'inline-source-map',
17+
plugins: [],
18+
output: {
19+
filename: '[name].bundle.js',
20+
chunkFilename: '[name].bundle.js',
21+
path: path.resolve(__dirname, 'dist'),
22+
publicPath: '/',
23+
},
24+
};

test/core-flags/cache-flags.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

33
const { run } = require('../utils/test-utils');
4+
const { existsSync } = require('fs');
5+
const { resolve } = require('path');
46

57
describe('cache related flags from core', () => {
68
it('should be successful with --cache ', () => {
@@ -25,17 +27,19 @@ describe('cache related flags from core', () => {
2527
});
2628

2729
it('should set cache.cacheDirectory with --cache-cache-directory', () => {
28-
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', '/test-cache-path']);
30+
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']);
2931

3032
expect(stderr).toBeFalsy();
3133
expect(stdout).toContain('test-cache-path');
34+
expect(existsSync(resolve(__dirname, './test-cache-path'))).toBeTruthy();
3235
});
3336

3437
it('should set cache.cacheLocation with --cache-cache-locations', () => {
35-
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', '/test-locate-cache']);
38+
const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', './test-locate-cache']);
3639

3740
expect(stderr).toBeFalsy();
3841
expect(stdout).toContain('test-locate-cache');
42+
expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy();
3943
});
4044

4145
it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compileOnSave": false,
3+
"buildOnSave": false,
4+
"compilerOptions": {
5+
"target": "es6",
6+
"moduleResolution": "node",
7+
"noEmitOnError": false,
8+
"outDir": "./dist"
9+
},
10+
"exclude": ["node_modules"]
11+
}

yarn.lock

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,6 +4067,11 @@ cli-width@^2.0.0:
40674067
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
40684068
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
40694069

4070+
cli-width@^3.0.0:
4071+
version "3.0.0"
4072+
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6"
4073+
integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==
4074+
40704075
cliui@^4.0.0:
40714076
version "4.1.0"
40724077
resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
@@ -7140,20 +7145,20 @@ inquirer@^6.0.0, inquirer@^6.2.0, inquirer@^6.3.1:
71407145
through "^2.3.6"
71417146

71427147
inquirer@^7.0.0, inquirer@^7.1.0:
7143-
version "7.1.0"
7144-
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29"
7145-
integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==
7148+
version "7.3.3"
7149+
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
7150+
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
71467151
dependencies:
71477152
ansi-escapes "^4.2.1"
7148-
chalk "^3.0.0"
7153+
chalk "^4.1.0"
71497154
cli-cursor "^3.1.0"
7150-
cli-width "^2.0.0"
7155+
cli-width "^3.0.0"
71517156
external-editor "^3.0.3"
71527157
figures "^3.0.0"
7153-
lodash "^4.17.15"
7158+
lodash "^4.17.19"
71547159
mute-stream "0.0.8"
71557160
run-async "^2.4.0"
7156-
rxjs "^6.5.3"
7161+
rxjs "^6.6.0"
71577162
string-width "^4.1.0"
71587163
strip-ansi "^6.0.0"
71597164
through "^2.3.6"
@@ -11020,17 +11025,10 @@ run-queue@^1.0.0, run-queue@^1.0.3:
1102011025
dependencies:
1102111026
aproba "^1.1.1"
1102211027

11023-
rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.5.3:
11024-
version "6.5.4"
11025-
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c"
11026-
integrity sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==
11027-
dependencies:
11028-
tslib "^1.9.0"
11029-
11030-
rxjs@^6.6.2:
11031-
version "6.6.2"
11032-
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.2.tgz#8096a7ac03f2cc4fe5860ef6e572810d9e01c0d2"
11033-
integrity sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==
11028+
rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.2:
11029+
version "6.6.3"
11030+
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
11031+
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
1103411032
dependencies:
1103511033
tslib "^1.9.0"
1103611034

0 commit comments

Comments
 (0)