Error: Plugin/Preset files are not allowed to export objects, only functions.
See original GitHub issueBug Report
Environment
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3"
OSX: 10.13.6 (17G3014)
node -v
v10.0.0
npm -v
5.6.0
Babel Configuration (.babelrc)
{
"presets": [ "react", ["env", {
"targets": {
"browsers": [ ">0.25%", "not ie 11", "not op_mini all"]
}
}], "stage-0" ],
"env": {
"production": {
"presets": ["minify"]
}
},
"plugins": [
[ "transform-object-rest-spread", { "useBuiltIns": true } ],
"transform-es2015-destructuring",
"transform-runtime",
"transform-decorators-legacy",
"transform-class-properties"
]
}
Want to transform code
import { transform } from '@babel/core'
...
const source = await readFile(fileName)
const posixName = posixPath(fileName)
const result = transform(source, {
babelrc: true,
filename: fileName
})
Current Behavior
Error: Plugin/Preset files are not allowed to export objects, only functions.
Expected behavior/code Code is successfully transformed regarded to working project with that babel config.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Preset files are not allowed to export objects - Stack Overflow
js Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. Does anyone know how to solve this?
Read more >Plugin/Preset files are not allowed to export objects, only ...
Hello. I am getting this error. I have seen that there is already about this error. I have tried all but not working...
Read more >Plugin/Preset files are not allowed to export objects, only ...
Hi there! When I running any tests, i getting: Error: Plugin/Preset files are not allowed to export objects, only functions.
Read more >React Native: Plugin/Preset files are not allowed to export ...
React Native: Plugin/Preset files are not allowed to export objects, only functions. I'm new to react-native and I'm trying to set up a ......
Read more >【React】webpackエラー解決方法"Plugin/Preset files are not ...
node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to export objects, only functions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s babel-core, not babel/core
Probably some of your dependencies depends on
@babel/core
, so you are able to import it because it is hoisted by npm.Also, FYI we have a
transformFile
function, so you don’t need to read the file yourself, and converting withposixPath
shouldn’t be needed.