Skip to content

Story discovering failed: [ConfigError: [BABEL] unknown file: Preset /* your preset */ requires a filename to be set when babel is called directly #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
viddo opened this issue Oct 14, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@viddo
Copy link

viddo commented Oct 14, 2024

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/@[email protected]/node_modules/@babel/core/lib/errors/config-error.js:10:5)
    at validateIfOptionNeedsFilename (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:265:11)
    at eval (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:275:103)
    at validatePreset (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:275:76)
    at loadPresetDescriptor (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:293:3)
    at recursePresetDescriptors (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:77:31)
    at eval (/home/projects/ladle-o7lxfz/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/full.js:156:21)

More info: https://ladle.dev/docs/stories#limitations

Reproduction

  1. Create a new Stackblitz
  2. Add babel.config.json in the root with contents:
{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react",
    "@babel/preset-typescript"
  ]
}
  1. Add/install aforementioned deps
pnpm add @babel/preset-env @babel/preset-react @babel/preset-typescript
  1. Add a src/whatever.stories.mdx file, contents doesn't matter
  2. Restart dev server pnpm install && pnpm run dev

Environment

@viddo viddo added the needs triage needs to be reviewed label Oct 14, 2024
@tajo
Copy link
Owner

tajo commented Nov 12, 2024

fyi: by default, Ladle doesn't use babel anymore (we use swc plugin instead)

@tajo tajo added documentation Improvements or additions to documentation and removed needs triage needs to be reviewed labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants