asset-manifest.json generated by CRA2 is not useful
See original GitHub issueAs mentioned in the discussion in #5306, asset-manifest.json
generated by CRA2 is less than useful. As an example, this is asset-manifest.json
as generated by yarn build
for my project:
{
"main.css": "/static/css/main.7263860d.chunk.css",
"main.js": "/static/js/main.1d09f064.chunk.js",
"main.js.map": "/static/js/main.1d09f064.chunk.js.map",
"static/css/1.a7cf09a2.chunk.css": "/static/css/1.a7cf09a2.chunk.css",
"static/js/1.f5aeaa31.chunk.js": "/static/js/1.f5aeaa31.chunk.js",
"static/js/1.f5aeaa31.chunk.js.map": "/static/js/1.f5aeaa31.chunk.js.map",
"runtime~main.js": "/static/js/runtime~main.229c360f.js",
"runtime~main.js.map": "/static/js/runtime~main.229c360f.js.map",
"static/css/1.a7cf09a2.chunk.css.map": "/static/css/1.a7cf09a2.chunk.css.map",
"static/css/main.7263860d.chunk.css.map": "/static/css/main.7263860d.chunk.css.map",
"index.html": "/index.html",
"precache-manifest.981d9ec8b3a8232e0184126d691edb97.js": "/precache-manifest.981d9ec8b3a8232e0184126d691edb97.js",
"service-worker.js": "/service-worker.js"
}
It was quite an unpleasant surprise when I upgraded to CRA2. Here are some obvious problems with this file:
- it contains no information on which files are chunks of the same package
- there is no way to identify chunks (except the ‘main’ chunk) by key (random strings in keys? seriously?)
- there is absolutely no information on the order in which chunks are to be loaded
It can of course still be parsed by pattern matching file names but there are obvious disadvantages:
- any such parsing will rely on heuristics
- parsing will break if file naming scheme is ever changed
- what is the point of having this file at all? you could
listdir()
the build directory and obtain basically the same information
Here is a suggested asset-manifest.json
format that could make it usable:
{
"main.js": [
"/static/js/1.f5aeaa31.chunk.js", // <-- order is significant
"/static/js/main.1d09f064.chunk.js",
],
"main.js.map": [
"static/js/1.f5aeaa31.chunk.js.map", // <-- same order as in "main.js"
"/static/js/main.1d09f064.chunk.js.map",
]
"runtime~main.js": "/static/js/runtime~main.229c360f.js",
"runtime~main.js.map": "/static/js/runtime~main.229c360f.js.map",
"precache-manifest.js": "/precache-manifest.981d9ec8b3a8232e0184126d691edb97.js",
"service-worker.js": "/service-worker.js"
"main.css": [
"/static/css/1.a7cf09a2.chunk.css"
"/static/css/main.7263860d.chunk.css"
],
"main.css.map": [
"/static/css/1.a7cf09a2.chunk.css.map"
"/static/css/main.7263860d.chunk.css.map"
],
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Serving a modified asset-manifest.json in CRA using CRACO ...
Whenever I build the application, my new assets.json file is generated as expected. However, I can't get CRA, or webpack-dev-server I assume, to ......
Read more >Keeping an on Web Performance. Why speed on mobile matters
Things that work on the desktop will not work right on mobile ... Precaching of javascript was done with asset-manifest.json provided by ...
Read more >The babel-plugin-tailwind-components from bradlc - GithubHelp
This style object format is compatible with most CSS-in-JS libraries, including styled-components. Some libraries such as styled-jsx do not support this format, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think we should just change it to only include “initial” scripts in the order they should be in HTML. Since the only purpose of this file is to reconstruct the HTML.
Does that make sense?
Sad to see #5955 and similar pull requests and issues being closed by stale bot. Is parsing the generated index.html file the only option forward when including CRA components on a site with a backend?