Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Pass filename to the babel transform call #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ishmidt-pp
Copy link

Thanks for the plugin!

Problem

Calls to babel transform without passing the filename causes babel to fail.
(According to the error stack and https://babeljs.io/docs/en/options#filename)

Environment

@babel/core: ^7.14.6
NodeJS: v14.17.1
vite: ^2.3.7
vite-react-jsx: ^1.1.1

Error stack

[vite:react-jsx] [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.
file: src/index.tsx
error during build:
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 (node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:295:11)
    at node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:307:52
    at Array.forEach (<anonymous>)
    at validatePreset (node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:307:25)
    at loadPresetDescriptor (node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:314:3)
    at loadPresetDescriptor.next (<anonymous>)
    at recursePresetDescriptors (node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:114:30)
    at recursePresetDescriptors.next (<anonymous>)
    at node_modules/vite-react-jsx/node_modules/@babel/core/lib/config/full.js:191:21
    at Generator.next (<anonymous>)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@ishmidt-pp
Copy link
Author

Hey @aleclarson, could you take a look at this PR please?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant