Story discovering failed: [ConfigError: [BABEL] unknown file: Preset /* your preset */ requires a filename to be set when babel is called directly #578
I could work around this problem by moving my babel config out of the root dir and reference it by the other tooling that needs it (e.g. Webpack, Jest, …). I don't expect a fix per se, but reporting nevertheless in case someone else runs into this issue. :)
Describe the bug
Adding MDX file with project that have babel config fails upon startup like so:
╭───────────────────────────────────────────────────╮
│ │
│ 🥄 Ladle.dev served at http://localhost:4123/ │
│ │
╰───────────────────────────────────────────────────╯
Story discovering failed:
ConfigError: [BABEL] unknown file: Preset /* your preset */ requires a filename to be set when babel is called directly,
babel.transformSync(code, { filename: 'file.ts', presets: [/* your preset */] });
See https://babeljs.io/docs/en/options#filename for more information.
at new ConfigError (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/errors/config-error.js:10:5)
at validateIfOptionNeedsFilename (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:265:11)
at eval (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:275:103)
at validatePreset (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:275:76)
at loadPresetDescriptor (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:293:3)
at recursePresetDescriptors (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:77:31)
at eval (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@babel+core@7.24.6/node_modules/@babel/core/lib/config/full.js:156:21)
More info: https://ladle.dev/docs/stories#limitations
I could work around this problem by moving my babel config out of the root dir and reference it by the other tooling that needs it (e.g. Webpack, Jest, …). I don't expect a fix per se, but reporting nevertheless in case someone else runs into this issue. :)
Describe the bug
Adding MDX file with project that have babel config fails upon startup like so:
Reproduction
babel.config.json
in the root with contents:src/whatever.stories.mdx
file, contents doesn't matterpnpm install && pnpm run dev
Environment