Skip to content
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 Parcel plugin to avoid hashing of specific bundles #448

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/hashing/subtests/avoid-hash/parcel/.parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@parcel/config-default",
"namers": ["parcel-namer-custom", "..."]
}
10 changes: 7 additions & 3 deletions tests/hashing/subtests/avoid-hash/parcel/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
result: partial
issue: https://github.com/parcel-bundler/parcel/issues/4553
result: pass
issue:
- url: https://github.com/parcel-bundler/parcel/issues/4553
status: closed
---

Parcel does not provide a way to control whether individual resources or bundles recieve hashed URLs. However, it does not include hashes in the URLs of HTML files and Service Workers by default.
Parcel does not include hashes in the URLs of HTML files and Service Workers by default.

Namer plugins control the naming of bundles and can also be used to selectively overriding names by returning `null` to defer to the default namer.
16 changes: 16 additions & 0 deletions tests/hashing/subtests/avoid-hash/parcel/namer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Namer } = require('@parcel/plugin');
const path = require('path');

module.exports = new Namer({
name({ bundle }) {
let mainEntry = bundle.getMainEntry();
if (
mainEntry != null &&
path.basename(mainEntry.filePath).includes('unhashed')
) {
return path.basename(mainEntry.filePath);
}

return null;
},
});
10 changes: 10 additions & 0 deletions tests/hashing/subtests/avoid-hash/parcel/namer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "parcel-namer-custom",
"version": "0.0.0",
"engines": {
"parcel": "^2.0.0"
},
"dependencies": {
"@parcel/plugin": "^2.0.0"
}
}
3 changes: 2 additions & 1 deletion tests/hashing/subtests/avoid-hash/parcel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"build": "rm -rf .parcel-cache && parcel build src/unhashed.html src/hashed.html"
},
"dependencies": {
"parcel": "^2.0.0"
"parcel": "^2.0.0",
"parcel-namer-custom": "link:./namer"
}
}