Registry / serialization / babel-plugin-named-exports-order

babel-plugin-named-exports-order

JSON →
library0.0.2jsnpmunverified

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).

npm install babel-plugin-named-exports-order
INSTALL
IMPORT
SIG · BABEL-PLUGIN-NAMED
B
babel-plugin-named-exports-order
serializationjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default plugin
module.exports = { plugins: ['babel-plugin-named-exports-order'] }
module.exports = { plugins: [require('babel-plugin-named-exports-order')] }
Simple string reference in Babel config is preferred over requiring the module.
default export (ESM)
import babelPluginNamedExportsOrder from 'babel-plugin-named-exports-order'
import { babelPluginNamedExportsOrder } from 'babel-plugin-named-exports-order'
Plugin exports a single function as default. Named import will be undefined.

Shows basic Babel configuration and the transform effect on a file with three named exports.

// .babelrc.js module.exports = { plugins: ['babel-plugin-named-exports-order'], }; // Example input file (stories.js) export const A = () => {}; export const B = () => {}; export const C = () => {}; // After transform, output includes: export const A = () => {}; export const B = () => {}; export const C = () => {}; export const __namedExportsOrder = ['A', 'B', 'C'];
Debug
Known issues
gotchaPlugin only processes static named exports; dynamic exports (e.g., `export { variable }`) or re-exports (`export * from`) are not captured in __namedExportsOrder.
fix
Ensure all exports to be ordered are static named exports declared directly in the file.
affects: >=0.0.0
gotchaThe __namedExportsOrder array is added as an additional export, which might cause duplicate if the file already exports a variable with that name.
fix
Avoid naming any export `__namedExportsOrder` in files processed by this plugin.
affects: >=0.0.0
gotchaThis 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.
fix
Use the __namedExportsOrder array in consuming code (e.g., Storybook) to reorder imports as needed.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'babel-plugin-named-exports-order'
Plugin not installed as dev dependency.
fix
Run `npm install --save-dev babel-plugin-named-exports-order` or `yarn add -D babel-plugin-named-exports-order`.
__namedExportsOrder is not defined
File does not have any static named exports, or plugin is not configured correctly.
fix
Verify .babelrc includes the plugin and that the file has at least one static named export declaration.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency for Babel plugin API
Agent activity
14 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
babel-plugin-named-exports-order — npm install babel-plugin-named-exports-order · libregistry