{"id":19200,"library":"babel-plugin-transform-inline-imports-commonjs","title":"babel-plugin-transform-inline-imports-commonjs","description":"A Babel plugin (v1.2.0, last updated 2019) that transforms ES module imports into lazily loaded, memoized CommonJS requires, deferring require() calls until the imported identifier is actually referenced. Unlike the standard babel-plugin-transform-es2015-modules-commonjs, this avoids upfront I/O and execution costs for imported modules. Maintained by the author of babel-plugin-module-resolver, but now in maintenance mode as most projects have moved to @babel/preset-env or other bundlers. Supports options like excludeModules and excludeNodeBuiltins to skip lazy loading for specific modules or Node builtins. No TypeScript types, minimal breaking changes across versions.","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/zertosh/babel-plugin-transform-inline-imports-commonjs","tags":["javascript","babel-plugin","commonjs"],"install":[{"cmd":"npm install babel-plugin-transform-inline-imports-commonjs","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-inline-imports-commonjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-inline-imports-commonjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for any Babel plugin","package":"@babel/core","optional":false}],"imports":[{"note":"This is a Babel plugin, not a runtime package. It should be listed in .babelrc or babel.config.js, not imported in code. Common mistake is to try to import it in source files.","wrong":"import plugin from 'babel-plugin-transform-inline-imports-commonjs'","symbol":"default","correct":"module.exports = require('babel-plugin-transform-inline-imports-commonjs')"},{"note":"The package name does not include the @babel/ scope. Use the exact name as published.","wrong":"// Incorrect path\n{ \"plugins\": [\"@babel/plugin-transform-inline-imports-commonjs\"] }","symbol":"babel-plugin-transform-inline-imports-commonjs","correct":"// .babelrc\n{ \"plugins\": [\"transform-inline-imports-commonjs\"] }"},{"note":"Option is 'excludeModules', not 'exclude'. Available since v1.0.0.","wrong":"// Typo in option name\n{ \"plugins\": [[\"transform-inline-imports-commonjs\", { \"exclude\": [\"atom\"] }]] }","symbol":"excludeModules","correct":"// .babelrc\n{ \"plugins\": [[\"transform-inline-imports-commonjs\", { \"excludeModules\": [\"atom\"] }]] }"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    [\"transform-inline-imports-commonjs\", {\n      \"excludeNodeBuiltins\": true,\n      \"excludeModules\": [\"react\"]\n    }]\n  ]\n}\n\n// index.js (will be transformed)\nimport express from 'express';\nconst app = express();\nexport default app;","lang":"javascript","description":"Shows Babel plugin configuration with exclusion options and a sample import that gets lazily loaded."},"warnings":[{"fix":"Migrate to @babel/preset-env or @babel/plugin-transform-modules-commonjs with babel-plugin-lazy-require or similar.","message":"This plugin is in maintenance mode; it has not been updated since Babel 6 era. For Babel 7+, consider using @babel/plugin-transform-modules-commonjs with lazy evaluation via other means.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use 'excludeModules' instead of 'exclude' in plugin options.","message":"In version 1.0.0, the option 'exclude' was renamed to 'excludeModules'.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Order plugins correctly: transform-inline-imports-commonjs should come before transform-runtime in your plugin list.","message":"If you use this plugin alongside @babel/plugin-transform-runtime, the lazy loading may conflict with runtime helpers.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use the 'excludeModules' option to skip lazy loading for modules involved in circular dependencies.","message":"Lazy loading can cause issues with circular dependencies because the require is deferred until the variable is used.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you are using Babel 6 with this plugin. For Babel 7, use a different module transformation plugin.","cause":"Using the plugin incorrectly with a bundler that doesn't support Babel 6-style plugins, or using a Babel 7 package with Babel 6.","error":"Error: Plugin/Preset files are not allowed to export objects, only functions."},{"fix":"Run: npm install --save-dev babel-plugin-transform-inline-imports-commonjs and verify the name in .babelrc.","cause":"Package not installed or wrong name in .babelrc.","error":"Cannot find module 'babel-plugin-transform-inline-imports-commonjs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}