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

Refactor the internal Ember loader to use the standard Ember CLI loader #19390

Merged
merged 2 commits into from Feb 10, 2021

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented Feb 9, 2021

This PR refactors the internal Ember loader so that it uses the standard
Ember CLI loader instead for modules. This means that modules will be
defined in the main namespace, and importable from there, instead of in
a hidden namespace that only Ember can use.

Notes:

  • Code is still loaded and built via treeForVendor and included as a
    vendor file. This needs to be the case for the time being for
    bootstrapping.
  • Loader code is still included for Node support. If define and
    require are not already defined, then a backup shim is used instead.
  • Modules are now exposed from Ember, but ember-cli-babel still
    transpiles them to global references. This unblocks us from being able
    to make all modules work normally, however.
  • require shim module is no longer defined, we reference define and
    require as globals instead (which is more accurate). In the future
    we should update this to use Embroider's conventions.
  • __loader is still exposed on the Ember object, referencing the same
    values as before.

@pzuraq pzuraq force-pushed the refactor-internal-loader branch 2 times, most recently from b059b42 to b99fa0f Compare February 9, 2021 20:19
lib/index.js Show resolved Hide resolved
packages/ember-template-compiler/lib/system/compile.ts Outdated Show resolved Hide resolved
packages/internal-test-helpers/lib/confirm-export.js Outdated Show resolved Hide resolved
tests/index.html Outdated Show resolved Hide resolved
tests/index.html Show resolved Hide resolved
packages/loader/lib/index.js Outdated Show resolved Hide resolved
This PR refactors the internal Ember loader so that it uses the standard
Ember CLI loader instead for modules. This means that modules will be
defined in the main namespace, and importable from there, instead of in
a hidden namespace that only Ember can use.

Notes:

- Code is still loaded and built via `treeForVendor` and included as a
  vendor file. This needs to be the case for the time being for
  bootstrapping.
- Loader code is still included for Node support. If `define` and
  `require` are not already defined, then a backup shim is used instead.
- Modules are now exposed from Ember, but `ember-cli-babel` still
  transpiles them to global references. This unblocks us from being able
  to make all modules work normally, however.
- `require` shim module is no longer defined, we reference `define` and
  `require` as globals instead (which is more accurate). In the future
  we should update this to use Embroider's conventions.
- `__loader` is still exposed on the Ember object, referencing the same
  values as before.
packages/@ember/-internals/bootstrap/index.js Show resolved Hide resolved
packages/ember/index.js Show resolved Hide resolved
Comment on lines +21 to +24
if (typeof globalObj.define === 'function' && typeof globalObj.require === 'function') {
define = globalObj.define;
require = globalObj.require;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to accommodate the no conflict APIs for loader.js here

https://github.com/ember-cli/loader.js#no-conflict

Since loader doesn't expose loader.require/loader.define or a way to access what the "new" aliases are we can't do this just yet.

tests/index.html Show resolved Hide resolved
tests/index.html Show resolved Hide resolved
packages/ember/index.js Outdated Show resolved Hide resolved
packages/loader/lib/index.js Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

None yet

3 participants