1

I've migrated my project to WebPack 5 and I'm struggling with following issue:

anytime I try to enable Terser property mangling I'm getting an error

config portion:

// isInvokedInDevServer is true if compiles using dev server
optimization: {
    minimize: true, // todo: fixme
    minimizer: [
        new TerserPlugin({
            parallel: true,
            exclude: /node_modules/,
            extractComments: false,
            terserOptions: {
                output: {
                    comments: /^\**!|@preserve|@license|@cc_on/i,
                },
                ecma: undefined,
                warnings: false,
                parse: {},
                compress: {
                    drop_console: !isInvokedInDevServer,
                    ecma: 6,
                    passes: 2
                },
                mangle: {
                    properties: {
                        keep_quoted: true,
                        debug: isInvokedInDevServer,
                        reserved: propertyMangleReserved, // this is an array
                    },
                    reserved: [
                        "IntersectionObserver",
                        "ResizeObserver"
                    ]
                },
                sourceMap: isInvokedInDevServer ? {
                    url: 'inline'
                } : false,
                module: true,
                toplevel: true,
            }
        }),
        '...'
    ],
},

Error I'm getting:
index.js:816 Uncaught TypeError: Cannot read properties of undefined (reading '_$configureDefaultLogger$true_')

This is for sure not related to any of my code as compiling a single js that contains just a console.log statement yields the same result.

In WebPack 3 I've just included <script src="webpack-dev-server.js" type="text/javascript"></script> in the sources of dev server and it worked, now this file isn't available.

Any ideas?

Artek Wisniewski
  • 797
  • 5
  • 13
  • 1
    Did you read this: https://github.com/terser/terser#cli-mangling-property-names---mangle-props. You should not mangle properties when using a bundler or you don't control all of the source code. – morganney Mar 12 '23 at 14:47

0 Answers0