[SOLVED] Can't Build Production App on 1.10.2 - Babel Issues

I just merged in a bunch of work and am getting the dreadful @babel build errors. My 1.10.2 app won’t build in production. I’m getting the following top line error:

   Identifier 'r' has already been declared (1:76023)
   at Object.raise

What’s weird is nothing has changed with my babel or other related packages except for adding a single npm package for the Giphy library. I did a meteor reset and that didn’t work. I’m convinced it’s something in my code - though the app runs fine in development.

How can I debug this better and find the source?

@filipenevola Any suggestions or things to check for this?

I might have seen similar error before…but I think it was due to legacy code compilation so it is not the exact error you are facing.

However I did get similar error message format, and the way I identified the culprit package was by looking at the minified code (in your case line (1:76023)) and try to see which package this minified code belongs to by using some clues from the minified file. Once I figured out the package (or perhaps your own code), I was able to sort things out.

With regards to this specific error, I’m just guessing and thinking loud here, I don’t have direct experience with it, but it seems to be thrown by terser and it might be related to this commit

Perhaps if you downgrade standard-minifier-js package to a version before this update it might go away, maybe worth trying…

I also think it is worth updating terser to latest in the next meteor release, it might sort this issue from the root. For instance this commit at terser v4.4.1 (meteor is currently using v4.4.0) claims to fix lets being collapsed out of their scope.

@seba any thoughts on this, do you think terser might be causing this?

1 Like

I had something similarish a while ago - can’t for the life of me find it now. It was a weird issue where a variable declared inside a closure conflicted with one declared outside of it - it was a babel problem, but I think it was caused in part because of a conflict in babel versions between some npm packages and meteor

1 Like

I figured it out thankfully. Yet, it’s very strange and is likely a bug.

For this production update, I merged in three different new feature branches, some of which added new npm packages and updated both the package.json and package-lock.json for the application.

So I assumed it was something to do with an npm package or a version bump, @babel, etc. After trying all of the above, I went manual and just started back at the last working commit. Upon halving my way into the future commits I quickly found the last working commit was one before the last commit which literally only updated a block of code in a template.onRendered. Surely no… yes indeed!

I had actually added some YouTube embedding into a template and hastily added their API example and had the following code:

Template.someTemplate.onRendered(function() {
   //  Added to delay the UI from showing the YouTube video
   Meteor.setTimeout(function() {
      //  Embed YT video via their client API
      let yt new YT.Player('player', {
         //  Other inconsequential YouTube API param stuff
         events: {
            'onReady': onPlayerReady

      function onPlayerReady(event) {
         //  Inconsequential YouTube API calls

     //  Some jquery code to animate the video onto the screen

   }, 1000);

The standard-minifier did not like that global function definition inside the Meteor.setTimeout. Why did I do it like that? Because I was rushing.

I moved all the above code outside of the Meteor.setTimeout, except the jquery animation, and it minified as expected. Would this be a bug? I know it’s a improper pattern (likely) but it worked fine in development. Shouldn’t this pass minification?

1 Like

Good find! but I think it should not have happened so I would label this a bug.

I am haveing same issue
/home/nick/.meteor/packages/standard-minifier-js/. Identifier 'O' has already been declared (1:105454) at Object.raise
any solution yet?

Where is meteor minified code in which file @alawi

The parsing error gets reported at the client console in the minified MeteorJS application bundle.

The minified bundle JS file has all the initial client code shipped to the browser.

To get this should I run application with --production

1 Like

Yes, that runs production minifiers similar to how a deploy call does.

Okay thanks @evolross @alawi I think some of my node_modules is using O like

function(O) {
...  code here
array.map(O => {

....code here

What do you think?

I think you need to narrow down the culprit package and then understand why it is not being transpiled or minified correctly.