-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
src/visitors/dependencies.js
Outdated
callee.object !== undefined && | ||
callee.object.property !== undefined && | ||
callee.object.property.name === 'serviceWorker' && | ||
types.isStringLiteral(args[0]); |
There was a problem hiding this comment.
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');
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
* Add url dependency for serviceWorker.register calls * extract matchesPattern helper * sync SW regexp with matchesPattern arg
* Add url dependency for serviceWorker.register calls * extract matchesPattern helper * sync SW regexp with matchesPattern arg
Adds support for
serviceWorker.register('foo.js')
.Maybe we should support
self.importScripts('foo.js', 'bar.js', ...);
too?