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

Consider removing/renaming ngDevMode const declaration from the polyfill #174

Open
Maximaximum opened this issue Apr 12, 2024 · 6 comments · May be fixed by #194
Open

Consider removing/renaming ngDevMode const declaration from the polyfill #174

Maximaximum opened this issue Apr 12, 2024 · 6 comments · May be fixed by #194

Comments

@Maximaximum
Copy link

Currenty, the polyfill depends on the existence of the ngDevMode variable in several places to decide whether it should throw useful error messages. This is obviously a copy-paste artifact from the Angular signals codebase.

Looks like the variable should be renamed to something framework-agnostic, like signal-polyfill-debug, and its usage should be documented in the README. Otherwise, any mentions of ngDevMode could be removed altogether, and the debug messages could just always be printed.

I'd be willing to make a PR for that if needed.

@NullVoxPopuli
Copy link
Collaborator

Why not import.meta?.env?.DEBUG?

This is a rising standard, iirc

Maximaximum pushed a commit to Maximaximum/proposal-signals that referenced this issue Apr 12, 2024
@Maximaximum
Copy link
Author

Sounds reasonable. Created a PR for that: #175

@littledan
Copy link
Member

Is this declaration preventing anyone from debugging their code with signals? If not, I'd prefer to leave things as they are now, to facilitate later re-upstreaming into Angular. Maybe we can work out a better solution with them.

I'm not so sure about that query--sounds like it'll always be false in browsers!

@Maximaximum
Copy link
Author

Is this declaration preventing anyone from debugging their code with signals? If not, I'd prefer to leave things as they are now, to facilitate later re-upstreaming into Angular. Maybe we can work out a better solution with them.

No, it's not preventing from debugging, it's just that:

  1. It's an undocumented prerequisite for being able to get meaningful error messages in 2 locations in the code of the polyfill
  2. The name of the variable is clearly Angular-specific. That variable is used throughout the Angular codebase for enabling additional runtime checks and errors. People using the polyfill outside of Angular might be confused by depending on this variable

At the end of the day, though, if you're planning to postpone any updates to the polyfill code or its documentation until some time later for whatever reason, it's totally fine.

@NullVoxPopuli
Copy link
Collaborator

Can we get angular to support import.meta.env.DEV?

@littledan
Copy link
Member

Yeah let's discuss this with Angular upstream to see what we can do next.

@dead-claudia dead-claudia linked a pull request Apr 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants