babel-plugin-import-asserts
v3.0.0
Published
babel plugin that adds console.asserts which check that your imports are not undefined
Downloads
565
Maintainers
Readme
babel-plugin-import-asserts
Babel plugin that does the following:
For every import baz, {foo, bar} from './baz';
it adds
console.assert(typeof foo !== 'undefined', '[IMPORT]: foo from ./abz is undefined');
console.assert(typeof bar !== 'undefined', '[IMPORT]: bar from ./abz is undefined');
console.assert(typeof baz !== 'undefined', '[IMPORT]: baz from ./abz is undefined');
below the import statement.
Motivation:
- Catching typos in import can be hard and sometimes lead to cryptic errors.
- Using destructuring with files containing constant can lead to weird behaviors if a constant is undefined without you knowing it.
Usage
- With Babel 5.0 use version 1.X
- With Babel 6.0 use version 2.X
Make sure to use it only in development.
In .babelrc
:
{
"stage": 0,
"env": {
"development": {
"plugins": [
"import-asserts"
]
}
}
Inspired by: https://github.com/jonathanewerner/babel-plugin-import-asserts