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

How to handle running in Node #21

Closed
3 tasks done
trentmwillis opened this issue Sep 19, 2016 · 8 comments
Closed
3 tasks done

How to handle running in Node #21

trentmwillis opened this issue Sep 19, 2016 · 8 comments

Comments

@trentmwillis
Copy link
Member

trentmwillis commented Sep 19, 2016

When running an Ember application in Node (such as through FastBoot), the asset-manifest module blows up since it can't read from the DOM (which doesn't exist).

There are patterns to handle this, but it raises the overarching issue of how should lazy assets be handled within a non-browser environment.

Open questions:

  • Should the Asset Manifest be present in Node? Or should it just be an empty config?
    • If the manifest is present, what should the loader functions do?
    • If the manifest is not present, what happens when a code path is hit that expects to load something?

My current thinking is:

In a Node process, all assets should be loaded upfront (need build targets in order to do this easily), but the manifest should still be present so that if a code path expects to load a bundle (or similar) it doesn't kill the app. This would mean that the loader functions should all return immediately resolving Promises (Promise.resolve()).

@nathanhammond @dgeb @rwjblue would greatly appreciate hearing your thoughts on this

Tasks:

  • Pre-load assets in non-browser environments (should be handle by whatever booted the application)
  • Enable asset-manifest to be present in non-browser environments [PR]
  • Return resolved Promises from loaders in non-browser environments [PR]
@kratiahuja
Copy link

+1 to loading everything upfront in sandbox for server side. It makes fastboot independent of app loading strategy and will probably not have a negative impact on server side rendering.

@trentmwillis
Copy link
Member Author

I've updated my original comment with what I believe are the tasks needed to make this work properly.

@trentmwillis
Copy link
Member Author

The pre-loading of assets poses an interesting problem, since this addon doesn't actually have any control over the build. Should this addon just assume that everything is pre-loaded? But leave the actual act of pre-loading up to the environment? I tend to think, yes.

@nathanhammond
Copy link
Contributor

actual act of pre-loading up to the environment.

I tend to agree that the environment should invoke loadBundles/whatever that is prior to booting since that is very environment specific.

@trentmwillis
Copy link
Member Author

the environment should invoke loadBundles/whatever that is prior to booting

Won't want to do loadBundles, the environment should just load the scripts into it's VM. Like what currently happens in FastBoot for vendor.js and app.js, see here for reference.

@trentmwillis
Copy link
Member Author

A path forward has been established and necessary changes have been made here. Will release version 0.2.0 soon with those changes.

@joebartels
Copy link

joebartels commented Mar 22, 2017

Could you share how exactly to configure this addon with fastboot and where the node-asset-manifest.js file should be located and from where it's consumed?
(apart from doing noManifest: true in the ember-cli-build.js file)

@trentmwillis
Copy link
Member Author

As far as I am aware, there is currently no way to configure this addon with Fastboot. The pieces are in place from this side, but from what I know there is no prescribed way to load additional files into the Fastboot sandbox which is what needs to be done for this to work.

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

4 participants