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

jQuery being transpiled to Ember.$ #327

Open
spansh opened this issue Feb 12, 2020 · 1 comment
Open

jQuery being transpiled to Ember.$ #327

spansh opened this issue Feb 12, 2020 · 1 comment

Comments

@spansh
Copy link

spansh commented Feb 12, 2020

I recently upgraded a bunch of things (including ember) in one of my apps. Now I've fixed most of the issues I'm left with one which I can't seem to track down.

In my code I have sections like

import jQuery from 'jquery';

            jQuery.ajax({
                url: url,
                method: 'HEAD'
            }).then(function(data,textStatus,response) {
                let details = {
                    name: file,
                    url: url,
                    size: response.getResponseHeader('Content-Length'),
                    modified: moment.utc(response.getResponseHeader('Last-Modified'))
                };
                let fileDetails = route.fileDetails;
                fileDetails[file] = details;
                route.set("fileDetails",fileDetails);
                controller.set("files",Object.keys(fileDetails).map( key => fileDetails[key] ));
            });

Which when I run it under ember serve is getting transpiled to:

        Ember.$.ajax({
          url: url,
          method: 'HEAD'
        }).then(function (data, textStatus, response) {
          var details = {
            name: file,
            url: url,
            size: response.getResponseHeader('Content-Length'),
            modified: _moment.default.utc(response.getResponseHeader('Last-Modified'))
          };
          var fileDetails = route.fileDetails;
          fileDetails[file] = details;
          route.set("fileDetails", fileDetails);
          controller.set("files", Object.keys(fileDetails).map(function (key) {
            return fileDetails[key];
          }));
        });

I've tried looking for addons or plugins which could be causing this and I've tried rebuilding node_modules and each time the deprecation warning remains. I asked around on the ember discord and noone seemed to have any ideas. I spent several hours grepping through my node_modules directory hoping to find something that referenced jQuery and set it up to be transpiled but at the moment I'm basically looking for a needle in a haystack. Is there any way I can find out exactly where/why this is being transpiled?

@spansh
Copy link
Author

spansh commented Feb 14, 2020

I believe I have finally managed to track down the error.

I had done ember install ember-jquery which was tripping ember-cli-babel, specifically the _shouldBlacklistJQuery function. Uninstalling and reinstalling it with ember install @ember/jquery has solved the problem. It may be worth adjusting the function to account for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant