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

Disabling bundling for specific script #2080

Closed
mischnic opened this issue Sep 29, 2018 · 1 comment
Closed

Disabling bundling for specific script #2080

mischnic opened this issue Sep 29, 2018 · 1 comment
Labels

Comments

@mischnic
Copy link
Member

mischnic commented Sep 29, 2018

❔ Question

Is there a way to disable parcel (especially bundling) on a script tag?

πŸ”¦ Context

My plugin parcel-plugin-sw-cache runs Workbox to create a service worker for (pre)caching. For precaching to work, Workbox runs after bundling has finished to create a list of files and hashes. This means however, that the service-worker.js file doesn't exist during the bundling and parcel throws ENOENT: no such file or directory while parsing the navigator.serviceWorker.register call.
Before 1.10, this worked fine, because script tags weren't parsed.

if ('serviceWorker' in navigator) {
	navigator.serviceWorker.register('service-worker.js')
		.then(function(registration) {
			console.log('Registration successful, scope is:', registration.scope);
		})
		.catch(function(error) {
			console.log('Service worker registration failed, error:', error);
		});
}

Alternatively, how can I make my plugin work, without hack a like this?

const x = 'service-worker.js';
navigator.serviceWorker.register(x);

πŸ’» Code Sample

https://github.com/mischnic/parcel-plugin-sw-cache/blob/2df57ec/example/src/index.html

🌍 Your Environment

Software Version(s)
Parcel 1.10.1
Node
npm/Yarn
Operating System
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants