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

Add url dependency for serviceWorker.register calls #398

Merged
merged 3 commits into from
Dec 29, 2017
Merged

Add url dependency for serviceWorker.register calls #398

merged 3 commits into from
Dec 29, 2017

Conversation

jdanyow
Copy link
Contributor

@jdanyow jdanyow commented Dec 25, 2017

Adds support for serviceWorker.register('foo.js').

Maybe we should support self.importScripts('foo.js', 'bar.js', ...); too?

callee.object !== undefined &&
callee.object.property !== undefined &&
callee.object.property.name === 'serviceWorker' &&
types.isStringLiteral(args[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is getting a bit unwieldy. maybe we could extract the matchesPattern helper from here and use that?

const isRegisterServiceWorker = matchesPattern(callee, 'navigator.serviceWorker.register');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (isRegisterServiceWorker) {
let assetPath = asset.addURLDependency(args[0].value);
if (!isURL(assetPath)) {
assetPath = urlJoin(asset.options.publicURL, assetPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should just make addURLDependency include the publicURL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure- CSSAsset, LESSAsset, SASSAsset and StylusAsset use addURLDependency's return value without prefixing with the public url. Will prefixing with the public url by default cause problems in these asset types?

@devongovett devongovett merged commit 0ab0aca into parcel-bundler:master Dec 29, 2017
@devongovett devongovett mentioned this pull request Dec 30, 2017
devongovett pushed a commit that referenced this pull request Oct 15, 2018
* Add url dependency for serviceWorker.register calls

* extract matchesPattern helper

* sync SW regexp with matchesPattern arg
devongovett pushed a commit that referenced this pull request Oct 15, 2018
* Add url dependency for serviceWorker.register calls

* extract matchesPattern helper

* sync SW regexp with matchesPattern arg
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 this pull request may close these issues.

2 participants