not working with babe.config.js? #1

Open
opened 3 years ago by dylang · 1 comments
dylang commented 3 years ago

Hi, thanks for creating this project!

I'm using require("fix-esm").register() before ts-node's register and get the following 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 (/node_modules/@babel/core/lib/config/full.js:295:11)
    at /node_modules/@babel/core/lib/config/full.js:307:52
    at Array.forEach (<anonymous>)
    at validatePreset (/node_modules/@babel/core/lib/config/full.js:307:25)
    at loadPresetDescriptor (/node_modules/@babel/core/lib/config/full.js:314:3)
    at loadPresetDescriptor.next (<anonymous>)
    at recursePresetDescriptors (/node_modules/@babel/core/lib/config/full.js:114:30)
    at recursePresetDescriptors.next (<anonymous>)
    at /node_modules/@babel/core/lib/config/full.js:191:21
    at Generator.next (<anonymous>)
error Command failed with exit code 1.

The monorepo I'm testing this is in has a babel config. If I remove the babel.config.js then it works.

BTW: for others attempting to create an account to add issues or comments, check your spam folder. gmail seems to have flaged cryto.net as frequent source of spam.

Hi, thanks for creating this project! I'm using `require("fix-esm").register()` before ts-node's register and get the following 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 (/node_modules/@babel/core/lib/config/full.js:295:11) at /node_modules/@babel/core/lib/config/full.js:307:52 at Array.forEach (<anonymous>) at validatePreset (/node_modules/@babel/core/lib/config/full.js:307:25) at loadPresetDescriptor (/node_modules/@babel/core/lib/config/full.js:314:3) at loadPresetDescriptor.next (<anonymous>) at recursePresetDescriptors (/node_modules/@babel/core/lib/config/full.js:114:30) at recursePresetDescriptors.next (<anonymous>) at /node_modules/@babel/core/lib/config/full.js:191:21 at Generator.next (<anonymous>) error Command failed with exit code 1. ``` The monorepo I'm testing this is in has a babel config. **If I remove the `babel.config.js` then it works.** _BTW: for others attempting to create an account to add issues or comments, check your spam folder. gmail seems to have flaged `cryto.net` as frequent source of spam._
dylang commented 3 years ago
Poster

Found a fix:

	return babelCore.transformSync(code, {
		plugins: [
			require.resolve("@babel/plugin-proposal-export-namespace-from"),
			require.resolve("@babel/plugin-transform-modules-commonjs")
		],
        
		// Ignore local babel config
		configFile: false
	});
Found a fix: ```ts return babelCore.transformSync(code, { plugins: [ require.resolve("@babel/plugin-proposal-export-namespace-from"), require.resolve("@babel/plugin-transform-modules-commonjs") ], // Ignore local babel config configFile: false }); ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joepie91/fix-esm#1
Loading…
There is no content yet.