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

DebugEngine module.hot error in vite (webpack5 and esm generally?) #434

Open
RobIsHere opened this issue Jun 18, 2023 · 1 comment
Open

Comments

@RobIsHere
Copy link

The error "module is undefined" at module.hot checks in DebugEngine shows up.

After some reading I'm just getting more confused about that.

  • The webpack 5 docs suggest that it has been moved to import.meta.webpackHot because of removal of module
  • The vite docs suggest it has always been in import.meta.hot there (the docs at the rollup plugin)

After all it seems to depend on the bundler and on cjs vs esm modules.
Anyway its uses should be guarded against undefined parent objects and the three diffferent paths ["module.hot", "import.meta.hot", "import.meta.webpackHot"] should all be checked for it IMHO.

@martijndeh
Copy link

Confirmed. DebugEngine is not working in vite.

As a workaround I'm setting the global module:

const m = {
  hot: {
    addStatusHandler: (cb: (status: string) => void) => {
      import.meta.hot?.dispose(() => {
        cb("dispose");
      });
    },
  },
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).module = m;

Make sure to guard this appropriately.

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

2 participants