A Babel plugin that inlines values from JSON files (e.g., config files) at build time, replacing require() calls to matched files with the actual JSON values. Current stable version is 2.1.0, with infrequent releases. Key differentiator: simple static replacement without runtime overhead, but does not work if the require argument is an identifier or template literal. Alternative to Webpack's DefinePlugin for Babel-only workflows.
npm install babel-plugin-inline-jsonVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin in .babelrc to inline values from a JSON file matching 'config', and the resulting replacement.
Use a string literal, e.g., require('config') instead of require(fileName).Upgrade to Babel 7 or use version 1.x for Babel 6.
Pass a single string regex pattern (e.g., 'config') for module names to match.
Run 'npm install --save-dev babel-plugin-inline-json' and ensure the config uses 'inline-json' without 'babel-plugin-' prefix.
Replace the require argument with a string literal, e.g., require('config') instead of const file = 'config'; require(file);No dependency data recorded yet.