Registry / devops / babel-plugin-nukable-import

babel-plugin-nukable-import

JSON →
library0.4.2jsnpmunverified

Babel plugin (v0.4.2) that removes specific named bindings from import declarations and corresponding export references. Useful for stripping development-only or debugging code from production builds. Unlike general dead-code elimination, it targets imports by source and binding name, working at AST level. Maintained by the Glimmer.js team; used within the Glimmer-VM ecosystem. Low release cadence.

npm install babel-plugin-nukable-import
INSTALL
IMPORT
SIG · BABEL-PLUGIN-NUKAB
B
babel-plugin-nukable-import
devopsjavascriptv0.4.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: [['nukable-import', { source: '@glimmer/debug' }]] }
import nukableImport from 'babel-plugin-nukable-import'
CommonJS module; use require or plugins array string syntax
babel.config.js usage
module.exports = { plugins: [['nukable-import', { source: '@glimmer/debug' }]] }
plugins: ['babel-plugin-nukable-import', { source: '@glimmer/debug' }]
Must be in array form with options object
delegate option
['nukable-import', { source: '@glimmer/vm', delegate(bindingName, path, types) { ... } }]
['nukable-import', { delegate: myDelegate }] where myDelegate is not a function
Delegate must be a function, not a reference to a function defined elsewhere

Configures Babel to remove all bindings from '@glimmer/debug' import, stripping debug code.

// babel.config.js module.exports = { plugins: [ ['nukable-import', { source: '@glimmer/debug' }] ] }; // input.js import { assert, check } from '@glimmer/debug'; assert(someCondition); check(value, someType); // output.js // Both assert and check calls removed, imports removed
Debug
Known issues
breakingOnly works with named imports; default imports are not removed.
fix
Use named imports for bindings you wish to remove, or use a different plugin for default imports.
affects: >=0.0.0
gotchaPlugin removes the entire import declaration if all bindings are nuked; side effects may be lost.
fix
Ensure the import source has no side effects, or use sideEffects: false in package.json.
affects: >=0.0.0
gotchaDelegate only receives CallExpression and Identifier paths; other expression types are ignored.
fix
Use delegate only for removing call expressions or identifier references; for other cases, write a custom plugin.
affects: >=0.0.0
gotchaDuplicate imports from the same source: plugin may merge or leave orphaned imports.
fix
Avoid duplicate import declarations from the same source in the same file.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'isCallExpression')
Delegate called with unexpected path type, likely from non-CallExpression/non-Identifier.
fix
Add a guard in your delegate: if (t.isCallExpression(path) || t.isIdentifier(path)) { ... }
Error: [BABEL] unknown: Plugin/preset files are not allowed to export objects, only functions.
Using plugin without array notation or misconfigured require.
fix
Use ['nukable-import', options] syntax in your Babel config.
ReferenceError: require is not defined in ES module scope
Using require in an ES module context.
fix
Use import.meta.glob or dynamic import, or configure Babel as CommonJS.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
babel-plugin-nukable-import — npm install babel-plugin-nukable-import · libregistry