A webpack loader that transforms infinite loops (e.g., `while(true)`) by injecting an iteration counter and a throw statement when the limit is exceeded. Version 1.0.9 is the latest stable release. It is part of the OpenComponents ecosystem but can be used standalone. The loader uses falafel/acorn to parse and transform JavaScript. Unlike manual linting or AST-based approaches, this provides a runtime safeguard for accidental infinite loops in webpack-bundled code. It supports configuration of the iteration limit and Acorn parser options. The package ships TypeScript definitions.
npm install infinite-loop-loaderNo compatibility data collected yet for this library.
Webpack configuration to transform infinite loops in all JS files with a limit of 100000 iterations.
Manually refactor other loop styles to while(true) if you need them to be guarded.
Avoid using the identifier __ITER in your source code, or rename it if possible.
Set a sensible limit via the `limit` option in the loader configuration.
Upgrade to a maintained alternative or check compatibility with webpack 5.
Consider using a more modern AST-based tool or babel plugin.
Run `npm install --save-dev infinite-loop-loader` and check that node_modules contains the package.
Update to the latest version of infinite-loop-loader and ensure the `opts` object contains valid Acorn parser options.
Ensure the `test` regex only matches .js files and that the files contain valid JavaScript syntax.