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

Extract validation system and tags into @glimmer/validator package #987

Merged
merged 3 commits into from
Nov 7, 2019

Conversation

pzuraq
Copy link
Member

@pzuraq pzuraq commented Nov 5, 2019

This PR extracts the tag and autotracking portions of the
@glimmer/reference package, which are fairly isolated from the rest
of the VM, and removes any additional dependencies they have on other VM
packages. This keeps them isolated, which makes it less likely that
type changes or issues could leak and cause problems in downstream
packages which have public types, such as @glimmer/tracking.

Also updates the implementation of autotracking in the VM to match Ember's directly, so that we can add this package once Ember is able to update its VM.

Impact on Ember.js and Glimmer.js

  • Imports for tag based primitives will switch to @glimmer/validator. Reference imports can remain the same.
  • Both Ember and Glimmer should be able to update to using the autotracking methods provided in this PR now, instead of writing their own from scratch.
  • For Ember, tags should be removed from Ember's meta system, and should be stored solely using the meta provided by @glimmer/validator.

@pzuraq pzuraq force-pushed the refactor/isolate-tags branch 2 times, most recently from 0d09a4f to 1566b06 Compare November 6, 2019 00:40
Chris Garrett added 2 commits November 5, 2019 16:47
This PR extracts the tag and autotracking portions of the
`@glimmer/reference` package, which are fairly isolated from the rest
of the VM, and removes any additional dependencies they have on other VM
packages. This keeps them isolated, which makes it less likely that
type changes or issues could leak and cause problems in downstream
packages which have public types, such as `@glimmer/tracking`.
import { Slice, LinkedListNode } from '@glimmer/util';
import { Tag, Tagged, createCombinatorTag, CONSTANT_TAG } from '@glimmer/tag';

export function combineTagged(tagged: ReadonlyArray<Tagged>): Tag {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this in runtime and not tag?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to avoid pulling extra types into @glimmer/tag for things that are essentially unrelated. These combinators are really optimizations for a couple of narrow use cases in the VM itself, and while I wasn't comfortable removing them/simplifying them without perf tests, I also don't think they really belong with the rest of the tracking infra, conceptually.

If perf wasn't a concern, or tests showed it wasn't an issue, I probably would have made them use the combine() function like everyone else. If perf is an issue, I think the internal createCombinatorTag API is good for solving the problem.

@@ -0,0 +1,107 @@
import { Tag, combine, CONSTANT_TAG } from './tags';
import { createTag, dirty } from './tags';
Copy link
Member

Choose a reason for hiding this comment

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

Seems vaguely odd for tag package to include tracked. Maybe “tag” isn’t the right name? Any other options?

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.

Can you update the title here and the description (since the package name is changed)?

@pzuraq pzuraq changed the title [REFACTOR] Create @glimmer/tag [REFACTOR] Create @glimmer/validator Nov 7, 2019
@pzuraq pzuraq merged commit beecb44 into master Nov 7, 2019
@pzuraq pzuraq deleted the refactor/isolate-tags branch November 7, 2019 19:03
@rwjblue
Copy link
Member

rwjblue commented Nov 8, 2019

@pzuraq - Would you mind leaving a little info in this PR description about how you expect Glimmer.js and Ember.js to absorb the breakage (might just be update import paths, but I dunno)? Just something new I'm trying to do to aid the upgrade...

@rwjblue rwjblue changed the title [REFACTOR] Create @glimmer/validator Extract validation system and tags into @glimmer/validator package Nov 8, 2019
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.

None yet

2 participants