asset-manifest.json generated by CRA2 is not useful
Created by: pthorn
As 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"
],
}