Skip to content

Import issue with @rspack/plugin-react-refresh (ReactRefreshRspackPlugin is not exported as default) #33

@mcantonbul

Description

@mcantonbul

When trying to use the @rspack/plugin-react-refresh module, importing the ReactRefreshRspackPlugin class via import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh"; results in an undefined error.

Expected Behavior:

The ReactRefreshRspackPlugin class should be correctly imported from the module, with the correct usage being:

import ReactRefreshRspackPlugin from "@rspack/plugin-react-refresh";

Actual Behavior:

Using import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh"; returns undefined, causing errors when trying to use new RefreshPlugin().

Workaround Solution:

import * as RefreshPluginModule from "@rspack/plugin-react-refresh";

// Get the actual class from the module
const ReactRefreshRspackPlugin = RefreshPluginModule.ReactRefreshRspackPlugin || RefreshPluginModule.default || RefreshPluginModule;

plugins: [
  new ReactRefreshRspackPlugin()
]

Rspack Version: 1.3.8
Rspack-Plugin-React-Refresh Version: 1.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions