-
Notifications
You must be signed in to change notification settings - Fork 357
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
implement first class mixins #2073
Conversation
I'm not able to reproduce the CI build failures locally. I assume it's to do with missing auto-generated (and gitignored) files that I have locally but which aren't created during the CI run. Is there something I'm missing updating for the embedded protocol files? |
@connorskees If you are making changes to the protobuf definition, you need to submit a PR for https://github.com/sass/sass, and link the PR in the description of this PR. |
I've reverted the embedded protocol changes for now as adding the protobuf changes to |
It looks like the CI is picking up the protocol buffer definition changes (at least now), so you may want to roll forward that patch. |
Do I need to link to the embedded host PR in this PR description? |
Yes, you do. |
Updated. |
You will also need to push a different commit in order for CI to get the updated PR description. E.g. an empty created by |
lib/src/js/value/mixin.dart
Outdated
|
||
/// The JavaScript `SassMixin` class. | ||
final JSClass mixinClass = () { | ||
var jsClass = createJSClass('sass.SassMixin', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it is related to the browser failure, but I think the argument is missing Object self
here when looking at all other values.
I added back the assertion to the sass-spec to see if adding that parameter fixes the browser failure. |
getJSClass(SassMixin(Callable('f', '', (_) => sassNull))) | ||
.injectSuperclass(jsClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this does not make much sense. If I understand it correctly the reason we have this for Sass Function type is to allow the "JS" type to inherit the prototype of dart-converted-JS type? If so here the argument passed into SassMixin (the dart type) should be some argument necessary to construct an actual Mixin object.
@nex3 I don't fully understand how the JS-interop works so please correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Looks like Mixin just takes AsyncCallable so this is probably fine.
If possible, I would like for the first class mixin PRs to merge quite soon -- after this week I will have significantly less time to work outside of work. |
It's not clear to me why the |
Seems it might be a known jest issue? See jestjs/jest#5946 and jestjs/jest#2549 and similar issues on stackoverflow, https://stackoverflow.com/questions/52551035/tobeinstanceofnumber-does-not-work-in-jest, https://stackoverflow.com/questions/58029714/jests-expectvalue-tobeinstanceofclass-fails-for-expectutil-promisify, and others. |
Jest does have weird |
The most recent error is interesting: |
@connorskees I think I found the root cause: we're missing ESM export here: Lines 49 to 65 in 16b8512
Node runs the CJS entrypoint but browser runs the ESM entrypoint... |
Nice find! Thank you -- that would have been annoying to find otherwise. |
I wonder if it would be possible to add a conformance check for that... |
All right, looks like everything is passing but sass/embedded-host-node#253. Once sass/embedded-host-node#255 lands, I'll merge these all in and we should be good to go. Thanks for the hard work, @connorskees! |
* feature.color-4: (30 commits) Update for `lch()` tests (sass#2108) Add support for relative color syntax (sass#2112) Update for `oklab()` tests (sass#2094) Poke CI Cut a release (sass#2107) Implement first class mixins (sass#2073) Fix a race condition preventing embedded compiler to shutdown after a protocol error (sass#2106) Switch to the GitHub-hosted MacOS ARM64 runner (sass#2103) Update the version of Sass used by the website on release (sass#2102) Bump actions/checkout from 3 to 4 (sass#2088) Bump docker/setup-qemu-action from 2 to 3 (sass#2089) Implement support for the relative color syntax of CSS Color 5 (sass#2098) Rephrase errors for numbers that must be unitless or % (sass#2101) Forbid LLM contributions (sass#2100) Update protocol-version during embedded-host-node release (sass#2097) Deprecate Deprecation.calcInterp (sass#2096) Avoid useless allocations for interpolations without maps (sass#2095) Fix an error during embedded compiler shutdown (sass#2092) Cut a release (sass#2090) Expose the containing URL to importers under some circumstances (sass#2083) ...
@@ -418,6 +418,19 @@ final class _EvaluateVisitor | |||
}); | |||
}, url: "sass:meta"), | |||
|
|||
BuiltInCallable.function("module-mixins", r"$module", (arguments) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nex3 is it expected that those functions are exposed as global aliases as well and not just as module functions or is it a mistake ? The spec PR does not mention those aliases).
The metaFunctions
variable defined here is not split between local and global lists (probably because when it was introduced, there were no local-only functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that metaMixins
below is local-only (there is no global aliases for those mixins)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, they aren't expected to be exposed globally.
Tracking issue: sass/sass#626
Protobuf changes: sass/sass#3674
Spec tests: sass/sass-spec#1933
Embedded host: sass/embedded-host-node#253
Closes #2046