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

Move responsibility of booting the app from Embroider internals to the Ember app #1957

Merged
merged 5 commits into from
Jun 25, 2024

Conversation

BlueCutOfficial
Copy link
Collaborator

@BlueCutOfficial BlueCutOfficial commented Jun 5, 2024

The app-boot script is now part of the Ember app

This PR implements the 1st part of #1960:

entrypoint.js should not have the responsibility to boot the app. We would prefer it to export the app-related modules, and the index.html should be where the app boot takes place.

  • It removes the app-boot part from virtual-entrypoint.ts so the app-boot no longer happens in Embroider internals.
  • It changes our different app templates (used for testing) to demonstrate the new way to boot the app (see the different index.html and app/app.js files).

How it drives the decision to stop the support of content-for "app-boot"

The app-boot script specifies instructions to boot the app. During the classic build, some Broccoli plugins and Ember libraries work together to generate the correct app-boot instructions, so it used to be something internal.

If you are an addon author and the way your addon works requires customizing the app-boot, you couldn't provide any configuration instructions to your users because they have no control over the app-boot anyway. But classic addons let you provide the required content yourself using the contentFor hook. There is an example in ember-cli-fastboot.

With this PR, app developers now have control over the app-boot script: it's written directly in the index.html. Classic addons won't be able to impact this script, it will be the responsibility of the app.

A new error message has been implemented so if the app uses at least one classic addon providing custom content for app-boot, an explanation about how to move the instructions on the app side will be displayed.

@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 2 times, most recently from 0a017b4 to b063489 Compare June 5, 2024 16:23
@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 4 times, most recently from b3d26ec to ac6a130 Compare June 6, 2024 09:22
@mansona
Copy link
Member

mansona commented Jun 6, 2024

I think this PR should remove the support for ember-app-boot.js i.e. addons can't provide it any more

@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 3 times, most recently from 1452428 to bf49153 Compare June 6, 2024 10:12
@BlueCutOfficial BlueCutOfficial changed the title feat(new app-boot): 1st iteration with an app-boot.js file that boots… Move responsibility of booting the app from Embroider internals to the Ember app Jun 6, 2024
@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 11 times, most recently from ae5593a to 54b0cef Compare June 13, 2024 14:18
@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 3 times, most recently from 8236571 to 6f393a8 Compare June 19, 2024 13:26
@BlueCutOfficial BlueCutOfficial force-pushed the new-app-boot branch 3 times, most recently from 88ffed3 to 3ea4714 Compare June 20, 2024 15:07
Comment on lines 698 to 592
expectAudit
.module('./node_modules/my-addon/_app_/components/hello-world.js')
.resolves('my-addon/components/hello-world')
.to('./node_modules/my-addon/components/hello-world.js', 'remapped to precise copy of my-addon');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed this assertion because I need to go through this resolve path anyway to test the content of my-addon/components/hello-world.js in another test. So I simply moved the message "remapped to precise copy of my-addon" to a comment in that other test.

Comment on lines -560 to -576
window.define("my-app/components/second-choice", function () {
return importSync("#embroider_compat/components/second-choice");
});
window.define("my-addon/synthetic-import-1", function () {
return importSync("../synthetic-import-1");
});
import Component from '@ember/component';
import layout from '../templates/components/hello-world';
import computed from '@ember/object/computed';
import somethingExternal from 'not-a-resolvable-package';
import { importSync } from "@embroider/macros";
export default Component.extend({
dynamicComponentName: computed('useDynamic', function () {
return this.useDynamic || 'default-dynamic';
}),
layout
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we want to keep asserting all the imports are present, or do we just want enough proof that this is the right file that has been loaded?

@BlueCutOfficial BlueCutOfficial marked this pull request as ready for review June 21, 2024 16:35
@BlueCutOfficial BlueCutOfficial requested review from mansona and ef4 June 21, 2024 16:35
@ef4 ef4 merged commit f653cff into main Jun 25, 2024
178 checks passed
@ef4 ef4 deleted the new-app-boot branch June 25, 2024 13:40
@github-actions github-actions bot mentioned this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants