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

Production builds produce incorrect browser runtimes for fastboot assets #968

Closed
thoov opened this issue Sep 9, 2021 · 6 comments
Closed

Comments

@thoov
Copy link
Collaborator

thoov commented Sep 9, 2021

Steps to reproduce:

  1. git clone git@github.com:thoov/fastboot-macro-issue.git
  2. cd fastboot-macro-issue && yarn

Then running the following commands:

  • CLASSIC=true ember s
  • CLASSIC=true ember s -prod
  • ember s

And visiting http://ocalhost:4200 in the browser you will correctly see "browser". However if you run:

  • ember s -prod

you will see "fastboot" printed indicating that the fastboot service is being used and not the app's service.

@thoov
Copy link
Collaborator Author

thoov commented Sep 9, 2021

Some background information:

When we encounter a fastboot asset (such as fastboot/service/foo.js) we create a "switcher template" for it. This uses a macroCondition to create a "switch" for fastboot and browser imports which works fine in dev mode. However, in production mode we eliminate the runtime aspect of macros (and eliminate the "false" branches) and thus this conditional removes the app service and only leaves the fastboot one.

@thoov thoov changed the title Production builds produce incorrect runtimes for fastboot assets Production builds produce incorrect browser runtimes for fastboot assets Sep 9, 2021
@ef4
Copy link
Contributor

ef4 commented Sep 10, 2021

However, in production mode we eliminate the runtime aspect of macros (and eliminate the "false" branches) and thus this conditional removes the app service and only leaves the fastboot one.

That is how it's supposed to work. But we're supposed to run the build twice, so that we have both a browser-optimized asset and a fastboot-optimized asset. This is what the Variant type is for.

@thoov
Copy link
Collaborator Author

thoov commented Sep 10, 2021

@ef4 Is this double build supposed to be working or is it not implemented?

@ef4
Copy link
Contributor

ef4 commented Sep 10, 2021

It's supposed to be working and tested. See fastboot-app-test.ts.

@ef4
Copy link
Contributor

ef4 commented Sep 10, 2021

That runs both in-browser tests and fastboot tests for both development and production.

@ef4
Copy link
Contributor

ef4 commented Nov 15, 2021

I think this was fixed by #974

@ef4 ef4 closed this as completed Nov 15, 2021
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

2 participants