xz64 / license-webpack-plugin

Outputs licenses from 3rd party libraries to a file
ISC License
165 stars 51 forks source link

webpack 5: optimizeChunkAssets is deprecated #84

Closed silverwind closed 3 years ago

silverwind commented 3 years ago

Using webpack@5.1.2:

(node:59342) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hook.processAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)
    at node_modules/license-webpack-plugin/dist/WebpackCompilerHandler.js:32:55
    at Hook.eval [as call] (eval at create (node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:9:1)
    at Hook.CALL_DELEGATE [as _call] (node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (node_modules/webpack/lib/Compiler.js:918:30)
    at node_modules/webpack/lib/Compiler.js:960:29
    at Hook.eval [as callAsync] (eval at create (node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (node_modules/webpack/lib/Compiler.js:955:28)
    at node_modules/webpack/lib/Compiler.js:456:12
    at Compiler.readRecords (node_modules/webpack/lib/Compiler.js:797:11)

Configuration:

new LicenseWebpackPlugin({
  outputFilename: 'js/licenses.txt',
  perChunkOutput: false,
  addBanner: false,
  skipChildCompilers: true,
  modulesDirectories: [
    resolve(__dirname, 'node_modules'),
  ],
  additionalModules: [
    '@primer/octicons',
  ].map((name) => ({name, directory: resolve(__dirname, `node_modules/${name}`)})),
  renderLicenses: (modules) => {
    const line = '-'.repeat(80);
    return modules.map((module) => {
      const {name, version} = module.packageJson;
      const {licenseId, licenseText} = module;
      const body = wrapAnsi(licenseText || '', 80);
      return `${line}\n${name}@${version} - ${licenseId}\n${line}\n${body}`;
    }).join('\n');
  },
  stats: {
    warnings: false,
    errors: true,
  },
}
xz64 commented 3 years ago

Fixed in v2.3.1.