Skip to content
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

Async babel compiler for babel ESM config support #2821

Closed
vjpr opened this issue Sep 30, 2021 · 1 comment
Closed

Async babel compiler for babel ESM config support #2821

vjpr opened this issue Sep 30, 2021 · 1 comment

Comments

@vjpr
Copy link

vjpr commented Sep 30, 2021

Issue description or question

When using wallaby.compilers.babel, I am using an ESM package as a plugin.

I get this message:

Error: /xxx/babel.config.js: Error while loading config - You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.
    ...
    at Object.transform (/Users/Vaughan/dev-mono/thirtyfive/node_modules/.pnpm/@babel+core@7.15.5_supports-color@9.0.1/node_modules/@babel/core/lib/transform.js:34:54)
    at e.run (/Users/Vaughan/Library/Application Support/JetBrains/IntelliJIdeaVaughan/system/wallaby/wallaby/server.js:14:23365)

wallaby

var t=n.transform(e.content,this._opts)

babel

const transform = function transform(code, opts, callback) {
  if (typeof opts === "function") {
    callback = opts;
    opts = undefined;
  }

  if (callback === undefined) return transformRunner.sync(code, opts);
  transformRunner.errback(code, opts, callback);
};

Should use https://babeljs.io/docs/en/babel-core#transformasync

@vjpr vjpr changed the title Async babel compiler Async babel compiler for babel ESM config support Sep 30, 2021
@NikGovorov
Copy link
Member

Hi @vjpr,

We've added the new setting called asyncTransform which forces our built-in babel compiler to use transformAsync:

export default function(wallaby) {
  return {
    files: [
      'package.json',
      'src/**/*.js',
      '!src/**/*.spec.js'
    ],
    tests: [
      'src/**/*.esmodules.spec.js'
    ],
    compilers: {
      '**/*.js': wallaby.compilers.babel({asyncTransform: true})
    },
    env: {
      type: 'node',
      runner: 'node',
      params: {
        runner: '--experimental-vm-modules'
      }
    },
    testFramework: 'ava'
  };
};

Please update to the the latest core version.

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

No branches or pull requests

2 participants