{"id":13734,"library":"parcel-plugin-sw-asset-urls","title":"Parcel Plugin for Hashed Service Worker Assets","description":"The `parcel-plugin-sw-asset-urls` (version 0.1.2) is a plugin specifically designed for `parcel-bundler` (Parcel v1.x) that addresses a common issue in Progressive Web App (PWA) development. Parcel automatically generates static assets with hashed filenames for effective browser cache busting. However, in Parcel v1, it does not inherently update the `sw.js` (service worker) file with these newly hashed URLs, leading to broken asset paths in the service worker's cache manifest. This plugin integrates into the Parcel v1 build process to replace the original, unhashed asset filenames within the generated service worker script with their corresponding hashed versions in the `dist` directory. This ensures the service worker correctly identifies and caches the fingerprinted assets. The package is currently at an early version (0.1.2) and its development is tied to Parcel v1, making it incompatible with Parcel v2, which has a different plugin architecture and often handles such issues internally or with updated strategies.","status":"abandoned","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/rohith/parcel-plugin-sw-asset-urls","tags":["javascript","parcel","parcel-bundler","parcel-plugin","service worker","pwa","asset urls","hash urls"],"install":[{"cmd":"npm install parcel-plugin-sw-asset-urls","lang":"bash","label":"npm"},{"cmd":"yarn add parcel-plugin-sw-asset-urls","lang":"bash","label":"yarn"},{"cmd":"pnpm add parcel-plugin-sw-asset-urls","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a plugin for Parcel v1 and requires `parcel-bundler` as a peer dependency.","package":"parcel-bundler","optional":false}],"imports":[{"note":"Parcel v1 plugins operate via auto-discovery from `node_modules`. Parcel v2 uses a `.parcelrc` configuration for plugins.","symbol":"No direct imports for userland code.","correct":"This package is a Parcel plugin. It is automatically detected and loaded by `parcel-bundler` (Parcel v1) when installed as a development dependency. There are no explicit symbols to import into your application code."}],"quickstart":{"code":"{\n  \"name\": \"my-pwa\",\n  \"version\": \"1.0.0\",\n  \"devDependencies\": {\n    \"parcel-bundler\": \"^1.12.5\",\n    \"parcel-plugin-sw-asset-urls\": \"^0.1.2\"\n  },\n  \"scripts\": {\n    \"build\": \"parcel build index.html\"\n  }\n}\n\n// index.html\n// This file links to a service worker and some assets.\n// <script>\n//   if ('serviceWorker' in navigator) {\n//     window.addEventListener('load', () => {\n//       navigator.serviceWorker.register('/service-worker.js').then(registration => {\n//         console.log('SW registered: ', registration);\n//       }).catch(error => {\n//         console.log('SW registration failed: ', error);\n//       });\n//     });\n//   }\n// </script>\n// <img src=\"./image.png\" alt=\"example\">\n\n// service-worker.js\n// This service worker explicitly lists assets to cache.\n// const CACHE_NAME = 'my-pwa-cache-v1';\n// const urlsToCache = [\n//   '/',\n//   '/index.html',\n//   '/image.png',\n//   '/app.js' // Assuming app.js is also part of your build\n// ];\n//\n// self.addEventListener('install', (event) => {\n//   event.waitUntil(\n//     caches.open(CACHE_NAME)\n//       .then((cache) => {\n//         console.log('Opened cache');\n//         return cache.addAll(urlsToCache);\n//       })\n//   );\n// });\n\n# 1. Create a project directory and navigate into it\nmkdir my-parcel-pwa && cd my-parcel-pwa\n\n# 2. Initialize npm and install Parcel v1 and the plugin\nnpm init -y\nnpm install parcel-bundler@^1.12.5 parcel-plugin-sw-asset-urls@^0.1.2 -D\n\n# 3. Create dummy files (index.html, service-worker.js, image.png, app.js)\necho '<!DOCTYPE html><html><body><h1>Hello PWA</h1><script>if (\"serviceWorker\" in navigator) { window.addEventListener(\"load\", () => { navigator.serviceWorker.register(\"/service-worker.js\"); }); }</script><img src=\"./image.png\" alt=\"example\"><script src=\"./app.js\"></script></body></html>' > index.html\necho 'self.addEventListener(\"install\", (event) => { event.waitUntil(caches.open(\"v1\").then((cache) => cache.addAll([\"/\", \"/index.html\", \"/image.png\", \"/app.js\"]))); });' > service-worker.js\necho 'console.log(\"App loaded\");' > app.js\necho 'dummy-image-content' > image.png\n\n# 4. Run the Parcel build command (the plugin will activate automatically)\nnpx parcel build index.html\n\n# 5. Inspect the 'dist' directory, particularly the 'service-worker.js' file.\n# You should find that '/image.png' and '/app.js' in 'dist/service-worker.js'\n# have been replaced with their hashed counterparts (e.g., '/image.c36190a6.png').","lang":"bash","description":"This quickstart demonstrates how to set up a minimal Parcel v1 project with the plugin. It shows how the plugin automatically replaces unhashed asset URLs in `service-worker.js` with their fingerprinted versions after a Parcel build, which is crucial for correct PWA caching."},"warnings":[{"fix":"For Parcel v2, consult the official Parcel documentation for handling service workers and asset hashing. Parcel v2 may provide native solutions or require different plugin approaches.","message":"This plugin is designed exclusively for Parcel v1 (`parcel-bundler`) and is not compatible with Parcel v2 (`parcel`). Parcel v2 introduced a new plugin system and significantly changed its internal architecture.","severity":"breaking","affected_versions":">=0.1.2"},{"fix":"Consider alternatives or be prepared to fork and maintain the code yourself if you need this functionality with Parcel v1. For new projects, use Parcel v2, which is actively maintained.","message":"The project appears to be abandoned. The last commit on GitHub was in January 2019, and the package version is 0.1.2. No further updates or maintenance are expected.","severity":"gotcha","affected_versions":">=0.1.2"},{"fix":"Migrate your project to Parcel v2. This will involve updating dependencies (e.g., `parcel-bundler` to `parcel`), adjusting project configuration, and potentially finding new solutions for functionalities previously provided by Parcel v1-specific plugins like this one.","message":"The underlying `parcel-bundler` package (Parcel v1) itself is deprecated and no longer maintained. Users are strongly encouraged to migrate to Parcel v2.","severity":"deprecated","affected_versions":">=0.1.2"}],"env_vars":null,"search_vec":"'0.1.2':16,134 'address':29 'app':36 'architectur':154 'asset':7,13,43,74,97,125,176 'automat':40 'broken':73 'browser':49 'build':90 'bundler':25,169 'bust':51 'cach':50,81,122 'common':31 'correct':119 'correspond':107 'current':129 'design':21 'develop':38,137 'differ':152 'directori':113 'dist':112 'earli':132 'effect':48 'ensur':115 'file':65 'filenam':46,98 'fingerprint':124 'generat':41,101 'handl':157 'hash':4,45,69,108,178 'howev':52 'identifi':120 'incompat':145 'inher':59 'integr':85 'intern':160 'issu':32,159 'javascript':165 'lead':71 'make':143 'manifest':82 'newli':68 'often':156 'origin':95 'packag':127 'parcel':1,10,24,26,39,54,88,141,147,166,168,171 'parcel-bundl':23,167 'parcel-plugin':170 'parcel-plugin-sw-asset-url':9 'path':75 'plugin':2,11,19,84,153,172 'process':91 'progress':34 'pwa':37,175 'replac':93 'script':104 'servic':5,63,78,102,117,173 'specif':20 'static':42 'strategi':164 'sw':12 'sw.js':62 'tie':139 'unhash':96 'updat':60,163 'url':14,70,177,179 'v1':55,89,142 'v1.x':27 'v2':148 'version':15,109,133 'web':35 'within':99 'worker':6,64,79,103,118,174","created_at":"2026-04-20T01:56:02.421853+00:00","updated_at":"2026-04-20T01:56:02.421853+00:00","problems":[{"fix":"Ensure `parcel-bundler` (specifically version 1.x) is installed as a development dependency: `npm install parcel-bundler@^1.11.0 -D` or `yarn add parcel-bundler@^1.11.0 -D`. Verify your `package.json` to confirm the correct Parcel version.","cause":"This error typically occurs if you have `parcel` (Parcel v2) installed but are trying to run a build that expects `parcel-bundler` (Parcel v1), or if `parcel-bundler` is not correctly installed as a development dependency.","error":"Error: Cannot find module 'parcel-bundler'"},{"fix":"Verify that your project is configured to use `parcel-bundler` (Parcel v1). If you intend to use Parcel v2, you will need to find a Parcel v2-compatible solution for updating service worker asset URLs, as this plugin is not compatible.","cause":"This plugin will not function if you are using Parcel v2 instead of Parcel v1. Parcel v2 has a completely different plugin architecture and does not automatically load v1 plugins.","error":"Plugin not working or service worker not updated with hashed URLs."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/rohith/parcel-plugin-sw-asset-urls","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/parcel-plugin-sw-asset-urls","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}