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

[docs] Document config.clientBootstrap #3449

Closed
1 task done
harriha opened this issue Dec 13, 2017 · 4 comments
Closed
1 task done

[docs] Document config.clientBootstrap #3449

harriha opened this issue Dec 13, 2017 · 4 comments
Assignees

Comments

@harriha
Copy link
Contributor

harriha commented Dec 13, 2017

The recently added config option for adding a custom bootstrap file to the main bundle is mentioned only in comments here and there so far, so thought to turn this into an actual task for clarity.

References:

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

I'd expect to

As a side note, it seems that there are no tests exercising this config option, but perhaps that can be seen as a different task than these docs.

Notes

Something to be aware of with this config (and the docs): sadly this option does not help with everything. I tried to add EventSource polyfill for webpack-hot-middleware to make the dev mode work in IE11, but this custom bootstrap is injected too late and thus it does not help with this kind of polyfilling.

@timneutkens
Copy link
Member

@arunoda made an example internally, he can commit it to the repository 👍

@designspin
Copy link

I'm trying to run a polyfill for intersection-observer using the clientBootstrap:

async function loadPolyfills() {
	const polyfills = [];
	console.log("Running polyfills!");
	if(!supportsIntersectionObserver()) {
		polyfills.push(import('intersection-observer'))
	}

	let all = await Promise.all(polyfills);
	return all;
}

function supportsIntersectionObserver() {
	return (
		'IntersectionObserver' in global &&
		'IntersectionObserverEntry' in global &&
		'intersectionRatio' in IntersectionObserverEntry.prototype
	)
}

loadPolyfills().then((polyfills) => {
	console.log(polyfills);
});

Unfortunately my react code is starting before the polyfill loads. What am I missing here?

@arunoda
Copy link
Contributor

arunoda commented Jan 14, 2018

We might remove clientBootstrap feature from Next.js in the future.
So instead use this: #3568

It's the same as clientBootstrap, but just using webpack config.

@arunoda arunoda closed this as completed Jan 14, 2018
@arunoda
Copy link
Contributor

arunoda commented Jan 14, 2018

@designspin your issue is because of the promise usage.
Try to load polyfills using NPM as shown in the ^^ mentioned example.
If not, start a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants