-
Notifications
You must be signed in to change notification settings - Fork 144
RangeError: Maximum call stack size exceeded #49
Comments
There is some recursive code in there, so I could imagine how this might happen, but at the same time, I'm not able to reproduce it. I'm using the following, roughly based on what you provided as your config: const HtmlWebpackPlugin = require('html-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin')
module.exports = {
entry: './index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index-template.html',
minify: {
collapseWhitespace: true
}
}),
new PreloadWebpackPlugin({
include: 'all', // Needed to get index-bundle.js prefetched.
rel: 'prefetch'
}),
]
}; Could you pass along the rest of your config? I'm assuming this has something to with with your use of a configuration that sets Also CC: @toxic-johann, as they authored #37 and might have more insight. |
Could it be somehow connected to the use of new webpack.DllPlugin({
name: 'App',
context: APPROOT,
path: path.resolve(DEST, 'manifest.json')
}), |
@jeffposnick I think you guess is right. I will check this today. @creage I'm still a little puzzled. You means you have not include chunk in htmlWebpackPlugin but through dllPlugin? If you can provide a simple full config. I may find out the bug quickly. |
@toxic-johann well, I've tried to create a simple repo with my config, but I cannot reproduce it there either. It is rather small, having 4 modules only, but my real app has ~1300 , with complex structure of async modules. I assume some of these causes the recursion. If you give me some hints on how could I debug this plugin, I could run it on my real app. |
I think it may be caused by chunk ring. Assume you have chunk, A,B,C. A include B, B include C and then C include A.. As I backtrace the parent chunks, it bump into a dead cycle |
OK, I've modified plugin to log chunks which cause an exception, like this: // Only handle the chunk import by the htmlWebpackPlugin
extractedChunks = extractedChunks.filter(chunk => {
try {
return isChunkBelongToHtml(chunk, Object.values(htmlPluginData.assets.chunks));
} catch (er) {
fs.appendFileSync('preload-webpack-plugin-log.txt', (chunk.name || chunk.files) + '\n');
return false;
}
}); and output list of chunks actually matches the list of items, preloaded on version 2.0.0. Meaning, every item proposed for preload leads to exception. Strange... And, trying to stringify JSON.stringify(chunk); leads to So, looks like @toxic-johann is right here. Can't we mark already visited nodes, to avoid circular recursion? |
@toxic-johann Do you have a handle on what would need to change in order to avoid the circular references, or would you prefer some help putting together a PR? |
Yes. I am trying to reproduce this. I think I need to do something to fix this bug. It's good that if someone can help me. |
I took a stab at a fix. @creage, could you switch your dependency in
and give that a try? And @toxic-johann & co., can you confirm that this still works with your setups as well? |
@jeffposnick I confirm it compiles fine now. No exceptions, and all expected assets are added to the |
@jeffposnick Yes.It still works. That's great. |
Great—the |
Last release causes RangeError.
NodeJS v9.2.0
NPM 5.5.1
Windows 10
preload-webpack-plugin 2.1.1
webpack 3.10.0
webpack.config is pretty simple
Error log is
The text was updated successfully, but these errors were encountered: