{"id":19109,"library":"babel-plugin-named-exports-order","title":"babel-plugin-named-exports-order","description":"Babel plugin (v0.0.2, stable) that adds a `__namedExportsOrder` array to JavaScript files preserving the original order of named exports. Bundlers like Webpack 5 do not guarantee export order, but tools like Storybook rely on it for features such as story ordering. This plugin inserts a constant array listing export names in declaration order, enabling consumers to reconstruct the intended sequence. Lightweight and zero-config, but only works with static named exports (not dynamic or re-exports).","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-named-exports-order","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-named-exports-order","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-named-exports-order","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin API","package":"@babel/core","optional":false}],"imports":[{"note":"Simple string reference in Babel config is preferred over requiring the module.","wrong":"module.exports = { plugins: [require('babel-plugin-named-exports-order')] }","symbol":"default plugin","correct":"module.exports = { plugins: ['babel-plugin-named-exports-order'] }"},{"note":"Plugin exports a single function as default. Named import will be undefined.","wrong":"import { babelPluginNamedExportsOrder } from 'babel-plugin-named-exports-order'","symbol":"default export (ESM)","correct":"import babelPluginNamedExportsOrder from 'babel-plugin-named-exports-order'"}],"quickstart":{"code":"// .babelrc.js\nmodule.exports = {\n  plugins: ['babel-plugin-named-exports-order'],\n};\n\n// Example input file (stories.js)\nexport const A = () => {};\nexport const B = () => {};\nexport const C = () => {};\n\n// After transform, output includes:\nexport const A = () => {};\nexport const B = () => {};\nexport const C = () => {};\nexport const __namedExportsOrder = ['A', 'B', 'C'];","lang":"javascript","description":"Shows basic Babel configuration and the transform effect on a file with three named exports."},"warnings":[{"fix":"Ensure all exports to be ordered are static named exports declared directly in the file.","message":"Plugin only processes static named exports; dynamic exports (e.g., `export { variable }`) or re-exports (`export * from`) are not captured in __namedExportsOrder.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid naming any export `__namedExportsOrder` in files processed by this plugin.","message":"The __namedExportsOrder array is added as an additional export, which might cause duplicate if the file already exports a variable with that name.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the __namedExportsOrder array in consuming code (e.g., Storybook) to reorder imports as needed.","message":"This plugin does not modify export order in the module system; it only inserts an array for downstream consumers to reorder. Bundlers may still reorder the actual export bindings.","severity":"gotcha","affected_versions":">=0.0.0"}],"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 babel-plugin-named-exports-order` or `yarn add -D babel-plugin-named-exports-order`.","cause":"Plugin not installed as dev dependency.","error":"Cannot find module 'babel-plugin-named-exports-order'"},{"fix":"Verify .babelrc includes the plugin and that the file has at least one static named export declaration.","cause":"File does not have any static named exports, or plugin is not configured correctly.","error":"__namedExportsOrder is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}