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

QUnit transpilation issue when using targets that include IE11 #731

Closed
NullVoxPopuli opened this issue Mar 23, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@NullVoxPopuli
Copy link
Collaborator

Reproduction: NullVoxPopuli/limber#9
Command ran: npm run test:ember (ember test)
Error

not ok 1 Chrome 89.0 - [undefined ms] - Global error: Uncaught Error: an unsupported module was defined, expected `define(id, deps, module)` instead got: `1` arguments to define` at http://localhost:7357/assets/vendor.js, line 67
    ---
        browser log: |
            {"type":"error","text":"Uncaught Error: an unsupported module was defined, expected `define(id, deps, module)` instead got: `1` arguments to define` at http://localhost:7357/assets/vendor.js, line 67\n","testContext":{}}

Logs
https://github.com/NullVoxPopuli/limber/pull/9/checks?check_run_id=2175531805

@rwjblue
Copy link
Collaborator

rwjblue commented Mar 23, 2021

The issue here is due to QUnit being babel'ed in CI in a way that forces a different transpilation (due to the inclusion of IE11 in the targets when running in CI). QUnit doesn't actually need to be babel'ed at all, and if you add it to skipBabel you can avoid this specific error.

The ember new blueprint (when using the --embroider flag) sets this up for you:

https://github.com/ember-cli/ember-cli/blob/4f3b31a61e18c2731ed536e7de8462dd908352f0/blueprints/app/files/ember-cli-build.js#L25-L29

return require('@embroider/compat').compatBuild(app, Webpack, {
    skipBabel: [
      {
        package: 'qunit',
      },
    ],
});

@rwjblue rwjblue changed the title (only in ci?) embroider tests fail with what looks like an incorrect bundle? QUnit transpilation issue when using targets that include IE11 Mar 23, 2021
@rwjblue rwjblue added the bug Something isn't working label Mar 23, 2021
@NullVoxPopuli
Copy link
Collaborator Author

NullVoxPopuli commented Mar 23, 2021

That worked! However, it now looks like #730 is affecting tests 🤔

Thanks for the progress! <3

@ef4
Copy link
Contributor

ef4 commented Mar 27, 2021

The full explanation for what's happening here is:

  • qunit is already transpiled by babel
  • that transpilation inlined babel's typeof, because older browsers native typeof will do the wrong thing for polyfilled native classes
  • if you build your ember app for ie11, our babel also sees a typeof (the one inside the babel helper itself) and decides to polyfill it to be safe
  • rather than bloat your build, we try to import the polyfill from @babel/runtime
  • when webpack encounters qunit.js, it sees that it has that added import statement and sends it down a different code path than it would otherwise get. That code path also tries to support define.amd, and causes qunit to try to register itself with Ember's loader in a broken way.

skipBabel exists to solve this kind of problem. It would be much better if qunit would publish their ES modules instead, untranspiled. I have experimented with this and it's relatively easy to do with a small refactor to qunit. But that would also cause churn for us, because the way ember apps consume qunit is incorrect, relative to how it's actually authored. It has no named exports for test, module, etc. It has only a default export of the whole QUnit object.

sandydoo added a commit to sandydoo/ember-google-maps that referenced this issue Apr 20, 2021
Windvis added a commit to Windvis/ember-breadcrumb-trail that referenced this issue May 15, 2021
Windvis added a commit to Windvis/ember-breadcrumb-trail that referenced this issue May 15, 2021
rwjblue added a commit to cibernox/ember-cli-head that referenced this issue May 26, 2021
Do not transpile for `IE11` (in CI or production).

See embroider-build/embroider#731
stefanpenner added a commit to emberjs/ember-test-waiters that referenced this issue Aug 17, 2021
note: This fixes an embroider related issue, where when IE11 was included as a build target (in CI mode) es6-promise, babel, and webpack didn’t get along. (As described [here](embroider-build/embroider#731 (comment)))
stefanpenner added a commit to emberjs/ember-test-waiters that referenced this issue Aug 17, 2021
* Enable embroider-safe ember-try scenario

* Use same polyfil as @ember/test-helpers & unit

note: This fixes an embroider related issue, where when IE11 was included as a build target (in CI mode) es6-promise, babel, and webpack didn’t get along. (As described [here](embroider-build/embroider#731 (comment)))

* Add embroider-optimized scenario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants