Did Meteor 1.4.4 remove conditional imports?

In my project, I had several places where I was doing conditional imports. I would commonly use it in methods to only import certain things on the server, like:

if (!this.isSimulation) {
    import something from 'server/super/secret.js'
    // blah

Since the 1.4.4 upgrade, I am getting errors pointing at import that say it is a reserved word. The only way I could resolve this was to use the require() syntax instead.

Is this a bug? A deliberate decision?

1 Like

Do you have a .babelrc in your project? What’s in there? There were some changes in how module compilation interacts with Babel in the newest version.

This certainly isn’t happening on a brand new Meteor project so there must be some other factor in play here.

I will point out that there were some other changes to the ways that conditional imports worked, though those should only have affected you if you were conditionally import-ing a module but then trying to use it outside the conditional’s braces. Reason being: import statements now obtain a scope similar to that of a let variable, whereas they used to (incorrectly, we think, but because there was no other way to prevent it at the time) be scoped as a var (and thus available outside the braces).

Just to be clear, I don’t think that’s the problem you’re referring to here, but thought you may be interested if you’re using conditional imports (and I’m very glad you are!). For more on that, see my comment here in GitHub.


I do. It has:

  "env": {
    "production": {
      "presets": ["babili"]

I get the same error when I remove the file, too.

@abernix I had no idea that was how things worked! I am importing and using the module in the same block, so I don’t think this is the problem, but that was interesting to read regardless!

… I realize that is not very helpful. I will investigate a bit more and see if I can find anything else of interest.

Thank you both!

@moberegger We’re tracking this issue in the following issue – if you could create a small reproduction and post it in that issue, it’d be very much appreciated!

This was a bug, and certainly not a deliberate choice to remove support for nested import declarations. I believe the problem has now been fixed, and I would encourage you to run meteor update to update the babel-compiler compiler package to version 6.18.2.


Resolved everything; works like a charm!

Thank you for the help, everyone!