Skip to content

HMR API exist in production build #4300

@JSerFeng

Description

@JSerFeng

System Info

System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Max
Memory: 2.40 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.0/bin/yarn
npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
pnpm: 8.6.9 - ~/.nvm/versions/node/v18.14.0/bin/pnpm
Browsers:
Chrome: 117.0.5938.149
Safari: 17.0
npmPackages:
@rspack/cli: ^0.3.6 => 0.3.6

Details

import.meta.hot and import.meta.webpackHot exist in production build.

input:

if (import.meta.hot) {
  import.meta.hot.accept();
}
if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}
if (module.hot) {
  module.hot.accept()
}

webpack output:

if (false) {}
if (false) {}
if (false) {}

rspack output

if (undefined) undefined();
if (import.meta.webpackHot) import.meta.webpackHot.accept();
if (module.hot) module.hot.accept();

Reproduce link

https://github.com/JSerFeng/rspack-issues

Reproduce Steps

pnpm i

see the differences between pnpm run build:webpack and pnpm run build:rspack

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleteamThe issue/pr is created by the member of Rspack.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions