Skip to content

Babel does not compile TypeScript when running with @babel/register #8962

@pronebird

Description

@pronebird
$ electron-mocha --renderer -R spec --require @babel/register --require-main "test/setup/main.js" --preload "test/setup/renderer.js" "test/*.spec.js" "test/*.spec.ts" "test/**/*.spec.js"
Unexpected identifier
~/gui/packages/desktop/test/keyframe-animation.spec.ts:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import KeyframeAnimation from '../src/main/keyframe-animation';
                                                                                                                                                                  ^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier

Compilation actually works

yarn workspace desktop private:compile
yarn workspace v1.10.1
yarn run v1.10.1
$ babel src/ --copy-files --out-dir build --extensions ".ts,.tsx,.js"
Successfully compiled 79 files with Babel.

babel.config.js

module.exports = function (api) {
  api.cache(true);

  return {
    "presets": [
      ["@babel/preset-env", {
        "targets": { "electron": "3.0" }
      }],
      "@babel/preset-react",
      "@babel/preset-typescript",
      "@babel/preset-flow"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties"
    ]
  };
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions