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

@babel/core doesn't seem to load .babelrc #8971

Open
kevin-de-coninck opened this Issue Nov 4, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@kevin-de-coninck

kevin-de-coninck commented Nov 4, 2018

Bug Report

Current Behavior
@babel/register doesn't seem to use .babelrc file.

Input Code
I have the following TypeScript file containing some tests:

import { expect } from 'chai';

describe('sample', (): void => {
  it('Returns false', (): void => {
    expect(false).to.equal(false);
  });
});

My package.json contains the following script:

"scripts": {
	"test": "npx mocha --require @babel/register spec/**/*.spec.ts"
}

The following error is throwed when invoking the script:

import { expect } from 'chai';
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Module._extensions..js (module.js:664:10)
    at Object.newLoader [as .js] (C:\Users\kevin\Development\Node.JS\Datalytics\Server\Services\Datalytics.Services.Logging\node_modules\pirates\lib\index.js:88:7)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at C:\Users\kevin\Development\Node.JS\Datalytics\Server\Services\Datalytics.Services.Logging\node_modules\mocha\lib\mocha.js:250:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (C:\Users\kevin\Development\Node.JS\Datalytics\Server\Services\Datalytics.Services.Logging\node_modules\mocha\lib\mocha.js:247:14)
    at Mocha.run (C:\Users\kevin\Development\Node.JS\Datalytics\Server\Services\Datalytics.Services.Logging\node_modules\mocha\lib\mocha.js:576:10)
    at Object.<anonymous> (C:\Users\kevin\Development\Node.JS\Datalytics\Server\Services\Datalytics.Services.Logging\node_modules\mocha\bin\_mocha:637:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Expected behavior/code
The tests should be executed.

Babel Configuration (.babelrc, package.json, cli command)

{
	"presets": [
		"@babel/typescript",
		"@babel/env"
	],
	"plugins": [
		"@babel/proposal-class-properties",
		"@babel/proposal-object-rest-spread"
	],
	"comments": false
}

Environment

  • Babel packages:
		"@babel/core": "^7.1.2",
		"@babel/plugin-proposal-class-properties": "^7.1.0",
		"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
		"@babel/preset-env": "^7.1.0",
		"@babel/preset-typescript": "^7.1.0",
		"@babel/register": "^7.0.0",
  • Node/npm version: Node 8.12.0 / NPM 6.4.1
  • OS: Windows 10
  • How you are using Babel: register
@babel-bot

This comment has been minimized.

Collaborator

babel-bot commented Nov 4, 2018

Hey @kevin-de-coninck! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment