babel-plugin-strip-glimmer-utils
raw JSON → 0.1.1 verified Sat Apr 25 auth: no javascript
A Babel plugin that strips specific imports and usages from @glimmer/utils (e.g., unwrap, expect) in production builds. Version 0.1.1 is the latest. Designed for Ember/Glimmer applications to remove debug-only utility calls. Lightweight, no runtime dependencies. Alternative to manual tree-shaking.
Common errors
error TypeError: Cannot read properties of undefined (reading 'default') ↓
cause Plugin imported via require without .default in CJS environment.
fix
Use require('babel-plugin-strip-glimmer-utils').default
error Error: [BABEL] Unknown option: .bindings ↓
cause Missing or incorrect configuration object (e.g., passing string instead of array for bindings).
fix
Ensure configuration is { source: '@glimmer/utils', bindings: ['unwrap'] }
error Error: Cannot find module '@glimmer/utils' ↓
cause Source package not installed or misconfigured in config.
fix
Install @glimmer/utils or adjust the 'source' option.
Warnings
gotcha Plugin only works with Babel 7+ ↓
fix Use Babel 7 or later; not compatible with Babel 6.
gotcha Bindings listed in config must be actual named exports from @glimmer/utils; otherwise plugin may fail silently. ↓
fix Verify the exact export names from the source package.
deprecated Plugin has not been updated in 4+ years; may not cover newer versions of @glimmer/utils. ↓
fix Consider forking or using manual tree-shaking. Check compatibility with your @glimmer/utils version.
Install
npm install babel-plugin-strip-glimmer-utils yarn add babel-plugin-strip-glimmer-utils pnpm add babel-plugin-strip-glimmer-utils Imports
- default export (plugin) wrong
import { stripGlimmerUtils } from 'babel-plugin-strip-glimmer-utils'correctimport stripGlimmerUtils from 'babel-plugin-strip-glimmer-utils' - plugin usage in Babel config wrong
plugins: ['babel-plugin-strip-glimmer-utils']correctplugins: [['strip-glimmer-utils', { source: '@glimmer/utils', bindings: ['unwrap'] }]] - require in Node.js (CJS) wrong
const stripGlimmerUtils = require('babel-plugin-strip-glimmer-utils')correctconst stripGlimmerUtils = require('babel-plugin-strip-glimmer-utils').default
Quickstart
// babel.config.js
module.exports = {
plugins: [
['strip-glimmer-utils', {
source: '@glimmer/utils',
bindings: ['unwrap', 'expect']
}]
]
};
// Before:
import { unwrap } from '@glimmer/utils';
console.log(unwrap(someValue));
// After (in production):
// import removed, call replaced with its argument
console.log(someValue);