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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

module.hot not replace to false in production build #3870

Open
MegaJSDeveloper opened this issue Dec 3, 2019 · 2 comments
Open

module.hot not replace to false in production build #3870

MegaJSDeveloper opened this issue Dec 3, 2019 · 2 comments

Comments

@MegaJSDeveloper
Copy link

MegaJSDeveloper commented Dec 3, 2019

馃悰 bug report

module.hot not replace to false in production build

馃 Expected Behavior

index.html

<script src="script.js"></script>

script.js

if (module.hot) {
	module.hot.dispose(function () {
		console.log('OLOLOOOOO')
	})
}

in production build all code like module.hot will be replace to false, like:

if (false) {
	module.hot.dispose(function () {
		console.log('OLOLOOOOO')
	})
}

and minificator will remove all if(false){ } code blocks from production build

馃槸 Current Behavior in Parcel v1.12.4

hot reload code get to the production bundle:

}({
	"mpVp": [function (require, module, exports) {
		module.hot && module.hot.dispose(function () {
			console.log("OLOLOOOOO")
		});
	}, {}]
}, {}, ["mpVp"], null)

this is not a good idea

馃拋 Possible Solution

you must replace module.hot in all scripts to false keyword, that's exactly what webpack does.

I use Parcel v1.12.4

@DeMoorJasper
Copy link
Member

what is the parcel version? Or the command you ran?

@MegaJSDeveloper
Copy link
Author

MegaJSDeveloper commented Dec 3, 2019

@DeMoorJasper parcel v1.12.4

command:

parcel build index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants