Cannot read property 'contexts' of null (Workaround here)
- Dominant language
- JavaScript
- Stars
- 4.4k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
Using Babel 0.5.0 (with brunch) with the following config:
```
exports.plugins = {
babel: {
'presets': ['es2015'],
'env': {
'production': {
'presets': [['minify', {
}]]
}
}
},
};
```
Will produce errors like the following:
```
17:25:50 - error: Compiling of app/article/component/HeadingMenu.js failed. TypeError: app/article/component/HeadingMenu.js: Cannot read property 'contexts' of null
at NodePath._getQueueContexts (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:278:21)
at NodePath._containerInsert (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:94:23)
at NodePath._containerInsertBefore (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:137:15)
at NodePath.insertBefore (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:56:19)
at NodePath.unshiftContainer (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:239:15)
at BuiltInReplacer.replace (/home/sean/bluetheme/node_modules/babel-plugin-minify-builtins/lib/index.js:164:22)
at PluginPass.exit (/home/sean/bluetheme/node_modules/babel-plugin-minify-builtins/lib/index.js:205:27)
at newFn (/home/sean/bluetheme/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:117:8)
at TraversalContext.visitQueue (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/home/sean/bluetheme/node_modules/babel-traverse/lib/index.js:114:17)
at traverse (/home/sean/bluetheme/node_modules/babel-traverse/lib/index.js:79:12)
at File.transform (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/file/index.js:516:35)
at /home/sean/bluetheme/node_modules/babel-core/lib/transformation/pipeline.js:50:19
at File.wrap (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/file/index.js:532:16)
at Pipeline.transform (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
at Promise (/home/sean/bluetheme/node_modules/babel-brunch/index.js:81:26)
at new Promise (:null:null)
at BabelCompiler.compile (/home/sean/bluetheme/node_modules/babel-brunch/index.js:77:12)
```
Disabling "builtIns" stops this error:
```
exports.plugins = {
babel: {
'presets': ['es2015'],
'env': {
'production': {
'presets': [['minify', {
'builtIns': false
}]]
}
}
},
};
```
Contributor guide
Research direction
Reproduce the failure with the shown Babel and minify preset configuration, then inspect babel-plugin-minify-builtins/lib/index.js and the babel-traverse paths in the stack trace. The workaround indicates builtIns handling is involved; done means the configuration compiles without the null-context error while builtIns remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100