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

[2.0 alpha 3.2]TypeError: module.hot is undefined #4063

Open
andriijas opened this issue Jan 30, 2020 · 4 comments · May be fixed by #4094
Open

[2.0 alpha 3.2]TypeError: module.hot is undefined #4063

andriijas opened this issue Jan 30, 2020 · 4 comments · May be fixed by #4094

Comments

@andriijas
Copy link

andriijas commented Jan 30, 2020

🐛 bug report

💻 Code Sample

Reproducible repo: https://github.com/andriijas/parcel-hmr-error

🤔 Expected Behavior

Expect async routes to navigate

😯 Current Behavior

Try open http://localhost:1234/dashboard in browser and then navigate to Foo or Bar in the header navigation

🌍 Your Environment

Software Version(s)
Parcel
Node v13.7.0
npm/Yarn 6.13.6
Operating System macos catalina

🖼 Screenshot

Screenshot 2020-01-30 at 11 29 46

@mischnic
Copy link
Member

mischnic commented Feb 5, 2020

Minimal Reproduction:

// a.js
import React from "react";
import C from "./c";

function A() {
	return (
		<div>
			A
			<C />
		</div>
	);
}

export default A;
// b.js
import React from "react";
import C from "./c";

function B() {
	return (
		<div>
			B
			<C />
		</div>
	);
}

export default B;
// c.js
import React from "react";

function C() {
	return "Common";
}

export default C;
// index.js
import React, { Suspense, lazy } from "react";
import ReactDOM from "react-dom";

let A = lazy(() => import("./a"));
let B = lazy(() => import("./b"));

export default function App(props) {
	return (
		<Suspense fallback={<p>Loading...</p>}>
			<A />
		</Suspense>
	);
}

ReactDOM.render(<App />, document.getElementById("root"));

@mischnic
Copy link
Member

mischnic commented Feb 6, 2020

The HMR runtime isn't executed in the async bundle.

// index.js
import React from "react";

let A = () => import("./a");
let B = () => import("./b");

console.log(A().then(v => v.default));

// a.js
import React from "react";
import C from "./c";

console.log("A", module.hot);

export default "A" + C;

// b.js
import React from "react";
import C from "./c";

console.log("B", module.hot);

export default "B" + C;

// c.js
import React from "react";

console.log("C", module.hot); // undefined

export default "C";

@andriijas
Copy link
Author

@mischnic is this by design or am I doing async bundling wrong?

@mischnic
Copy link
Member

mischnic commented Feb 6, 2020

No, this is a bug.

@mischnic mischnic linked a pull request Feb 7, 2020 that will close this issue
DeMoorJasper pushed a commit that referenced this issue Mar 14, 2020
Related to #4063, This is crashing my app currently, which is async loading a few components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants