Skip to content

Commit

Permalink
Merge branch 'next' into feat/analyze-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Oct 5, 2020
2 parents 82b935d + 305c188 commit 528a23e
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 34 deletions.
7 changes: 0 additions & 7 deletions .gitignore
Expand Up @@ -39,8 +39,6 @@ lerna-debug.log
# package-lock file
package-lock.json

# source maps of docs
docs/**/*.map
junit.xml

# typescript source maps
Expand All @@ -50,8 +48,3 @@ packages/**/*.map
# cache
.eslintcache

# temporary test files
test-assets/
./lib/

lib/test/loader/error-test/src/index.d.ts
11 changes: 9 additions & 2 deletions packages/webpack-cli/lib/utils/Compiler.js
Expand Up @@ -87,8 +87,15 @@ class Compiler {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
await this.compiler.run((err, stats) => {
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
resolve(content);
if (this.compiler.close) {
this.compiler.close(() => {
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
resolve(content);
});
} else {
const content = this.compilerCallback(err, stats, lastHash, options, outputOptions);
resolve(content);
}
});
});
}
Expand Down
21 changes: 16 additions & 5 deletions scripts/cleanupTest.js
Expand Up @@ -3,16 +3,27 @@ const rimraf = require('rimraf');
const { join } = require('path');
const collectTestFolders = require('./utils');

const outputDirectories = ['bin', 'binary', 'dist', 'test', 'test-assets', 'test-plugin', 'test-loader', 'stats.json'];
const outputDirectories = [
'bin',
'binary',
'dist',
'test',
'test-assets',
'test-plugin',
'test-loader',
'test-cache-path',
'test-locate-cache',
'stats.json',
];

function folderStrategy(stats, file) {
const folderStrategy = (stats, file) => {
return stats.isDirectory() && outputDirectories.includes(file);
}
};

function cleanupOutputDirs() {
const cleanupOutputDirs = () => {
for (const outputFolder of collectTestFolders(folderStrategy)) {
outputDirectories.forEach((dir) => rimraf.sync(join(outputFolder, dir)));
}
}
};

module.exports = cleanupOutputDirs;
16 changes: 16 additions & 0 deletions test/cache/cache.test.js
@@ -0,0 +1,16 @@
'use strict';

const { run, isWebpack5 } = require('../utils/test-utils');

describe('cache related tests', () => {
it('should log warning in case of single compiler', () => {
let { stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js'], false);
// run 2nd compilation
({ stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js'], false));

if (isWebpack5) {
expect(stderr).toContain('starting to restore cache content');
expect(stdout).toContain('[cached] 1 module');
}
});
});
1 change: 1 addition & 0 deletions test/cache/src/main.js
@@ -0,0 +1 @@
console.log('tehghgst cache');
24 changes: 24 additions & 0 deletions test/cache/webpack.config.js
@@ -0,0 +1,24 @@
const path = require('path');

module.exports = {
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename],
},
},
infrastructureLogging: {
debug: /webpack\.cache/,
},
entry: {
app: './src/main.js',
},
devtool: 'inline-source-map',
plugins: [],
output: {
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
};
8 changes: 6 additions & 2 deletions test/core-flags/cache-flags.test.js
@@ -1,6 +1,8 @@
'use strict';

const { run } = require('../utils/test-utils');
const { existsSync } = require('fs');
const { resolve } = require('path');

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

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

expect(stderr).toBeFalsy();
expect(stdout).toContain('test-cache-path');
expect(existsSync(resolve(__dirname, './test-cache-path'))).toBeTruthy();
});

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

expect(stderr).toBeFalsy();
expect(stdout).toContain('test-locate-cache');
expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy();
});

it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => {
Expand Down
11 changes: 11 additions & 0 deletions test/loader/error-test/tsconfig.json
@@ -0,0 +1,11 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"noEmitOnError": false,
"outDir": "./dist"
},
"exclude": ["node_modules"]
}
34 changes: 16 additions & 18 deletions yarn.lock
Expand Up @@ -4067,6 +4067,11 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=

cli-width@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6"
integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==

cliui@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
Expand Down Expand Up @@ -7140,20 +7145,20 @@ inquirer@^6.0.0, inquirer@^6.2.0, inquirer@^6.3.1:
through "^2.3.6"

inquirer@^7.0.0, inquirer@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29"
integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==
version "7.3.3"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
dependencies:
ansi-escapes "^4.2.1"
chalk "^3.0.0"
chalk "^4.1.0"
cli-cursor "^3.1.0"
cli-width "^2.0.0"
cli-width "^3.0.0"
external-editor "^3.0.3"
figures "^3.0.0"
lodash "^4.17.15"
lodash "^4.17.19"
mute-stream "0.0.8"
run-async "^2.4.0"
rxjs "^6.5.3"
rxjs "^6.6.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
through "^2.3.6"
Expand Down Expand Up @@ -11020,17 +11025,10 @@ run-queue@^1.0.0, run-queue@^1.0.3:
dependencies:
aproba "^1.1.1"

rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.5.3:
version "6.5.4"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c"
integrity sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==
dependencies:
tslib "^1.9.0"

rxjs@^6.6.2:
version "6.6.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.2.tgz#8096a7ac03f2cc4fe5860ef6e572810d9e01c0d2"
integrity sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==
rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.2:
version "6.6.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
dependencies:
tslib "^1.9.0"

Expand Down

0 comments on commit 528a23e

Please sign in to comment.