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

Can't resolve 'svelte-loader/lib/hot-api' #49

Closed
Rich-Harris opened this issue Apr 3, 2018 · 0 comments · Fixed by #50
Closed

Can't resolve 'svelte-loader/lib/hot-api' #49

Rich-Harris opened this issue Apr 3, 2018 · 0 comments · Fixed by #50

Comments

@Rich-Harris
Copy link
Member

Kind of an edge case, but if you're using a component that has been linked to your project, it won't be able to resolve hot-api. A plausible fix might be this:

+const resolved = require.resolve('./lib/hot-api');
+
function makeHot(id, code, hotOptions) {
	const options = JSON.stringify(hotOptions);
	const replacement = `

if (module.hot) {

-	const { configure, register, reload } = require('svelte-loader/lib/hot-api');
+	const { configure, register, reload } = require('${resolved}');

	module.hot.accept();

	if (!module.hot.data) {
		// initial load
		configure(${options});
		$2 = register(${id}, $2);
	} else {
		// hot update
		$2 = reload(${id}, $2);
	}
}


export default $2;
`;
Rich-Harris added a commit that referenced this issue Apr 3, 2018
Rich-Harris added a commit that referenced this issue Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant