MCPcopy
hub / github.com/GoogleChrome/workbox / loadModule

Method loadModule

packages/workbox-sw/controllers/WorkboxSW.mjs:170–184  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 3

getMethod · 0.80
sw.jsFile · 0.80
sw.jsFile · 0.80

Calls 1

_getImportPathMethod · 0.95

Tested by

no test coverage detected