Skip to content

Webpack 5 update breaks wrapper-webpack-plugin #21

Description

@bodenloszt

Hello, guys!

I have a Preact project that uses Webpack 4 as it's bundling utility. I want to update to Webpack 5. I encountered lots of errors and changes that had to be done and right now I am almost at the end of it. But I am currently facing a huge blocker.

The project I work on has a webpack-server.config that uses wrapper-webpack-plugin at one point and it looks like this:

        new WrapperPlugin({
            test: /\.js$/,
            header: `
                exports['setupGlobals'] = function (globals) {
                    var navigator = globals.navigator;
                    var location = globals.location;
                            
                    var render = `,
            footer: `
                return { render: render };
            }`
        })

Later it uses setupGlobals().render() as:

const { html, chunks, http2Links } = serverApp.setupGlobals(getGlobals(ctx)).render(clone(state));

After I upgraded Webpack 4 -> Webpack 5, this Wrapper doesn't work anymore. It returns render as undefined so it can't be called.

The build is working webpack 5.84.0 compiled -> Build done! but when I try to access the app via browser, I get error 500 and this error:

500 TypeError: serverApp.setupGlobals(...).render is not a function

Does anyhow have any idea why this wrapper wouldn't work in Webpack 5? Thanks a bunch!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions