https://github.com/chadhietala/babel-plugin-nukable-import
Nukes bindings coming from a specified import declaration source
https://github.com/chadhietala/babel-plugin-nukable-import
Last synced: 2 months ago
JSON representation
Nukes bindings coming from a specified import declaration source
- Host: GitHub
- URL: https://github.com/chadhietala/babel-plugin-nukable-import
- Owner: chadhietala
- Created: 2017-09-05T21:49:49.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T11:17:42.000Z (over 2 years ago)
- Last Synced: 2024-10-30T04:17:41.764Z (8 months ago)
- Language: JavaScript
- Size: 108 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/chadhietala/babel-plugin-nukable-import)
Allows you to remove bindings from a specific import declaration source. The source is also used to remove any exports as well.
## Example
```js
import {
expectStackChange,
assert,
check,
CheckInterface,
CheckFunction
} from '@glimmer/debug';APPEND_OPCODES.app(123, (vm) => {
let { stack } = vm;
let mgr = check(stack.pop(), CheckInterface({ didRenderLayout: CheckFunction }));
mgr.didRenderLayout();
assert(stack.pop(), 'Must have a value');
expectStackChange(stack, -2, 'PrimitiveReference');
});
```Will be compiled as:
```js
APPEND_OPCODES.app(123, (vm) => {
let { stack } = vm;
let mgr = stack.pop();
mgr.didRenderLayout();
stack.pop();
});
```## Basic Usage
```
{
moduleIds: true,
getModuleId() { ... },
plugins: [
['nukable-import', { source: '@glimmer/debug' }]
]
}
```## Advanced Usage
If you need fine grain control over the bindings, you can implement a delegate that will be shown all the bindings that are `CallExpressions` and `Identifiers`. Note, this should be used for one-offs like removing a specific binding from from a specific source.
```
{
moduleIds: true,
getModuleId() { ... },
plugins: [
['nukable-import', {
source: '@glimmer/vm',
delegate(bindingName, path, types) {
if (bindingName === 'META_DATA') {
path.remove();
}
}
}]
]
}
```