somewind / amd-webpack-plugin

make split chunks be AMD modules
MIT License
4 stars 1 forks source link

Webpack5 compatibility #4

Open breezewish opened 4 years ago

breezewish commented 4 years ago

Thanks for the project! I tried to use this plugin in Webpack 5 using the example in the README, but unfortunately it doesn't work with the following error message:

library name must be a string for amd target

It looks to be fine in Webpack 4 though, without changing anything :)

inspiraller commented 2 years ago

I'm also investigating this. I just forked the project.

So far I just changed

lib/index.js

Find original: new webpack.HashedModuleIdsPlugin(this.hashedModuleIds || { Replace with: new webpack.ids.HashedModuleIdsPlugin(this.hashedModuleIds || {

The next problem I'm having is when index.js imports an extended plugin - ExternalModuleFactoryOverridePlugin.js

lib/index.js

    // use root external
    const ExternalsOverridePlugin = require('./ExternalsOverridePlugin')

    new ExternalsOverridePlugin(options).apply(compiler)

    // inject amd modules
    compiler.hooks.thisCompilation.tap('AmdWebpackPlugin', compilation => {

Error: TypeError: Cannot read properties of undefined (reading 'hooks')

ExternalModuleFactoryOverridePlugin.js

  • compiler.hooks.normalModuleFactory - Does not exist
    apply (compiler) {
    const globalType = this.type
    console.log('ExternalModuleFactor - compiler.hooks = ', compiler.hooks)
    compiler.hooks.normalModuleFactory.tap(

Not sure why, but maybe its to do with a plugin loading another plugin.