Skip to content

react-hot-loader breaks the page without react #1159

@a1ooha

Description

@a1ooha

Description

My project has a lot of pages, some of which don't use react, react-hot-loader breaks these pages.

Expected behavior

no react-hot-loader code in the js of the page.

Actual behavior

image
image

i add react in webpack externals, but do not add cdn link in this page. and react-hot-loader requires it, so "React is not defined", but i really don't need react. If i remove react-hot-loader/babel in .babelrc or remove react in externals or add cdn link in this page, everything will be ok.

Environment

React Hot Loader version: 4.2.0

Run these commands in the project folder and fill in their results:

  1. node -v: 8.11.3
  2. npm -v: 6.4.0

Reproducible Demo

.babelrc

{
    "presets": [
        [
            "env",
            {
                "targets": {
                    "node": "current",
                    "browsers": ["Android >= 4", "iOS >= 8", "last 3 versions"]
                }
            }
        ],
        "react"
    ],
    "plugins": [
        "transform-object-assign",
        "react-hot-loader/babel",
        "transform-class-properties",
        [
            "transform-runtime",
            {
                "polyfill": false,
                "regenerator": true
            }
        ]
    ]
}

webpack externals

externals: {
    vue: 'Vue',
    react: 'React',
    'react-dom': 'ReactDOM',
    'prop-types': 'PropTypes',
}

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