Missing assets from loadable-stats.json
See original GitHub issueš Bug Report
We are receiving the following error when generating HTML via our server-side-rendering process.
const nodeStats = path.join(process.cwd(), 'build/node/loadable-stats.json')
const webStats = path.join(process.cwd(), 'build/loadable-stats.json')
const nodeExtractor = new ChunkExtractor({
statsFile: nodeStats, outputPath: path.resolve(process.cwd(), 'build/node')
})
const { default: App, React, renderToString } = nodeExtractor.requireEntrypoint()
const webExtractor = new ChunkExtractor({
statsFile: webStats, outputPath: path.resolve(process.cwd(), 'build/web')
})
Hereās the error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:112:11)
at Object.extname (path.js:1231:5)
at getFileScriptType (/Users/noah/work/lib/node_modules/@loadable/server/lib/ChunkExtractor.js:49:60)
at isScriptFile (/Users/noah/work/lib/node_modules/@loadable/server/lib/ChunkExtractor.js:53:10)
at /Users/noah/work/lib/node_modules/@loadable/server/lib/ChunkExtractor.js:366:11
It appears that the cause is related to the way the assets within the loadable-stats.json
block is generated.
Hereās the loadable-stats.json using 5.15
{
"hash": "aeebda487075c80e6709",
"publicPath": "/",
"outputPath": "/Users/nmarkon/work/content-site-connect2local/build/node",
"assetsByChunkName": {
...snip..
},
"assets": [
{
"type": "assets by status",
"cached": true,
"filteredChildren": 70,
"size": 281927
}
],
In 5.14.2
the assets block in contained information regarding each chunk such as:
{
"hash": "4ee6a975c8dd4cdbc020",
"version": "5.37.0",
"time": null,
"publicPath": "/",
"outputPath": "/Users/noah/work/lib/build/node",
"assetsByChunkName": {
.... snip....
},
"assets": [
{
"type": "asset",
"name": "static/js/name-goes-here.d2b992cb.chunk.js",
"size": 3518,
"emitted": false,
"comparedForEmit": false,
"cached": true,
"info": {
"immutable": true,
"contenthash": "d2b992cb",
"javascriptModule": false,
"minimized": true
},
"chunkNames": [
"name-goes-here"
],
"chunkIdHints": [],
"auxiliaryChunkNames": [],
"auxiliaryChunkIdHints": [],
"related": {},
"chunks": [
4677
],
"auxiliaryChunks": [],
"isOverSizeLimit": false
},
...snip...
It looks like this change is the root cause: https://github.com/gregberge/loadable-components/commit/9ad6bf569a28ff553a5adf5104b55c6dcba47016
It appears that the all: false
is preventing the cached assets from being added. If cachedAssets: true
is added to the JSON then the cached assets are added as expected.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Server Side Rendering - Loadable Components
When running your build, notice @loadable/webpack-plugin generates a file called loadable-stats.json , which contains information about all your entries andĀ ...
Read more >CSS modules not working in loadable-components in server ...
I have checked the stats.json file and it is missing the CSS files. webpack.config.js: 'use strict'; const fs = require('fs'); const pathĀ ...
Read more >Stats Data - webpack
Stats Data. When compiling source code with webpack, users can generate a JSON file containing statistics about modules. These statistics can be used...
Read more >@react-loadable/revised - npm package | Snyk
Looks like @react-loadable/revised is missing a security policy. ... Based on project statistics from the GitHub repository for the npm packageĀ ...
Read more >Webpack-imported NPM | npm.io
SSR API Ā· importedAssets(stats, chunks, [tracker]) - return all assets associated with provided chunks. Could be provided a tracker to prevent duplicationsĀ ...
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ām having the same issue. However, removing
all: false
grows the stats file a lot when using Webpack 5 (from 180 kB to 108 MB in my case), so I can understand why it was added. Could we maybe expose all options to the user facing API?My use case, for example, works just fine with the currently set options when I replace
all: false
withI could also provide a pull request if I get a āgoā from a maintainer.
Update to my above suggestion
I misunderstood @Noah-Vivial: he does not want to remove
all: false
, but merely addcachedAssets: true
, which:So #778
is probably overkill, feel free to close itmight still serve other use cases. Iāve created #779 instead, and also published an according git tag to be used with npm / yarn:depoulo/loadable-components#@loadable/webpack-plugin/cached-assets-770/5.15.1
.