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

Empty coverage report when using "type": "module" with babel/register #10970

Open
IgorNovozhilov opened this issue Jan 8, 2020 · 5 comments
Open

Comments

@IgorNovozhilov
Copy link

@IgorNovozhilov IgorNovozhilov commented Jan 8, 2020

Empty coverage report when using "type": "module" in "package.json".

  "devDependencies": {
    "@babel/register": "latest",
    "@babel/plugin-proposal-class-properties": "latest",
    "@babel/plugin-transform-modules-commonjs": "latest",
    "babel-eslint": "latest",
    "babel-plugin-istanbul": "latest",
    "eslint": "latest",
    "eslint-config-standard": "latest",
    "eslint-plugin-import": "latest",
    "eslint-plugin-node": "latest",
    "eslint-plugin-promise": "latest",
    "eslint-plugin-standard": "latest",
    "nyc": "latest"
  }

How to configure everything to work "out of the box"?

Example repo: https://github.com/demo-source/node-app

Here is the output in the original:
изображение

Relying on the message: ExperimentalWarning: The ESM module loader is experimental., I assume that the source code is not converted using the module @babel/register, and is still executed as an ESM

But if you manually change the type, but everything works. ("type": "commonjs")
if you add a small plug(https://github.com/demo-source/node-app/blob/master/update-package.cjs), and in real-time to replace the type:
изображение

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Jan 8, 2020

Hey @IgorNovozhilov! 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."

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 8, 2020

@babel/register only works with commonjs scripts, because node doesn't have a stable API to hook into modules loading yet.

@IgorNovozhilov

This comment has been minimized.

Copy link
Author

@IgorNovozhilov IgorNovozhilov commented Jan 8, 2020

@nicolo-ribaudo, Maybe there is a plugin that solves this problem?

@mAAdhaTTah

This comment has been minimized.

Copy link
Contributor

@mAAdhaTTah mAAdhaTTah commented Jan 8, 2020

@IgorNovozhilov No. Node does not yet provide the capabilities needed to create a plugin.

@IgorNovozhilov

This comment has been minimized.

Copy link
Author

@IgorNovozhilov IgorNovozhilov commented Jan 8, 2020

Well, then I'll use my solution, maybe someone will be useful:
https://www.npmjs.com/package/babel-hook-esm-to-cjs-package-type-runtime
Or maybe someone will suggest something else...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.