webpack: Regression on v5.99.0, [something] not defined

Bug report

What is the current behavior?

Webpack builds the artefact just fine. When running the app, there is a reference error, which prevents the app from running.

I’ve verified version 5.99.0 is affected by downgrading to 5.98.0, on which the app works as expected. The same behaviour is observed in a production and development build (including the hot-reload setup).

Image

If the current behavior is a bug, please provide the steps to reproduce.

Reporting this as soon as confirmed, but root cause is not detected just yet. Not enough time (yet) to provide a minimal reproduction.

What is the expected behavior?

Other relevant information: webpack version: 5.99.0 Node.js version: v22.14.0 Operating System: MacOS and Ubuntu Additional tools: n/a

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 18
  • Comments: 81 (40 by maintainers)

Commits related to this issue

Most upvoted comments

Please try - https://github.com/webpack/webpack/releases/tag/v5.99.1 and feedback welcome, hope catch all cases

Repro: https://github.com/thorn0/webpack-5.99.0-repro Works fine with 5.98.0. Errors with 5.99.0:

Uncaught TypeError: Cannot read properties of undefined (reading 'call')
    at __webpack_require__ (main.js:2:166143)
    at Object.modules (main.js:2:77260)
    at __nested_webpack_require_186993__ (main.js:2:78759)
    at factory (main.js:2:78515)
    at 98 (main.js:2:78869)
    at __webpack_require__ (main.js:2:166143)
    at main.js:2:166582
    at main.js:2:166607
    at main.js:2:166611

I will add your test case to avoid future regressions, anyway thank you

Ok, actually nevermind. It does seem like one of the other changes fixed the issue. I was using an outdated version of webpack still. Sorry for the noise.

Namely, here:

https://github.com/ruffle-rs/ruffle/blob/5aa7f0276a78e9c222ff927539dce86c8876c73d/web/packages/extension/src/background.ts#L55-L61

I got Uncaught (in promise) ReferenceError: utils is not defined. utils is an import and the uses of it in try/catch were replaced just fine.

Looks like we fixed all cases I am going to close, anyway if you faced with this problem feel free to feedback or open anew issue, thank you everyone to help with examples and repos

@alexander-akait I’ve tried 5.99.5 with demo project and the main one - both works so far, at least the issue with assert from tss-react now gone. I’ll do some more tests and let you know.

Thanks a lot!

@alexander-akait I’m really sorry, but I think issue (or some of it’s part) is still somewhere here. I’ve made a demo-repo https://github.com/rtm-ctrlz/webpack-demo-issue19394 that still reproduces this issue, even with 5.99.4 version. It has some outdated deps, but changing webpack version 5.98.0 <-> 5.99.x makes project work (or not). I used dev-server for tests - I my project I have issue in all build dev/production with and without dev-server. Hope it will help.

P.S. BTW @GrantBartlett thanks for your template!

I also faced that issue in my project, I had ReferenceError: assert is not defined error, im my case it was assert function that is used (and bundled) by tss-react library. Using webpack versions 5.99.0...5.99.3 was building project with issue, but 5.99.4 managed to build application without that issue.

Thanks @alexander-akait for your fixes!

@RaananW Please try https://github.com/webpack/webpack/releases/tag/v5.99.4

Working correctly now (at least in one snippet that didn’t work). Will continue testing. You are awesome, thanks for the quick fix.

@RaananW Found a problem WIP, hope is it the last

Thank you so much for the update!

@RaananW Found a problem WIP, hope is it the last

@RaananW Which webpack version do you use? Please run npm ls webpack

5.99.3 across the board

@ileandreKU Just update webpack to the latest version, always verify it using npm ls webpack

If this helps, here is a snippet of code generated using 5.99.3:

constructor(
    /** defines the manager's name */
    name, imgUrl, capacity, cellSize, scene, epsilon = 0.01, samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__.Texture.TRILINEAR_SAMPLINGMODE, fromPacked = false, spriteJSON = null, options) {

        console.log(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__.Texture, 1);

        if (!scene) {
            scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__.EngineStore.LastCreatedScene;
        }
        if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__.SceneComponentConstants.NAME_SPRITE)) {
            scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_3__.SpriteSceneComponent(scene));
        }
        this._fromPacked = fromPacked;
        this._scene = scene;
        const engine = this._scene.getEngine();
        this._spriteRenderer = new _spriteRenderer__WEBPACK_IMPORTED_MODULE_10__.SpriteRenderer(engine, capacity, epsilon, scene, options?.spriteRendererOptions);

        console.log(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__.Texture, 2);

        if (cellSize.width && cellSize.height) {
            this.cellWidth = cellSize.width;
            this.cellHeight = cellSize.height;
        }
        else if (cellSize !== undefined) {
            this.cellWidth = cellSize;
            this.cellHeight = cellSize;
        }
        else {
            this._spriteRenderer = null;
            return;
        }

        console.log(Texture, 3);

        this._scene.spriteManagers && this._scene.spriteManagers.push(this);
        this.uniqueId = this.scene.getUniqueId();

        console.log(Texture, 4);

        if (imgUrl) {
            this.texture = new Texture(imgUrl, scene, true, false, samplingMode);
        }
        if (this._fromPacked) {
            this._makePacked(imgUrl, spriteJSON);
        }
    }

The important reference is the “console.log” calls. They all log the same variable - a class imported, calls Texture. For some reason, between the 2nd and 3rd log, the webpack reference is gone.

I get this too, only 5.98.0 works, all 5.99.x are broken.

@alexander-akait Thanks for version 5.99.3! I was encountering the Cannot use 'import.meta' outside a module error with react-router in version 5.99 after upgrading from 5.98. However, the latest release (or one of the three recent patch releases) resolved the issue, though I’m not sure which one exactly. Either way, everything is working again.

@alexander-akait for my app v5.99.2 works 👍

No issues so far with 5.99.2 for me, previously had process is not defined with 5.99.0.

@MarshallOfSound Found a place and reproduce, WIP on fix, thanks for screenshot, it really helps

@alexander-akait here is the minified bundle output that had the error --> https://gist.github.com/MarshallOfSound/13dd3307261f26797ef908379821bef2

The error specifically in our bundle was MessageFormatError is not defined

That class is part of the open source react-intl package or one of it’s dependencies, I’ve tried to repro in an isolated webpack build but unfortunately without much success. Let me know if there’s anything that makes this easier to track for you

@alexander-akait, we also struggled with the symptoms described here and 5.99.1 resolved them for us. Thank you!

This might be related but I also started having issues this morning: When upgrading to webpack 5.99.0, our application started experiencing a runtime error: ReferenceError: shouldCancel is not defined in redux-saga. This error occurs at runtime in the redux-saga core module, specifically at redux-saga-core.esm.js:1150:14 in the next function of the compile module. But in reality it seems the webpack update affects the import of the shouldCancel function