Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5 support #49

Open
donferi opened this issue Oct 20, 2020 · 4 comments
Open

Webpack 5 support #49

donferi opened this issue Oct 20, 2020 · 4 comments

Comments

@donferi
Copy link

donferi commented Oct 20, 2020

Trying to upgrade a repo to use webpack 5 but I keep getting this:

ERROR in  (./node_modules/webpack-inject-plugin/dist/webpack-inject-plugin.loader.js?id=webpack-inject-module-2!)
Module build failed (from ./node_modules/file-loader/dist/cjs.js):
TypeError: argument 'value' must be either string of Buffer
@deini
Copy link
Contributor

deini commented Oct 26, 2020

I'm experiencing the same issue when combined with file-loader + oneOf.

Simplified repro on webpack 5, modified example/webpack.config.js to:

const InjectPlugin = require('..').default;

module.exports = {
  entry: './entry.js',
  mode: 'development',
  plugins: [
    new InjectPlugin(() => `console.log('hello world');`),
    new InjectPlugin(() => `console.log('second injected code');`)
  ],
  module: {
    rules: [
      {
        oneOf: [
          {
            exclude: [/webpack-inject/],
            loader: require.resolve('file-loader'),
          }
        ]
      }
    ]
  }
};

Seems like now its trying to use file-loader on webpack-inject-plugin.loader.js?id=webpack-inject-module-1. Tried excluding it but haven't been able to get it to work yet.

Will try to investigate a bit more, lmk if you have any ideas @adierkens 🙏

@lobsterkatie
Copy link

To support webpack 5 it'll also be necessary to account for the possibility of entry descriptor syntax - see https://webpack.js.org/configuration/entry-context/#entry-descriptor.

Cheers!

@flakey-bit
Copy link

Looks like someone has done some work on Webpack5 support already: https://github.com/bpnetguy/webpack-inject-plugin

@bpnetguy

@zhangHongEn
Copy link

zhangHongEn commented Nov 14, 2022

I also need this plugin in webpack5, so I have to implement a version myself, Code injection can be performed by scopes ["entry", "remoteEntry", "exposesEntry"]

inject-webpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants