mirror of https://github.com/webpack/webpack.git
				
				
				
			add separate webpack warmup step with large timeout
This commit is contained in:
		
							parent
							
								
									a455ff7309
								
							
						
					
					
						commit
						b29c44e223
					
				| 
						 | 
				
			
			@ -9,11 +9,11 @@ const cacheDirectory = path.resolve(__dirname, "js/buildDepsCache");
 | 
			
		|||
const outputDirectory = path.resolve(__dirname, "js/buildDeps");
 | 
			
		||||
const inputDirectory = path.resolve(__dirname, "js/buildDepsInput");
 | 
			
		||||
 | 
			
		||||
const webpack = require("../");
 | 
			
		||||
const coverageEnabled = webpack.toString().includes("++");
 | 
			
		||||
 | 
			
		||||
const exec = (n, options = {}) => {
 | 
			
		||||
	return new Promise((resolve, reject) => {
 | 
			
		||||
		const webpack = require("../");
 | 
			
		||||
		const coverageEnabled = webpack.toString().includes("++");
 | 
			
		||||
 | 
			
		||||
		const p = child_process.execFile(
 | 
			
		||||
			process.execPath,
 | 
			
		||||
			[
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,14 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const { createFsFromVolume, Volume } = require("memfs");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
 | 
			
		||||
const createCompiler = config => {
 | 
			
		||||
	const webpack = require("..");
 | 
			
		||||
	const compiler = webpack(config);
 | 
			
		||||
	compiler.outputFileSystem = createFsFromVolume(new Volume());
 | 
			
		||||
	return compiler;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,16 +1,18 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
let fixtureCount = 0;
 | 
			
		||||
 | 
			
		||||
describe("Compiler (caching)", () => {
 | 
			
		||||
	jest.setTimeout(15000);
 | 
			
		||||
 | 
			
		||||
	function compile(entry, options, callback) {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		options = webpack.config.getNormalizedWebpackOptions(options);
 | 
			
		||||
		options.mode = "none";
 | 
			
		||||
		options.cache = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,8 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const Stats = require("../lib/Stats");
 | 
			
		||||
const { createFsFromVolume, Volume } = require("memfs");
 | 
			
		||||
const captureStdio = require("./helpers/captureStdio");
 | 
			
		||||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ describe("Compiler", () => {
 | 
			
		|||
	jest.setTimeout(20000);
 | 
			
		||||
	function compile(entry, options, callback) {
 | 
			
		||||
		const noOutputPath = !options.output || !options.output.path;
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		options = webpack.config.getNormalizedWebpackOptions(options);
 | 
			
		||||
		if (!options.mode) options.mode = "production";
 | 
			
		||||
		options.entry = entry;
 | 
			
		||||
| 
						 | 
				
			
			@ -206,6 +207,7 @@ describe("Compiler", () => {
 | 
			
		|||
	describe("methods", () => {
 | 
			
		||||
		let compiler;
 | 
			
		||||
		beforeEach(() => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				entry: "./c",
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
| 
						 | 
				
			
			@ -285,6 +287,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not emit on errors", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -306,6 +309,7 @@ describe("Compiler", () => {
 | 
			
		|||
		try {
 | 
			
		||||
			const createCompiler = options => {
 | 
			
		||||
				return new Promise((resolve, reject) => {
 | 
			
		||||
					const webpack = require("..");
 | 
			
		||||
					const c = webpack(options);
 | 
			
		||||
					c.run((err, stats) => {
 | 
			
		||||
						if (err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -339,6 +343,7 @@ describe("Compiler", () => {
 | 
			
		|||
	it("should not emit compilation errors in async (watch)", async () => {
 | 
			
		||||
		const createStats = options => {
 | 
			
		||||
			return new Promise((resolve, reject) => {
 | 
			
		||||
				const webpack = require("..");
 | 
			
		||||
				const c = webpack(options);
 | 
			
		||||
				c.outputFileSystem = createFsFromVolume(new Volume());
 | 
			
		||||
				const watching = c.watch({}, (err, stats) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -362,6 +367,7 @@ describe("Compiler", () => {
 | 
			
		|||
	});
 | 
			
		||||
 | 
			
		||||
	it("should not emit on errors (watch)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -381,6 +387,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not be running twice at a time (run)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -399,6 +406,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not be running twice at a time (watch)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -417,6 +425,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not be running twice at a time (run - watch)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -435,6 +444,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not be running twice at a time (watch - run)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -453,6 +463,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should not be running twice at a time (instance cb)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack(
 | 
			
		||||
			{
 | 
			
		||||
				context: __dirname,
 | 
			
		||||
| 
						 | 
				
			
			@ -471,6 +482,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should run again correctly after first compilation", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -492,6 +504,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should watch again correctly after first compilation", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -512,6 +525,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should run again correctly after first closed watch", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -533,6 +547,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should set compiler.watching correctly", function (done) {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -550,6 +565,7 @@ describe("Compiler", () => {
 | 
			
		|||
		expect(compiler.watching).toBe(watching);
 | 
			
		||||
	});
 | 
			
		||||
	it("should watch again correctly after first closed watch", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -571,6 +587,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should run again correctly inside afterDone hook", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -595,6 +612,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should call afterDone hook after other callbacks (run)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -620,6 +638,7 @@ describe("Compiler", () => {
 | 
			
		|||
	});
 | 
			
		||||
	it("should call afterDone hook after other callbacks (instance cb)", done => {
 | 
			
		||||
		const instanceCb = jest.fn();
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack(
 | 
			
		||||
			{
 | 
			
		||||
				context: __dirname,
 | 
			
		||||
| 
						 | 
				
			
			@ -645,6 +664,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should call afterDone hook after other callbacks (watch)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -677,6 +697,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should call afterDone hook after other callbacks (watch close)", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -709,6 +730,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should flag watchMode as true in watch", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -731,6 +753,7 @@ describe("Compiler", () => {
 | 
			
		|||
		});
 | 
			
		||||
	});
 | 
			
		||||
	it("should use cache on second run call", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
			mode: "development",
 | 
			
		||||
| 
						 | 
				
			
			@ -754,6 +777,7 @@ describe("Compiler", () => {
 | 
			
		|||
	});
 | 
			
		||||
	it("should call the failed-hook on error", done => {
 | 
			
		||||
		const failedSpy = jest.fn();
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			bail: true,
 | 
			
		||||
			context: __dirname,
 | 
			
		||||
| 
						 | 
				
			
			@ -775,7 +799,8 @@ describe("Compiler", () => {
 | 
			
		|||
	});
 | 
			
		||||
	it("should deprecate when watch option is used without callback", () => {
 | 
			
		||||
		const tracker = deprecationTracking.start();
 | 
			
		||||
		webpack({
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		compiler = webpack({
 | 
			
		||||
			watch: true
 | 
			
		||||
		});
 | 
			
		||||
		const deprecations = tracker();
 | 
			
		||||
| 
						 | 
				
			
			@ -817,6 +842,7 @@ describe("Compiler", () => {
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
		it("should log to the console (verbose)", done => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
				entry: "./a",
 | 
			
		||||
| 
						 | 
				
			
			@ -847,6 +873,7 @@ describe("Compiler", () => {
 | 
			
		|||
			});
 | 
			
		||||
		});
 | 
			
		||||
		it("should log to the console (debug mode)", done => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
				entry: "./a",
 | 
			
		||||
| 
						 | 
				
			
			@ -879,6 +906,7 @@ describe("Compiler", () => {
 | 
			
		|||
			});
 | 
			
		||||
		});
 | 
			
		||||
		it("should log to the console (none)", done => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
				entry: "./a",
 | 
			
		||||
| 
						 | 
				
			
			@ -898,6 +926,7 @@ describe("Compiler", () => {
 | 
			
		|||
			});
 | 
			
		||||
		});
 | 
			
		||||
		it("should log to the console with colors (verbose)", done => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
				entry: "./a",
 | 
			
		||||
| 
						 | 
				
			
			@ -929,6 +958,7 @@ describe("Compiler", () => {
 | 
			
		|||
			});
 | 
			
		||||
		});
 | 
			
		||||
		it("should log to the console with colors (debug mode)", done => {
 | 
			
		||||
			const webpack = require("..");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				context: path.join(__dirname, "fixtures"),
 | 
			
		||||
				entry: "./a",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const vm = require("vm");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,8 @@
 | 
			
		|||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const jestDiff = require("jest-diff").diff;
 | 
			
		||||
const stripAnsi = require("strip-ansi");
 | 
			
		||||
const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } =
 | 
			
		||||
	require("..").config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Escapes regular expression metacharacters
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +63,8 @@ describe("Defaults", () => {
 | 
			
		|||
	});
 | 
			
		||||
 | 
			
		||||
	const getDefaultConfig = config => {
 | 
			
		||||
		const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } =
 | 
			
		||||
			require("..").config;
 | 
			
		||||
		config = getNormalizedWebpackOptions(config);
 | 
			
		||||
		applyWebpackOptionsDefaults(config);
 | 
			
		||||
		process.chdir(cwd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
| 
						 | 
				
			
			@ -129,12 +131,6 @@ async function compile(options) {
 | 
			
		|||
	return { errors, warnings };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
it("should compile fine (warmup)", async () => {
 | 
			
		||||
	await compile({
 | 
			
		||||
		entry: "./entry-point"
 | 
			
		||||
	});
 | 
			
		||||
}, 120000);
 | 
			
		||||
 | 
			
		||||
it("should emit warning for missingFile", async () => {
 | 
			
		||||
	await expect(
 | 
			
		||||
		compile({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
/* describe it */
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
 | 
			
		||||
describe("Examples", () => {
 | 
			
		||||
	const basePath = path.join(__dirname, "..", "examples");
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ describe("Examples", () => {
 | 
			
		|||
					if (!options.entry) options.entry = "./example.js";
 | 
			
		||||
					if (!options.plugins) options.plugins = [];
 | 
			
		||||
				}
 | 
			
		||||
				const webpack = require("..");
 | 
			
		||||
				webpack(options, (err, stats) => {
 | 
			
		||||
					if (err) return done(err);
 | 
			
		||||
					if (stats.hasErrors()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const vm = require("vm");
 | 
			
		||||
| 
						 | 
				
			
			@ -7,8 +9,6 @@ const rimraf = require("rimraf");
 | 
			
		|||
const checkArrayExpectation = require("./checkArrayExpectation");
 | 
			
		||||
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
 | 
			
		||||
const casesPath = path.join(__dirname, "hotCases");
 | 
			
		||||
let categories = fs
 | 
			
		||||
	.readdirSync(casesPath)
 | 
			
		||||
| 
						 | 
				
			
			@ -45,6 +45,7 @@ const describeCases = config => {
 | 
			
		|||
						it(
 | 
			
		||||
							testName + " should compile",
 | 
			
		||||
							done => {
 | 
			
		||||
								const webpack = require("..");
 | 
			
		||||
								const outputDirectory = path.join(
 | 
			
		||||
									__dirname,
 | 
			
		||||
									"js",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const { createFsFromVolume, Volume } = require("memfs");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const { createFsFromVolume, Volume } = require("memfs");
 | 
			
		||||
 | 
			
		||||
describe("MultiStats", () => {
 | 
			
		||||
	it("should create JSON of children stats", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		const compiler = webpack([
 | 
			
		||||
			{
 | 
			
		||||
				context: __dirname,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,13 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
 | 
			
		||||
describe("NodeTemplatePlugin", () => {
 | 
			
		||||
	jest.setTimeout(20000);
 | 
			
		||||
	it("should compile and run a simple module", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		webpack(
 | 
			
		||||
			{
 | 
			
		||||
				mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +44,7 @@ describe("NodeTemplatePlugin", () => {
 | 
			
		|||
	});
 | 
			
		||||
 | 
			
		||||
	it("should compile and run a simple module in single mode", done => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		webpack(
 | 
			
		||||
			{
 | 
			
		||||
				mode: "production",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,10 @@
 | 
			
		|||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const util = require("util");
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
const vm = require("vm");
 | 
			
		||||
const webpack = require("../");
 | 
			
		||||
 | 
			
		||||
const readdir = util.promisify(fs.readdir);
 | 
			
		||||
const writeFile = util.promisify(fs.writeFile);
 | 
			
		||||
| 
						 | 
				
			
			@ -52,6 +53,7 @@ describe("Persistent Caching", () => {
 | 
			
		|||
 | 
			
		||||
	const compile = async (configAdditions = {}) => {
 | 
			
		||||
		return new Promise((resolve, reject) => {
 | 
			
		||||
			const webpack = require("../");
 | 
			
		||||
			webpack(
 | 
			
		||||
				{
 | 
			
		||||
					...config,
 | 
			
		||||
| 
						 | 
				
			
			@ -164,6 +166,7 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
 | 
			
		|||
			"lib2.js": "export default 21"
 | 
			
		||||
		};
 | 
			
		||||
		await updateSrc(data);
 | 
			
		||||
		const webpack = require("../");
 | 
			
		||||
		const configAdditions = {
 | 
			
		||||
			plugins: [
 | 
			
		||||
				new webpack.container.ModuleFederationPlugin({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,16 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const webpack = require("../");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
 | 
			
		||||
describe("Profiling Plugin", function () {
 | 
			
		||||
	jest.setTimeout(120000);
 | 
			
		||||
 | 
			
		||||
	it("should handle output path with folder creation", done => {
 | 
			
		||||
		const webpack = require("../");
 | 
			
		||||
		const outputPath = path.join(__dirname, "js/profilingPath");
 | 
			
		||||
		const finalPath = path.join(outputPath, "events.json");
 | 
			
		||||
		rimraf(outputPath, () => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const { createFsFromVolume, Volume } = require("memfs");
 | 
			
		||||
 | 
			
		||||
const compile = options => {
 | 
			
		||||
	return new Promise((resolve, reject) => {
 | 
			
		||||
		const webpack = require("..");
 | 
			
		||||
		const compiler = webpack(options);
 | 
			
		||||
		compiler.outputFileSystem = createFsFromVolume(new Volume());
 | 
			
		||||
		compiler.run((err, stats) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const rimraf = require("rimraf");
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +36,7 @@ const tests = fs
 | 
			
		|||
	});
 | 
			
		||||
 | 
			
		||||
describe("StatsTestCases", () => {
 | 
			
		||||
	jest.setTimeout(60000);
 | 
			
		||||
	jest.setTimeout(30000);
 | 
			
		||||
	let stderr;
 | 
			
		||||
	beforeEach(() => {
 | 
			
		||||
		stderr = captureStdio(process.stderr, true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const vm = require("vm");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
const { describeCases } = require("./TestCases.template");
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
 | 
			
		||||
describe("TestCases", () => {
 | 
			
		||||
	describeCases({
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +10,11 @@ describe("TestCases", () => {
 | 
			
		|||
			moduleIds: "named",
 | 
			
		||||
			chunkIds: "named"
 | 
			
		||||
		},
 | 
			
		||||
		plugins: [new webpack.HotModuleReplacementPlugin()]
 | 
			
		||||
		plugins: [
 | 
			
		||||
			c => {
 | 
			
		||||
				const webpack = require("..");
 | 
			
		||||
				new webpack.HotModuleReplacementPlugin().apply(c);
 | 
			
		||||
			}
 | 
			
		||||
		]
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,12 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
describe("Validation", () => {
 | 
			
		||||
	const createTestCase = (name, config, fn) => {
 | 
			
		||||
		it("should fail validation for " + name, () => {
 | 
			
		||||
			try {
 | 
			
		||||
				const webpack = require("..");
 | 
			
		||||
				webpack(config);
 | 
			
		||||
			} catch (err) {
 | 
			
		||||
				if (err.name !== "ValidationError") throw err;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,8 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const webpack = require("../");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
 | 
			
		||||
describe("WatchClose", () => {
 | 
			
		||||
	jest.setTimeout(5000);
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ describe("WatchClose", () => {
 | 
			
		|||
		let watcher;
 | 
			
		||||
 | 
			
		||||
		beforeEach(() => {
 | 
			
		||||
			const webpack = require("../");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				mode: "development",
 | 
			
		||||
				entry: filePath,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
 | 
			
		||||
const webpack = require("../");
 | 
			
		||||
 | 
			
		||||
describe("WatchSuspend", () => {
 | 
			
		||||
	if (process.env.NO_WATCH_TESTS) {
 | 
			
		||||
		it.skip("long running tests excluded", () => {});
 | 
			
		||||
| 
						 | 
				
			
			@ -41,6 +41,7 @@ describe("WatchSuspend", () => {
 | 
			
		|||
			} catch (e) {
 | 
			
		||||
				// skip
 | 
			
		||||
			}
 | 
			
		||||
			const webpack = require("../");
 | 
			
		||||
			compiler = webpack({
 | 
			
		||||
				mode: "development",
 | 
			
		||||
				entry: filePath,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
require("./helpers/warmup-webpack");
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const fs = require("graceful-fs");
 | 
			
		||||
const vm = require("vm");
 | 
			
		||||
| 
						 | 
				
			
			@ -11,8 +13,6 @@ const prepareOptions = require("./helpers/prepareOptions");
 | 
			
		|||
const deprecationTracking = require("./helpers/deprecationTracking");
 | 
			
		||||
const FakeDocument = require("./helpers/FakeDocument");
 | 
			
		||||
 | 
			
		||||
const webpack = require("..");
 | 
			
		||||
 | 
			
		||||
function copyDiff(src, dest, initial) {
 | 
			
		||||
	if (!fs.existsSync(dest)) fs.mkdirSync(dest);
 | 
			
		||||
	const files = fs.readdirSync(src);
 | 
			
		||||
| 
						 | 
				
			
			@ -156,6 +156,7 @@ describe("WatchTestCases", () => {
 | 
			
		|||
 | 
			
		||||
							setTimeout(() => {
 | 
			
		||||
								const deprecationTracker = deprecationTracking.start();
 | 
			
		||||
								const webpack = require("..");
 | 
			
		||||
								const compiler = webpack(options);
 | 
			
		||||
								compiler.hooks.invalid.tap(
 | 
			
		||||
									"WatchTestCasesTest",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
describe("warmup", () => {
 | 
			
		||||
	it("should warmup webpack", done => {
 | 
			
		||||
		let webpack = require("../../");
 | 
			
		||||
		let END = new Error("end warmup");
 | 
			
		||||
		webpack(
 | 
			
		||||
			{
 | 
			
		||||
				entry: "data:text/javascript,import 'data:text/javascript,'",
 | 
			
		||||
				plugins: [
 | 
			
		||||
					c =>
 | 
			
		||||
						c.hooks.emit.tap("Warmup", () => {
 | 
			
		||||
							throw END;
 | 
			
		||||
						})
 | 
			
		||||
				]
 | 
			
		||||
			},
 | 
			
		||||
			err => {
 | 
			
		||||
				webpack = undefined;
 | 
			
		||||
				try {
 | 
			
		||||
					expect(err).toBe(END);
 | 
			
		||||
					done();
 | 
			
		||||
				} catch (e) {
 | 
			
		||||
					done(e);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		);
 | 
			
		||||
	}, 120000);
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
		Reference in New Issue