* Load a Workbox module by passing in the appropriate module name. * * This is not generally needed unless you know there are modules that are * dynamically used and you want to safe guard use of the module while the * user may be offline. * * @param {string} moduleName * * @
(moduleName)
| 168 | * @alias workbox.loadModule |
| 169 | */ |
| 170 | loadModule(moduleName) { |
| 171 | const modulePath = this._getImportPath(moduleName); |
| 172 | try { |
| 173 | importScripts(modulePath); |
| 174 | this._modulesLoaded = true; |
| 175 | } catch (err) { |
| 176 | // TODO Add context of this error if using the CDN vs the local file. |
| 177 | |
| 178 | // We can't rely on workbox-core being loaded so using console |
| 179 | // eslint-disable-next-line |
| 180 | console.error( |
| 181 | `Unable to import module '${moduleName}' from '${modulePath}'.`); |
| 182 | throw err; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * This method will get the path / CDN URL to be used for importScript calls. |
no test coverage detected