LZS911 / vite-plugin-conditional-compile

6 stars 0 forks source link

`vite-plugin-conditional-compile` fails to import named export 'traverse' from `@babel/core` #2

Closed f4-miyata closed 8 months ago

f4-miyata commented 8 months ago

Bug Description

When trying to run my project with vite-plugin-conditional-compile, I encounter an error stating that the named export 'traverse' cannot be found in the @babel/core module. The error message suggests that @babel/core is a CommonJS module, which may not support all module.exports as named exports.

This issue is preventing my project from starting in development mode using Vite and vite-plugin-conditional-compile.

Steps to Reproduce

  1. Install vite-plugin-conditional-compile in a project that uses Vite.
  2. Run the project.
  3. See error.

Environment

Additional Context

Here is the error message I receive:

SyntaxError: Named export 'traverse' not found. The requested module '@babel/core' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@babel/core';
const { parseSync, traverse } = pkg;

Acknowledgements

Thank you for maintaining the vite-plugin-conditional-compile plugin. It's been instrumental in our development process, and we appreciate the effort put into making it work seamlessly with Vite.

LZS911 commented 8 months ago

Thank you for discovering this problem. Preliminary investigation found that the @babel-core product used only has the common js version. I will upgrade the package to solve this problem. Thank you again.

LZS911 commented 8 months ago

version 1.4.4 has been released and can be used normally in ESModule after testing.

f4-miyata commented 8 months ago

@LZS911 Thank you for addressing this issue so promptly. I'm grateful for the effort to upgrade the @babel-core package and find a resolution. After updating to version 1.4.4, I can confirm the issue has been resolved and it now works perfectly in ESModule. Thank you for your support and swift response.