score:0
fips' answer helped me get on the right track.
i am not using a bundler/compiler, which seems like a the avenue to pursue.
however, for anyone else that this may help:
importscripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.3/workbox-sw.js');
workbox.precaching.precacheandroute(self.__wb_manifest);
fits well to those trying to solve some examples from googles documentation
or more specific to your code, all those modules are accessible as attributes on the workbox
object.
importscripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.3/workbox-sw.js');
self.addeventlistener('message', event => {
if (event.data && event.data.type === 'skip_waiting') {
self.skipwaiting();
}
});
workbox.core.clientsclaim();
workbox.routing.registerroute(/* your params here */);
workbox.precaching.precacheandroute(/* your params here */);
// presuming op function is deprecated in current version and changed
// to 'registerroute', but may actually be 'navigationroute' check
// current documentation for more clarity.
workbox.routing.registerroute(/* your params here */);
score:8
there is no module support in workers yet.
importscripts() could do the job for you, but it can not import modules, meaning anything with an "export" keyword inside.
https://developer.mozilla.org/en-us/docs/web/api/workerglobalscope/importscripts
Source: stackoverflow.com
Related Query
- Workbox service worker: Cannot use import statement outside a module
- Jest - SyntaxError: Cannot use import statement outside a module
- SyntaxError: Cannot use import statement outside a module when start NodeJS from IntellijIDEA
- React-Image-Annotate - SyntaxError: Cannot use import statement outside a module
- cannot use import statement outside a module with Next.js
- react jest : Cannot use import statement outside a module
- Storybook main.ts: Cannot use import statement outside a module
- MUI5 not working with jest - SyntaxError: Cannot use import statement outside a module
- Uncaught SyntaxError: Cannot use import statement outside a module using reactjs CDN Links
- Cannot use import statement outside a module @emotion
- React CKeditor Jest error: SyntaxError: Cannot use import statement outside a module
- ReactJS inside .NET framework project - Cannot use import statement outside a module
- SyntaxError: Cannot use import statement outside a module React JS Antd
- Jest - Cannot use import statement outside a module - using Rescript
- Nextjs Redux Persist Error - SyntaxError: Cannot use import statement outside a module
- Cannot use import statement outside a module babel
- ASP.NET - Uncaught SyntaxError: Cannot use import statement outside a module
- react-styleguidist - example with Component as a prop - SyntaxError: Cannot use import statement outside a module
- SyntaxError: Cannot use import statement outside a module while using `fast-image-zoom`
- SyntaxError: Cannot use import statement outside a module -- React
- Cannot use import statement outside a module error in React JS + JEST + Antd
- Uncaught SyntaxError Cannot use import statement outside a module
- Web Worker - Jest - Cannot use 'import.meta' outside a module
- How to fix "SyntaxError: Cannot use import statement outside a module"
- Using @SVGR/cli with a template example is throwing `SyntaxError: Cannot use import statement outside a module`
- "Uncaught SyntaxError: Cannot use import statement outside a module" When Importing ReactJS
- Error "SyntaxError: Cannot use import statement outside a module" when deploying React app with Netlify Functions
- Importing React = 'SyntaxError: Cannot use import statement outside a module'
- "Uncaught SyntaxError: Cannot use import statement outside a module" error in reactjs
- When I wants to run my code in local server i always get this kinds of error "SyntaxError: Cannot use import statement outside a module"
More Query from same tag
- Handle react event and legacy library event together
- Import scss in react
- Specify axios response data type
- React create constants file
- Infinite loop in Redux Saga
- How to fix this "React Hook useEffect has a missing dependency" warning?
- Migration to React 16.0.0 Error: Cannot find module "react/lib/ReactComponentTreeHook"
- Make a field or all fields required in React
- Does a React application HAVE to run on its own server process?
- Adding Extra Data with File upload using springBoot and ReactJs
- How do I set the response header from a server using an apollo server?
- What is default css display value for react web application?
- TypeError: Assignment to constant variable. React.js Hook
- how can i append selected row data in another table
- Uncaught TypeError: Cannot read properties of undefined (reading 'map') & React Props Rules
- CSS grid make items same height
- React Fullcalendar - column header format
- Create React App SyntaxError: Unexpected Token
- Adding debounce to mobx function
- (error) AWS as backend installing amplify libraries
- Antlr4 parsing templateLiteral in jsx
- React context menu & watch for prop changes
- Lazy loading embedded YouTube videos in React
- change position landscape or portrait in react
- Setting a default value for a select when select is based on API call
- How to fill the horizontal space between two divs using dotted/dashed line using CSS
- Grid Size isn't changing properly in React when changing state
- Error withRef is removed. To access the wrapped instance, use a ref on the connected component when using Redux Form
- Cloudinary image upload from React: am including Cloudinary unsigned preset but get "Upload preset must be specified when using unsigned upload"
- javascript iframe set timer and check if loaded