Skip to content

The refresh blows up randomly #526

@kariae

Description

@kariae

Hey, thanks for the awesome package, it's helping a lot.

I'm using it with the following and 2 thirds of the time when I do a change on the code, I have this error, and nothing loads:

Error on Safari:

TypeError: undefined is not an object (evaluating '__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ "./node_modules/react-refresh/runtime.js")')

Error on Chrome:

Uncaught TypeError: Cannot set properties of undefined (setting 'runtime')

The configuration:

webpack: 5.59.1
webpack-cli: 4.9.1
webpack-dev-server 4.3.1
@pmmmwh/react-refresh-webpack-plugin: 0.5.1
react: 17.0.2
react-dom: 17.0.2
react-refresh: 0.10.0

The webpack config:

{
        mode: 'development',
        devtool: 'inline-source-map',
        cache: {
            type: 'filesystem',
            allowCollectingMemory: true,
        },
        devServer: {
            static: './dist',
            hot: true,
            allowedHosts: ['site.local'],
            port: 81,
            headers: {
                'Access-Control-Allow-Origin': '*',
            },
        },
        module: {
            rules: [
                {
                    test: /\.[jt]sx?$/,
                    exclude: /node_modules/,
                    use: [
                        {
                            loader: require.resolve('ts-loader'),
                            options: {
                                getCustomTransformers: () => ({
                                    before: [ReactRefreshTypeScript()].filter(Boolean),
                                }),
                                transpileOnly: true,
                            },
                        },
                    ],
                },
            ],
        },
        plugins: [
            new ReactRefreshWebpackPlugin(),
            new ForkTsCheckerWebpackPlugin({
                eslint: {
                    files: './src/**/*.{ts,tsx,js,jsx}', // required - same as command `eslint ./src/**/*.{ts,tsx,js,jsx} --ext .ts,.tsx,.js,.jsx`
                },
            }),
        ],
    }

I'm happy to debug this if guided as I'm not familiar with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions