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

create isNode (or isServer) and isBrowser #397

Closed
2 of 10 tasks
PatrickJS opened this issue May 9, 2016 · 6 comments
Closed
2 of 10 tasks

create isNode (or isServer) and isBrowser #397

PatrickJS opened this issue May 9, 2016 · 6 comments

Comments

@PatrickJS
Copy link
Member

  • I'm submitting a ...
  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.
  • What modules are related to this pull-request
  • express-engine
  • grunt-prerender
  • gulp-prerender
  • hapi-engine
  • preboot
  • universal
  • webpack-prerender

return true or false per code split path

@jeffwhelpley
Copy link
Contributor

Nooooooooooooooooooooo.

OK, so at the very least can we not expose this feature unless users set a config flag? I understand that we need this for certain low level libraries when we don't have control over the user bootstrap, but we should discourage the use of this in most cases.

@PatrickJS
Copy link
Member Author

PatrickJS commented May 10, 2016

we should discourage use of it but we do need escape hatches. It's easier for demos and starting off with Universal. We should recommend how to refactor services/etc into the correct universal patterns

@JohnGorter
Copy link
Contributor

Patrick,

Talked about taking on this feature, tell me (here or slack) what needs to be done :-)

@jeffwhelpley
Copy link
Contributor

Actually, to this point, I think during our last call, @gdi2290, you seemed to have an idea of how you wanted to implement this, but we never said it explicitly. There are really two approaches here:

  1. Have user pass in some value to Universal at build time that specifies the environment.
  2. Have Universal infer the environment based on some global known factor (ex. if (!window))

It would seem like the first option is preferable which would mean we would be modifying the Universal API to accept in an environment value which is then stored at the platform level and is accessible through getters in the Universal API. If that lines up with what you are thinking, then the only question is whether the user should be able to check arbitrary environment values (ex. if (universal.isEnvironment('server'))) or if we want to just have a boolean isNode/isBrowser. I think you were leaning toward the later on this one, but that approach is less flexible.

@PatrickJS
Copy link
Member Author

I ended up doing it via 2bdeb32

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants