{"id":20133,"library":"infinite-loop-loader","title":"infinite-loop-loader","description":"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.","status":"active","version":"1.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/opencomponents/base-templates","tags":["javascript","oc","opencomponents","webpack","loader","inifinite-loop","webpackloader","transform","typescript"],"install":[{"cmd":"npm install infinite-loop-loader","lang":"bash","label":"npm"},{"cmd":"yarn add infinite-loop-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add infinite-loop-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"AST traversal and transformation of JavaScript code","package":"falafel","optional":false},{"reason":"JavaScript parser used by falafel","package":"acorn","optional":false},{"reason":"Webpack loader utility to parse options","package":"loader-utils","optional":false}],"imports":[],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        use: {\n          loader: 'infinite-loop-loader',\n          options: {\n            limit: 100000,\n            opts: {\n              allowImportExportEverywhere: true,\n            },\n          },\n        },\n      },\n    ],\n  },\n};","lang":"javascript","description":"Webpack configuration to transform infinite loops in all JS files with a limit of 100000 iterations."},"warnings":[{"fix":"Manually refactor other loop styles to while(true) if you need them to be guarded.","message":"The loader only transforms while(true) and while(1) patterns. Other infinite loop constructs (e.g., for(;;) or do{}while(true)) are not transformed.","severity":"gotcha","affected_versions":"*"},{"fix":"Avoid using the identifier __ITER in your source code, or rename it if possible.","message":"The injected counter variable name (__ITER) can conflict with user-declared variables. The loader does not perform scope analysis.","severity":"gotcha","affected_versions":"*"},{"fix":"Set a sensible limit via the `limit` option in the loader configuration.","message":"The default iteration limit is 1000000000, which is extremely high and may not catch unintended infinite loops in a timely manner.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to a maintained alternative or check compatibility with webpack 5.","message":"Minimum webpack version required is 2. May not work with webpack 5 due to changes in loader API.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Consider using a more modern AST-based tool or babel plugin.","message":"The package relies on falafel, which is no longer actively maintained. Acorn options are passed through falafel, which may cause issues with newer Acorn versions.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev infinite-loop-loader` and check that node_modules contains the package.","cause":"The loader is not installed or webpack cannot resolve it.","error":"Module build failed: Error: 'infinite-loop-loader' is not a valid loader"},{"fix":"Update to the latest version of infinite-loop-loader and ensure the `opts` object contains valid Acorn parser options.","cause":"Falafel's iteratee function is not compatible with the version used by this loader, or the Acorn options are invalid.","error":"Error: custom iteratee is not supported"},{"fix":"Ensure the `test` regex only matches .js files and that the files contain valid JavaScript syntax.","cause":"The loader received a malformed source or an empty file. This can happen if the file is not valid JavaScript or if the test pattern matches non-JS files.","error":"TypeError: Cannot read properties of undefined (reading 'start')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}