Skip to content

[BUG] Using redux in background.ts because the related dependency package references window. #401

Closed

Description

@Mis-tian

What happened?

A bug happened!
image
image
image

Hi, using redux in background.ts, I found the problem as shown above, because the related dependency package references window (there is no window in Service Worker)

For example, the situation is that a custom axios is introduced in the createAsyncThunk method, and the axios wrapper internally introduces antd's message component to handle some generic error alerts. Currently it works fine after I clear the message component code.

Also tell us, what did you expect to happen?
This is probably not a bug, more like an optimization。
Is there any suggestion to avoid this problem, and is it possible to consider a package build of background.ts that excludes window related code.

Version

Latest

What OS are you seeing the problem on?

No response

What browsers are you seeing the problem on?

No response

Relevant log output

var webpackHMR = false;
function useDevHMR() {
    return webpackHMR;
}
exports.default = useDevHMR; // Webpack `module.hot.accept` do not support any deps update trigger
// We have to hack handler to force mark as HRM
if (module && module.hot) {
    var win = window;
    if (typeof win.webpackHotUpdate === "function") {
        var originWebpackHotUpdate = win.webpackHotUpdate;
        win.webpackHotUpdate = function() {
            webpackHMR = true;
            setTimeout(function() {
                webpackHMR = false;
            }, 0);
            return originWebpackHotUpdate.apply(void 0, arguments);
        };
    }
}

},{"@parcel/transformer-js/src/esmodule-helpers.js":"hCtEe"}],

(OPTIONAL) Contact Details

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.

Activity

  1. added
    bug
    on Jan 14, 2023
  2. changed the title [-][BUG] The dependency causes the plugin to fail to run related to[/-] [+][BUG] Using redux in background.ts because the related dependency package references window.[/+] on Jan 14, 2023
  3. locked and limited conversation to collaborators on Jan 15, 2023
  4. converted this issue into a discussion #402 on Jan 15, 2023
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions