Babel plugin that transforms export default of anonymous functions, arrow functions, and anonymous classes to named exports using the filename as the variable name. Version 2.1.0 is current. Released sporadically; last update was several years ago. Key differentiator: solves stack trace readability by assigning a derived name from the file (e.g., foo-bar.js becomes fooBar), improving debugging. Unlike other plugins that only handle function declarations, this targets anonymous/arrow function and class expressions. Works with Babel 6 and 7 (likely).
npm install babel-plugin-transform-export-default-nameVerified import paths — ran on the pinned version, not inferred.
Shows how to enable the plugin and the transformation of an anonymous arrow function default export to a named variable.
Ensure this plugin is listed before any plugin that handles export-all or re-exporting.
Consider using @babel/plugin-proposal-export-default-from or monkey-patch Babel transform output for named functions.
Check transformed output for valid identifiers; avoid file names starting with digits or containing special chars.
Use only for anonymous default exports; for named exports, use other tools.
Ensure the default export is truly anonymous; otherwise, no transformation occurs.
npm install --save-dev babel-plugin-transform-export-default-name
Install @babel/core@^7.0.0 and ensure compatibility; consider alternative plugin.
Ensure the default export is anonymous; remove any explicit name declaration.
Ensure this plugin runs first in the plugin list before other export transforms.