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

[REFACTOR] Extract environment variables into global context #1138

Merged
merged 1 commit into from
Aug 22, 2020

Conversation

pzuraq
Copy link
Member

@pzuraq pzuraq commented Aug 20, 2020

There are a number of environment variables that are currently threaded
through glimmer that are:

  1. Only environment variables for compatibility reasons (e.g. legacy
    Ember compat)
  2. Never expected to change over the lifetime of an append
  3. Never expected to differ between different apps or render trees in
    the same context.

This PR consolidates these into a single global context, exported from
@glimmer/global-context, which is set once by the embedding
environment before rendering. It also upstreams the logic for
protocolForUrl, which was not specific to Ember, and simplifies
the attributeFor logic to be as minimal as possible an interface for
Ember.

packages/@glimmer/global-context/index.ts Outdated Show resolved Hide resolved
{
"name": "@glimmer/global-context",
"version": "0.58.0",
"repository": "https://github.com/glimmerjs/glimmer-vm/tree/master/packages/@glimmer/global-context",
Copy link
Member

Choose a reason for hiding this comment

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

We should update these (in a future PR) to something like:

{
  "repository": {
    "type" : "git",
    "url" : "https://github.com/glimmerjs/glimmer-vm.git",
    "directory": "packages/@glimmer/global-context"
  }
}

https://docs.npmjs.com/configuring-npm/package-json.html#repository

packages/@glimmer/global-context/package.json Show resolved Hide resolved
Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

  • Should we move the global revision stuff here? It seems very much in the same vein, though maybe we don't want to have to call a method to bump so might not want to move it...
  • Should we add a validation similar to the one we added to @glimmer/validations to prevent loading the module two times? Seems like @glimmer/global-context has much the same constraints as that one does...
  • Can you do a benchmark to confirm this doesn't have problems? (I suspect it will actually be somewhat beneficial, but good to confirm)

packages/@glimmer/reference/lib/iterable.ts Outdated Show resolved Hide resolved
packages/@glimmer/reference/lib/template.ts Outdated Show resolved Hide resolved
packages/@glimmer/reference/test/template-test.ts Outdated Show resolved Hide resolved
packages/@glimmer/runtime/lib/references.ts Show resolved Hide resolved
packages/@glimmer/runtime/lib/references.ts Show resolved Hide resolved
@pzuraq pzuraq force-pushed the refactor/make-env-module-state branch from 910635e to 79ff403 Compare August 21, 2020 22:25
valueForTag(tag1);
dirtyTag(tag3);
valueForTag(tag1);
// let tag1 = createUpdatableTag();
Copy link
Member

Choose a reason for hiding this comment

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

These comments should either be brought back or deleted.

There are a number of environment variables that are currently threaded
through glimmer that are:

1. Only environment variables for compatibility reasons (e.g. legacy
   Ember compat)
2. Never expected to change over the lifetime of an append
3. Never expected to differ between different apps or render trees in
   the same context.

This PR consolidates these into a single global context, exported from
`@glimmer/global-context`, which is set once by the embedding
environment before rendering. It also upstreams the logic for
`protocolForUrl`, which was not specific to Ember, and simplifies
the `attributeFor` logic to be as minimal as possible an interface for
Ember.
@pzuraq pzuraq force-pushed the refactor/make-env-module-state branch from e9c5581 to 47142cc Compare August 22, 2020 16:11
pzuraq pushed a commit to emberjs/ember.js that referenced this pull request Aug 22, 2020
@pzuraq
Copy link
Member Author

pzuraq commented Aug 22, 2020

Benchmark shows no significant change:
results.pdf

@rwjblue rwjblue merged commit 6b0db3a into master Aug 22, 2020
@rwjblue rwjblue deleted the refactor/make-env-module-state branch August 22, 2020 17:11
pzuraq pushed a commit to emberjs/ember.js that referenced this pull request Aug 22, 2020
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.

2 participants