better-docs
better-docs copied to clipboard
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
Trying to generate docs with typescript but I received an error..
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
This is my babel.config.json
{
"presets": [
[
"@babel/preset-typescript",
{
"jsxPragma": "j"
}
],
[
"@babel/preset-env",
{
"modules": false,
"loose": true,
"useBuiltIns": "entry",
"corejs": 3
}
]
],
"plugins": [
"syntax-async-functions",
"@babel/plugin-transform-async-to-generator",
[
"@babel/plugin-transform-arrow-functions",
{
"spec": true,
"loose": true
}
],
[
"@babel/plugin-transform-runtime",
{
"absoluteRuntime": false,
"corejs": 3,
"helpers": true,
"regenerator": true,
"useESModules": false,
"version": "7.0.0-beta.0"
}
],
[
"module-resolver",
{
"root": [
"."
],
"extensions": [
".js",
".jsx",
".ts"
],
"alias": {
"^@components/(.+)": "./src/components/\\1",
"^@assets/(.+)": "./src/assets/\\1",
"^@pages/(.+)": "./src/pages/\\1",
"^@store$": "./src/store/index.js",
"^@store/(.+)": "./src/store/\\1",
"^@api$": "./src/api/index.js",
"^@api/(.+)": "./src/api/\\1",
"^@base$": "./src/base.js",
"^@validator$": "./src/validator/index.js",
"^@validator/(.+)": "./src/validator/\\1",
"^@utils$": "./src/utils.js"
}
}
],
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "h",
"pragmaFrag": "Fragment"
}
],
[
"@babel/plugin-proposal-object-rest-spread",
{
"loose": true,
"useBuiltIns": true
}
],
[
"@babel/plugin-transform-destructuring",
{
"loose": true,
"useBuiltIns": true
}
],
"@babel/plugin-syntax-dynamic-import",
[
"@babel/plugin-proposal-class-properties",
{
"spec": true
}
],
"transform-react-remove-prop-types"
],
"env": {
"development": {
"plugins": [
"react-hot-loader/babel",
"@babel/plugin-transform-react-jsx-source",
"@babel/plugin-transform-react-display-name"
]
}
}
}
With this error
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
`
babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
`
See https://babeljs.io/docs/en/options#filename for more information.
at validateIfOptionNeedsFilename (./web/node_modules/@babel/core/lib/config/full.js:275:11)
at options.overrides.forEach.overrideOptions (./web/node_modules/@babel/core/lib/config/full.js:287:52)
at Array.forEach (<anonymous>)
at validatePreset (./web/node_modules/@babel/core/lib/config/full.js:287:25)
at loadPresetDescriptor (./web/node_modules/@babel/core/lib/config/full.js:294:3)
at loadPresetDescriptor.next (<anonymous>)
at recurseDescriptors (./web/node_modules/@babel/core/lib/config/full.js:108:30)
at recurseDescriptors.next (<anonymous>)
at loadFullConfig (./web/node_modules/@babel/core/lib/config/full.js:143:6)
at loadFullConfig.next (<anonymous>)
at Object.parse (./web/node_modules/@babel/core/lib/parse.js:28:45)
at parse.next (<anonymous>)
at evaluateSync (./web/node_modules/gensync/index.js:245:28)
at Object.sync (./web/node_modules/gensync/index.js:85:14)
at Object.parse (./web/node_modules/react-docgen/dist/babelParser.js:66:20)
at Object.parse (./web/node_modules/recast/lib/parser.js:32:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! web@ generate-docs: `jsdoc -c jsdoc.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web@ generate-docs script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Same problem here `DEBUG: Environment info: {"env":{"conf":{"plugins":["plugins/markdown","node_modules/better-docs/component"],"recurseDepth":10,"source":{"includePattern":".+\.js(doc|x)?$","excludePattern":"(^|\/|\\)","include":["src"]},"sourceType":"module","tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false,"better-docs":{"name":"My React components"}},"opts":{"destination":"docs","recurse":true,"readme":"README.md"}},"opts":{"":[],"configure":"jsdoc.conf.json","debug":true,"destination":"docs","recurse":true,"readme":"README.md","encoding":"utf8"}}} DEBUG: Parsing source files: ["/Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/boxContainer.js","/Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/hello.js","/Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/index.js","/Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/touchable.js","/Users/abraaobarros/Projetos/react_native/Base/src/index.js"] Parsing /Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/boxContainer.js ... Parsing /Users/abraaobarros/Projetos/react_native/Base/src/components/atoms/hello.js ... /Users/abraaobarros/Projetos/react_native/Base/node_modules/better-docs/component.js:67 throw error ^
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
See https://babeljs.io/docs/en/options#filename for more information.
at validateIfOptionNeedsFilename (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:275:11)
at options.overrides.forEach.overrideOptions (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:287:52)
at Array.forEach (
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
See https://babeljs.io/docs/en/options#filename for more information.
at validateIfOptionNeedsFilename (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:275:11)
at options.overrides.forEach.overrideOptions (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:287:52)
at Array.forEach (
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
See https://babeljs.io/docs/en/options#filename for more information.
at validateIfOptionNeedsFilename (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:275:11)
at options.overrides.forEach.overrideOptions (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:287:52)
at Array.forEach (
Error: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
See https://babeljs.io/docs/en/options#filename for more information.
at validateIfOptionNeedsFilename (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:275:11)
at options.overrides.forEach.overrideOptions (/Users/abraaobarros/Projetos/react_native/Base/node_modules/@babel/core/lib/config/full.js:287:52)
at Array.forEach (
@Ridermansb, @abrahampe I had the same issue. I successfully resolve it by changing line 50 of ./src/react-wrapper.jsx :
const src = Babel.transform(wrapper, { presets: ['react', 'es2015'] }).code
by :
const src = Babel.transform(wrapper, { presets: ["@babel/preset-react", "@babel/preset-env"] }).code
Let me know if it resolve the issue for you too. (don't forget to build better-docs)