Skip to content

Provide alternative to calling window.require directly #31

Description

@tomwayson

I ran into this issue:

ember-codemods/ember-native-class-codemod#222 (comment)

The root cause is that this library calls window.require directly, which doesn't work in apps that have had to rename the ember loader's global to get around this long standing problem for (I'll admit) a small group in the ember community. There are multiple addons dedicated to dealing w/ this problem (that I'm aware of):

https://github.com/richardaiko/ember-derequire
https://github.com/Esri/ember-cli-amd
https://github.com/Esri/ember-esri-loader (which I maintain)

And apps like ours that use one of those will not be able to use codemods that use this library as is.

One idea is that this could take some kind of option like requireGlobal: 'eriuqer' to allow users to override the default behavior. The problem is that I think all codemods that use this would have to also add a corresponding option to their own command line args or config files so that they could pass it along.

Another potential option is for this to use Ember.__loader.require instead of window.require. This is what Ember Inspector does. One thing I've been able to do to get Ember inspector working in my app is to run Ember.__loader.require = Ember.__loader.eriuqer in the DevTools command line before accessing the Ember tab. In theory, I could just call that before running any telemetry based codemod I should not have the above problem.

I'd be willing to make a PR if you have a direction you prefer to go.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions