highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

Webpack error with autoit.js: Maximum call stack size exceeded

Open zwily opened this issue 11 years ago • 21 comments

I'm not sure if this is a highlight.js problem or webpack, but when webpack attempts to bundle highlight.js version 8.7, it chokes on autoit.js:

ERROR in ../~/highlight.js/lib/languages/autoit.js
Module build failed: Maximum call stack size exceeded
 @ ../~/highlight.js/lib/index.js 12:32-61

Had to pin to ~8.6.0 to get around this. Using node 0.10.25.

zwily avatar Aug 04 '15 02:08 zwily

Can you please provide all actions that you do? Unfortunatly at least me and @isagalaev are not familiar with modern packaging tools :-(

Sannis avatar Aug 04 '15 08:08 Sannis

To add more details to what @Sannis said…

highlight.js is a bit of a special case as it's supposed to be built with its internal tool first to become a working library. There are several kinds of build targets for different environment (browsers, node.js). So the answer to your question here depends very much on what webpack does. However I tend to think it's webpack's problem anyway as "maximum call stack exceeded" is a run-time problem and highlight.js code is not executing at that time (or so I dearly hope). Also, no other tool chokes on autoit.js, to my knowledge.

I'm going to close this issue as it doesn't seem we can do anything about it. If anything comes up in the future that we could fix feel free to reopen it. Thanks!

isagalaev avatar Sep 01 '15 21:09 isagalaev

I also have ran into this error. On node v4 using highlight.js v8.8.0 and WebPack v1.12.1. The bigger problem I have with this error is around the inconsistency. Half the time it builds fine, other half it blows up with this error.

gwing33 avatar Sep 22 '15 01:09 gwing33

Good day. I have the same issue.

ERROR in ./~/highlight.js/lib/languages/autoit.js
Module parse failed: /Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/highlight.js/lib/languages/autoit.js Maximum call stack size exceeded
You may need an appropriate loader to handle this file type.
RangeError: Maximum call stack size exceeded
    at Parser.applyPluginsBailResult (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/tapable/lib/Tapable.js:44:35)
    at Parser.evaluateExpression (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:711:20)
    at Parser.<anonymous> (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:60:20)
    at Parser.applyPluginsBailResult (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/tapable/lib/Tapable.js:48:50)
    at Parser.evaluateExpression (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:711:20)
    at Parser.<anonymous> (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:60:20)
    at Parser.applyPluginsBailResult (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/tapable/lib/Tapable.js:48:50)
    at Parser.evaluateExpression (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:711:20)
    at Parser.<anonymous> (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/webpack/lib/Parser.js:60:20)
    at Parser.applyPluginsBailResult (/Users/olegshilov/Documents/actor-platform/actor-apps/app-web/node_modules/tapable/lib/Tapable.js:48:50)
 @ ./~/highlight.js/lib/index.js 13:32-61

I use node v4.1.1, highlight.js v8.8.0, webpack v1.12.2 in my project. Before update node to v4, I had the same error and it's fixed with adding following lines to webpack config.

  resolve: {
    modulesDirectories: ['node_modules']
  }

But now it's stop working again.

olegshilov avatar Oct 01 '15 11:10 olegshilov

I have the same error on OSX. Sometimes it goes away, sometimes it comes back.

onsails avatar Oct 05 '15 12:10 onsails

This is happening for me too.

TylerBrock avatar Oct 08 '15 17:10 TylerBrock

+1 same problem

anorudes avatar Oct 10 '15 14:10 anorudes

I believe the problem is because the file autoit.js has thousands of string concatenations and that is causing web pack to blow it's stack.

TylerBrock avatar Oct 10 '15 15:10 TylerBrock

+1 reverting to v8.7 fixed it for me

mjhasbach avatar Oct 12 '15 03:10 mjhasbach

I resolved it in webpack config file by adding to module.noParse option new RegExp, e.g. like this:

{
    //...other config options
    module: {
       noParse: [/autoit.js/],
       //...other config options
    },
}

martinjirku avatar Oct 19 '15 14:10 martinjirku

I tried again with webpack 1.12.2 + highlight.js 8.9.1 and it worked without noParse.

mjhasbach avatar Oct 20 '15 20:10 mjhasbach

It's nice when things get automagically fixed themselves :-)

isagalaev avatar Oct 20 '15 21:10 isagalaev

The error reappeared after adding an additional dependency to my project. Oddly enough, after restarting webpack --watch, the error did not reappear. My server automatically pulls from GitHub every time I push to master, then runs npm install, triggering a webpack -p postinstall script. It has done that several times without any issues, so it would appear that the error is intermittent. I will try noParse.

@martinjirku Here's a better RegExp: /autoit\.js$/

mjhasbach avatar Oct 23 '15 06:10 mjhasbach

It seems that it is a wepback issue. Created it: https://github.com/webpack/webpack/issues/1721

just-boris avatar Dec 07 '15 12:12 just-boris

yeah this bug makes me really sad lol. Thanks for figuring out the cause.

geyang avatar Apr 08 '16 03:04 geyang

It looks like this issue is in deadlock. :(

The last comment (from a month ago) on webpack/webpack#1721 was:

highlight.js can use a single multi-line string to avoid the high AST depth. (this is a webpack problem, but if highlight.js doesn't mind making the change, then yay!)

And the last effective comment here was:

It seems that it is a wepback issue.

bvaughn avatar May 07 '16 15:05 bvaughn

highlight.js can use a single multi-line string to avoid the high AST depth. (this is a webpack problem, but if highlight.js doesn't mind making the change, then yay!)

Thanks for bringing this up, it actually helps. I don't see why not do it, and it should be fairly straightforward. I encourage anyone interested to pick it up and submit a pull request.

isagalaev avatar May 07 '16 15:05 isagalaev

May also be worth noting that- for me at least- this issue is resolved using the latest Node (6.1.0) although I was encountering it with older versions (5.3.0, 5.9.1).

bvaughn avatar May 07 '16 16:05 bvaughn

I looked more closely into AutoIt and found out it is simply too big anyway. I reduced the list based on the official docs of the languages which reduced the size of the whole library by about 20% and as a side effect fixed this issue.

isagalaev avatar May 08 '16 07:05 isagalaev

Nice work! :)

bvaughn avatar May 08 '16 14:05 bvaughn