Internal Babel helper package providing utility functions for implementing ES6 module transformations, such as converting imports and exports to CommonJS, AMD, or UMD. This package is used by plugins like @babel/plugin-transform-modules-commonjs and @babel/plugin-transform-modules-amd. Version 7.0.0-beta.1 is an early beta; current stable releases follow Babel 7.x line (v7.29.2 as of March 2026) and Babel 8 development on v8.0.0-rc.3. Users should not depend on this package directly; use the respective transform plugins instead. Key differentiator: it centralizes module transformation logic shared across Babel module plugins.
npm install babel-helper-module-transformsVerified import paths — ran on the pinned version, not inferred.
Shows how to use the default export to rewrite module statements and extract metadata from an AST.
Use import rewriteModuleStatementsAndPrepareHeader from '@babel/helper-module-transforms' instead of importing a named export.
Prefer using higher-level Babel plugins or @babel/core APIs instead of directly depending on this helper.
Use the 'moduleId' or 'getModuleId' options in your Babel configuration instead.
If you need ESM output, use @babel/preset-env with modules: false or use a bundler like Rollup.
Change to import rewriteModuleStatementsAndPrepareHeader from '@babel/helper-module-transforms'.
Ensure you have @babel/core installed, or explicitly install @babel/helper-module-transforms.
Update all @babel/* packages to the same version.