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

New option: staticEmberSource #1521

Merged
merged 10 commits into from
Jul 14, 2023
Merged

New option: staticEmberSource #1521

merged 10 commits into from
Jul 14, 2023

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Jul 8, 2023

This restores a feature we did previously. At the time we backed it out because too many addons were relying on the Ember global in vendor.js. But after Ember 4 there is no Ember global, so it seems likely to work this time.

All our supported ember versions ship loose modules in their published package. The modules are normally not visible to the build though, because the ember-source addon manually packages them and stuffs them into vendor.js. This PR adds a compat adapter that stops that process.

The benefit of this is that each of the ember-source provided modules will only get pulled into the build if you actually use it.

One other problem we saw last time was that the deps that ship inside ember-source:

.
├── @glimmer
│   ├── destroyable.js
│   ├── encoder.js
│   ├── env.js
│   ├── global-context.js
│   ├── low-level.js
│   ├── manager.js
│   ├── node.js
│   ├── opcode-compiler.js
│   ├── owner.js
│   ├── program.js
│   ├── reference.js
│   ├── runtime.js
│   ├── util.js
│   ├── validator.js
│   ├── vm.js
│   └── wire-format.js
├── @simple-dom
│   └── document.js
├── backburner.js
├── dag-map.js
├── route-recognizer.js
├── router_js.js
└── rsvp.js

started taking precedence globally over any copies of those packages that were consumed normally by other packages. This PR addresses that by making our renamedModules and renamedPackages compatibility features less aggressive -- they will now only take effect if the consuming package doesn't have an explicit dependency. That is, if a package tries to import from rsvp, if it doesn't have a dependency on rsvp we will redirect that to something like ember-source/rsvp.js. But if they do have an explicit dependency on rsvp we will leave it alone.

@ef4 ef4 marked this pull request as draft July 8, 2023 19:43
@ef4
Copy link
Contributor Author

ef4 commented Jul 8, 2023

Ugh, why oh why does ember-source have router.js as both a hard-coded inlined dependency and a real NPM dependency?

@ef4
Copy link
Contributor Author

ef4 commented Jul 11, 2023

The final failures here are because ember-cli-fastboot uses require from within vendor.js. This is a thing we're going to have to work to deprecate across the ecosystem. I know other addons do it too, and that was one of the key findings in emberjs/ember.js#20349, which is the upstream equivalent of the compat adapter in this PR.

We can probably still land this, but as a new option.

@ef4 ef4 marked this pull request as ready for review July 13, 2023 18:53
@ef4 ef4 merged commit 9834d5b into main Jul 14, 2023
@ef4 ef4 deleted the ember-source-modules branch July 14, 2023 17:57
@ef4 ef4 changed the title ember-source as modules New option: staticEmberSource Jul 14, 2023
@ef4 ef4 added the enhancement New feature or request label Jul 14, 2023
@ef4
Copy link
Contributor Author

ef4 commented Jul 14, 2023

This is landed as a new option staticEmberSource. Like all our options it defaults to the more-compatible, less-optimizable setting (false). It is included in the embroiderOptimized default test scenario.

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

Successfully merging this pull request may close these issues.

1 participant