Meteor-Community-Packages / meteor-collection2

A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
https://packosphere.com/aldeed/collection2
MIT License
1.02k stars 108 forks source link

Internet Explorer not working #401

Closed HemalR closed 4 years ago

HemalR commented 4 years ago

I went through a project and upgraded a tonne of packages. All seemed to go well until I realised that one of the upgrades broke IE (which I sadly still have to support!).

Anyway, after many hours trying to find the package in question (and tbh, there might be more than one), I decided to try create a new project from scratch to see if I can find it that way. Repo here: https://github.com/HemalR/meteor-ie-breaker/branches

Two branches are in there - the master doesn't work and the 'works' branch does.

The only difference between the two is the presence of the aldeed:collection2 package. I tried adding simpl-schema to the recompile list under package.json to see if that makes a difference, but no luck there.

Questions:

  1. Has anyone faced this same issue?
  2. Is it possible that the test above is a red-herring and the real culprit package is not collection2 at all?
  3. Any recommended fixes?

Thanks!

hexsprite commented 4 years ago

When you say "broke" what actual error did you get? Do you have a traceback? Which version of IE?

HemalR commented 4 years ago

@hexsprite Thanks for helping mate.

IE11. It comes up as a blank screen, and the console shows: 'Syntax error'.

image

Clicking on the error to try and find the code causing the issue points to this:

image

This is identical to my main production app (clicking on the IE error leads to the same block of code). Is it perhaps the default parameter causing the issue?

That said, doing some digging in the last 30 minutes, I'm fairly certain (but not 100%) that this version of Collection2 has worked on IE in the past so I am a bit stumped.

hexsprite commented 4 years ago

Looks like maybe it's not getting the modern instead of legacy bundle. It seems like IE11 doesn't support ES6 classes. I'm not sure why it would get the wrong bundle though!

HemalR commented 4 years ago

We have progress! Thanks to @CaptainN - https://github.com/meteor/meteor/pull/10603

I'm testing it out in my production env as I write this. I'll update both with a final outcome once I have it.

HemalR commented 4 years ago

Alright, confirmation - this added to package.json fixes things:

 "meteor": {
    "mainModule": {
      "client": "./client/main.js",
      "server": "./server/main.js"
    },
    "nodeModules": {
      "recompile": {
        "simpl-schema": "legacy",
        "query-string": "legacy"       
      }
    }
  },

@hexsprite Thanks for taking the time to respond and helping 👍

coagmano commented 4 years ago

Yeah, this is a simple-schema publishing bug, I've got a PR for the fix, but it's still waiting to be merged and re-published: https://github.com/aldeed/simple-schema-js/pull/347

Considering simple-schema was originally made for meteor, it really should work out of the box without re-compilation