123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- const cachePrefix = require('.').cachePrefix;
- const LoggerFactory = require('../loggerFactory');
- exports.moduleFreezeError = (compilation, module, e) => {
- const loggerSerial = LoggerFactory.getLogger(compilation).from('serial');
- const compilerName = compilation.compiler.name;
- const compilerContext = compilation.compiler.options.context;
- const identifierPrefix = cachePrefix(compilation);
- const moduleIdentifier = module.identifier();
- const shortener = new (require('webpack/lib/RequestShortener'))(
- compilerContext,
- );
- const moduleReadable = module.readableIdentifier(shortener);
- loggerSerial.error(
- {
- id: 'serialization--error-freezing-module',
- identifierPrefix,
- compilerName,
- moduleIdentifier,
- moduleReadable,
- error: e,
- errorMessage: e.message,
- errorStack: e.stack,
- },
- `Unable to freeze module "${moduleReadable}${
- compilerName ? `" in compilation "${compilerName}` : ''
- }". An error occured serializing it into a string: ${e.message}`,
- );
- };
- exports.cacheNoParity = (compiler, { parityRoot }) => {
- const loggerSerial = new LoggerFactory(compiler).create().from('serial');
- loggerSerial.error(
- {
- id: 'serialzation--cache-incomplete',
- parityRoot,
- },
- [
- `Previous cache did not complete parity check. ${parityRoot.reason}`,
- 'Resetting cache.',
- ].join('\n'),
- );
- };
- exports.serialBadCache = (compiler, error) => {
- const loggerSerial = new LoggerFactory(compiler).create().from('serial');
- loggerSerial.error(
- {
- id: 'serialzation--bad-cache',
- },
- ['Cache is corrupted.', error.stack || error.message || error].join('\n'),
- );
- };
- const logCore = compiler => new LoggerFactory(compiler).create().from('core');
- exports.configHashSetButNotUsed = (compiler, { cacheDirectory }) => {
- const loggerCore = logCore(compiler);
- loggerCore.error(
- {
- id: 'confighash--directory-no-confighash',
- cacheDirectory: cacheDirectory,
- },
- 'HardSourceWebpackPlugin cannot use [confighash] in cacheDirectory ' +
- 'without configHash option being set and returning a non-falsy value.',
- );
- };
- exports.configHashFirstBuild = (compiler, { cacheDirPath, configHash }) => {
- const loggerCore = logCore(compiler);
- loggerCore.log(
- {
- id: 'confighash--new',
- cacheDirPath,
- configHash,
- },
- `HardSourceWebpackPlugin is writing to a new confighash path for the first time: ${cacheDirPath}`,
- );
- };
- exports.configHashBuildWith = (compiler, { cacheDirPath, configHash }) => {
- const loggerCore = logCore(compiler);
- loggerCore.log(
- {
- id: 'confighash--reused',
- cacheDirPath,
- configHash,
- },
- `HardSourceWebpackPlugin is reading from and writing to a confighash path: ${cacheDirPath}`,
- );
- };
- exports.deleteOldCaches = (compiler, { newTotalSize, oldTotalSize }) => {
- const loggerCore = logCore(compiler);
- const sizeMB = Math.ceil(newTotalSize / 1024 / 1024);
- const deletedSizeMB = Math.ceil(oldTotalSize / 1024 / 1024);
- loggerCore.log(
- {
- id: 'caches--delete-old',
- size: newTotalSize,
- sizeMB,
- deletedSize: oldTotalSize,
- deletedSizeMB,
- },
- `HardSourceWebpackPlugin is using ${sizeMB} MB of disk space after deleting ${deletedSizeMB} MB.`,
- );
- };
- exports.keepCaches = (compiler, { totalSize }) => {
- const loggerCore = logCore(compiler);
- const sizeMB = Math.ceil(totalSize / 1024 / 1024);
- loggerCore.log(
- {
- id: 'caches--keep',
- size: totalSize,
- sizeMB,
- },
- `HardSourceWebpackPlugin is using ${sizeMB} MB of disk space.`,
- );
- };
- exports.environmentInputs = (compiler, { inputs }) => {
- const loggerCore = logCore(compiler);
- loggerCore.log(
- {
- id: 'environment--inputs',
- inputs,
- },
- `Tracking environment changes with ${inputs.join(', ')}.`,
- );
- };
- exports.configHashChanged = compiler => {
- const loggerCore = logCore(compiler);
- loggerCore.warn(
- {
- id: 'environment--config-changed',
- },
- 'Environment has changed (configuration was changed).\n' +
- 'HardSourceWebpackPlugin will reset the cache and store a fresh one.',
- );
- };
- exports.environmentHashChanged = compiler => {
- const loggerCore = logCore(compiler);
- loggerCore.warn(
- {
- id: 'environment--changed',
- },
- 'Environment has changed (node_modules was updated).\n' +
- 'HardSourceWebpackPlugin will reset the cache and store a fresh one.',
- );
- };
- exports.hardSourceVersionChanged = compiler => {
- const loggerCore = logCore(compiler);
- loggerCore.warn(
- {
- id: 'environment--hardsource-changed',
- },
- 'Installed HardSource version does not match the saved ' +
- 'cache.\nHardSourceWebpackPlugin will reset the cache and store ' +
- 'a fresh one.',
- );
- };
- exports.childCompilerWithoutCache = compilation => {
- var loggerUtil = LoggerFactory.getLogger(compilation).from('util');
- loggerUtil.error(
- {
- id: 'childcompiler--no-cache',
- compilerName: compilation.compiler.name,
- },
- [
- `A child compiler (${compilation.compiler.name}) does not`,
- "have a memory cache. Enable a memory cache with webpack's",
- '`cache` configuration option. HardSourceWebpackPlugin will be',
- 'disabled for this child compiler until then.',
- ].join('\n'),
- );
- };
- exports.childCompilerUnnamedCache = compilation => {
- var loggerUtil = LoggerFactory.getLogger(compilation).from('util');
- loggerUtil.error(
- {
- id: 'childcompiler--unnamed-cache',
- compilerName: compilation.compiler.name,
- },
- [
- `A child compiler (${compilation.compiler.name}) has a`,
- 'memory cache but its cache name is unknown.',
- 'HardSourceWebpackPlugin will be disabled for this child',
- 'compiler.',
- ].join('\n'),
- );
- };
- const logParallel = compiler =>
- new LoggerFactory(compiler).create().from('parallel');
- exports.parallelStartWorkers = (compiler, options) => {
- const loggerParallel = logParallel(compiler);
- loggerParallel.log(
- {
- id: 'parallel--start-workers',
- numWorkers: options.numWorkers,
- },
- [`Start ${options.numWorkers} module workers.`].join('\n'),
- );
- };
- exports.parallelConfigMismatch = (compiler, options) => {
- const loggerParallel = logParallel(compiler);
- loggerParallel.error(
- {
- id: 'parallel--config-mismatch',
- ourHash: options.ourHash,
- theirHash: options.theirHash,
- },
- [
- `Child process's configuration does not match parent `,
- `configuration. Unable to parallelize webpack.`,
- ].join('\n'),
- );
- };
- exports.parallelErrorSendingJob = (compiler, error) => {
- const loggerParallel = logParallel(compiler);
- loggerParallel.error(
- {
- id: 'parallel--error-sending-job',
- error,
- },
- `Failed to send parallel module work. ${error.stack}`,
- );
- };
- exports.parallelRequireWebpack4 = compiler => {
- const loggerParallel = logParallel(compiler);
- loggerParallel.error(
- {
- id: 'parallel--webpack-4',
- },
- `Parallel Module Plugin requires webpack 4.`,
- );
- };
|