emberjs/ember-jquery

jQuery shim module structure not AMD-compatible

timiyay opened this issue · 2 comments

I'm investigating an issue we're having after upgrading to ember-jquery 0.6.0.

A PR from Jan 2019 added a shim for jQuery, which changes the structure of the exported module.

We have a legacy AMD module system based on https://github.com/ember-cli/loader.js, which imports 'jquery'.

The issue is this alias used to return jquery, but now returns an object:

{
  'default': 'the jQuery module, which used to be returned, but is now wrapped in this object',
  __esModule: true,
};

This breaks some of our AMD module imports, and we're reviewing our options for fixes.

Is ember-jquery expected to work with AMD modules, as defined and required by ember-cli/loader? It would seem it was AMD-compliant until 0.6.0, and then switched to ES2015 format.

Are there any migration strategies we can use, so that require('jquery') returns jQuery, and not the object shown above?

I've opened a proof-of-concept PR at #99 that fixes the immediate issue for us. I'd be interested to hear if it's useful or unsuitable.

The discussion in #99 led to a neat solution that fixes our specific use case.