Enable hashing of entry files and generation of manifest file
See original GitHub issue🙋 Feature request
Enable hashing of entry files and generation of a manifest file via CLI/API option. This has already been suggested in https://github.com/parcel-bundler/parcel/issues/3279#issuecomment-516088162 but this issue serves a little more context as to why this is beneficial.
🤔 Expected Behavior
The resulting assets bundles should be hashed and a manifest file generated.
😯 Current Behavior
Entry files are not hashed.
💁 Possible Solution
The issue can be circumvented to some degree by the method outlined in https://github.com/parcel-bundler/parcel/issues/2611 but would like to see better out of the box support to open Parcel up to more types of projects.
🔦 Context
The inclusion of such a feature will enable a wider variety of projects to benefit from entry hashing. Parcel is currently very much focused on either very simple static stiles or the likes of SPA’s where it’s very probable you only have single index.html
file, but in more traditional sites (PHP, .net, Ruby, etc) this may not be the case.
I’m thinking off PHP driven CMS’s and the like. In this situation, you have an index.php
file that bootstraps the app and handles all the routing, your templates that reference your CSS and JS are off in another directory. Applying Parcel’s automatically dependency search isn’t practical but I think there is a middle ground where you can benefit from the majority of what Parcel has to offer, including entry file hashing.
My proposal is to allow entry files to be hashed and a manifest file created (it’s then up to the app to read this and include the hashed file names, there are many such libraries that do so for a host of backend languages).
Parcel is perfectly usable in these types of projects and a brilliant project that abstracts many issues with today’s build tools and lowers the barrier to entry. Entry hashing would be the icing on the cake.
💻 Examples
Multi Entry
build src/scripts/main.js src/styles/main.scss
Result
dist/scripts/main.hash.js
dist/styles/main.hash.css
Single Entry with Imports
parcel build src/entry.js
// src/entry.js
import './scripts/main.js';
import './styles/main.scss';
Result
dist/entry.hash.js
dist/entry.hash.css
Issue Analytics
- State:
- Created 4 years ago
- Reactions:18
- Comments:5 (3 by maintainers)
I think I understand what you want but it strikes me as not the correct solution.
I think by definition you can’t hash an entry because in my mind an “entry” is a place where someone will enter your application. But they can’t enter there if they don’t know the name.
This is why I am proposing the manifest route. In your case your application is the entry, however your entry needs to provide the path to the “non-entry” bundles that you depend on. I think this could also be considered something like “external entry” because parcel itself is not handling the entry, however it needs to export information about non-entries to your application so that you can reference them.
https://github.com/autifyhq/parcel-reporter-bundle-manifest seems to do this.