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

Default globals for strict mode #1070

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Jan 18, 2025

Propose default globals for strict mode

Rendered

Implementation:

Summary

This pull request is proposing a new RFC.

To succeed, it will need to pass into the Exploring Stage, followed by the Accepted Stage.

A Proposed or Exploring RFC may also move to the Closed Stage if it is withdrawn by the author or if it is rejected by the Ember team. This requires an "FCP to Close" period.

An FCP is required before merging this PR to advance to Accepted.

Upon merging this PR, automation will open a draft PR for this RFC to move to the Ready for Released Stage.

Exploring Stage Description

This stage is entered when the Ember team believes the concept described in the RFC should be pursued, but the RFC may still need some more work, discussion, answers to open questions, and/or a champion before it can move to the next stage.

An RFC is moved into Exploring with consensus of the relevant teams. The relevant team expects to spend time helping to refine the proposal. The RFC remains a PR and will have an Exploring label applied.

An Exploring RFC that is successfully completed can move to Accepted with an FCP is required as in the existing process. It may also be moved to Closed with an FCP.

Accepted Stage Description

To move into the "accepted stage" the RFC must have complete prose and have successfully passed through an "FCP to Accept" period in which the community has weighed in and consensus has been achieved on the direction. The relevant teams believe that the proposal is well-specified and ready for implementation. The RFC has a champion within one of the relevant teams.

If there are unanswered questions, we have outlined them and expect that they will be answered before Ready for Release.

When the RFC is accepted, the PR will be merged, and automation will open a new PR to move the RFC to the Ready for Release stage. That PR should be used to track implementation progress and gain consensus to move to the next stage.

Checklist to move to Exploring

  • The team believes the concepts described in the RFC should be pursued.
  • The label S-Proposed is removed from the PR and the label S-Exploring is added.
  • The Ember team is willing to work on the proposal to get it to Accepted

Checklist to move to Accepted

  • This PR has had the Final Comment Period label has been added to start the FCP
  • The RFC is announced in #news-and-announcements in the Ember Discord.
  • The RFC has complete prose, is well-specified and ready for implementation.
    • All sections of the RFC are filled out.
    • Any unanswered questions are outlined and expected to be answered before Ready for Release.
    • "How we teach this?" is sufficiently filled out.
  • The RFC has a champion within one of the relevant teams.
  • The RFC has consensus after the FCP period.

@github-actions github-actions bot added the S-Proposed In the Proposed Stage label Jan 18, 2025
@NullVoxPopuli NullVoxPopuli mentioned this pull request Jan 19, 2025
11 tasks
@ef4 ef4 added S-Exploring In the Exploring RFC Stage and removed S-Proposed In the Proposed Stage labels Jan 24, 2025
@bartocc
Copy link

bartocc commented Jan 29, 2025

This is not a direct comment about this RFC, but I did not realize globalThis was available inside strict mode templates! And as the RFC states, it must be pretty useful!

I guess an alternative to this RFC would at least be to update the documentation to help devs take advantage of this, with examples.

As far as I'm concerned, I'll start trying to tinker with globalThis.Array etc… asap!

@tcjr
Copy link

tcjr commented Feb 23, 2025

Over time, Ember has done a great job of eliminating hard-to-debug magic (implicit #each, implicit this, etc.) The templates, in particular, have become stricter and stricter. Still, popular addons, like ember-composable-helpers, had to do elaborate opt-in/opt-out build-time shenanigans to avoid global resolver issues. Now with full strict mode and the arrival of template tag, everything is imported and there are no surprises.

The motivation section of the RFC has the example:

const { JSON } = globalThis;

<template>
  {{JSON.stringify @data null 3}}
</template>

I may be alone on this island, but I like modern Ember's strictness and I think the above is a great way indicate intent and get support with just one line of code.

So, I guess I agree with @bartocc that showcasing the availability and ease of use of globalThis would be a pretty good non-code alternative.

@NullVoxPopuli
Copy link
Contributor Author

why use globalThis for common things, when in every other js/ts file you don't need to?

@tcjr
Copy link

tcjr commented Feb 23, 2025

I dunno. I guess because the space inside a <template> tag isn't js/ts.

Feel free to completely disregard my opinion here. Of the list of things being added to the scope, I've only ever wished I had JSON. I realize I'm probably not qualified to comment since I've not encountered the UX burden this RFC is eliminating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Final Comment Period S-Exploring In the Exploring RFC Stage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants