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

Not all properties on import with register 7 #8953

msaglietto opened this Issue Oct 31, 2018 · 4 comments


None yet
4 participants

msaglietto commented Oct 31, 2018

v7 Regression

I am updating an app to babel 7 and the application build with @babel/loader seems to be working fine but the test that run wit babel-registry is not working as before

On the app I'm updating the registry is included by mocha

default: `${crossEnv('NODE_ENV=test')} mocha 'test/**/*.test.js' --colors --require @babel/register --timeout 10000 --exit`,

So not sure if I'm missing some configuration or something is not working correctly

Describe the regression
When importing mongoose library the property Schema that is on the imported object when running with register 7 is not there anymore
In the example below the Schema property is undefined when used with @babel/register

Input Code

I create a repo to showcase the error

import mongoose, { Schema } from 'mongoose';

console.log('Schema is', Schema);

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

  "presets": [
    [ "@babel/env", { "targets": { "node": "8" } } ]

Expected behavior/code
You can use Schema from mongoose import with babel-register as in babel-loader


  • Babel version(s): 7.1.2
  • Node/npm version: Node 10
  • OS: Ubuntu 8.10
  • Monorepo: no
  • How you are using Babel: register

This comment has been minimized.


babel-bot commented Oct 31, 2018

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


This comment has been minimized.


nicolo-ribaudo commented Oct 31, 2018

The problem is that mongoose doesn't export both a default export and named exports (I don't know why it worked with Babel 6).
You should

import mongoose from "mongoose";
const { Scheme } = mongoose;

This comment has been minimized.


loganfsmyth commented Nov 1, 2018

Babel's interop helpers expects named imports to be own properties, but .Scheme lives on the mongoose instance's prototype:

We've also had this discussion in #6915 (comment) in the past.


This comment has been minimized.

msaglietto commented Nov 2, 2018

Yes to work around that is not a problem .. just is strange that babel-loader works and babel-register dont ...

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