`isDevMode` not working in library: "cannot enable prod mode after platform setup"
See original GitHub issue🚀 feature request
Relevant Package
This feature request is for @angular/core
Description
A clear and concise description of the problem or missing capability...Yeah, here is the problem.
I have multi project:
And then instead of having 2 * 4 = 8 enviroment file duplicate for firebase information:
I really want to create only one module like this to easy import firebase module once (instead of 4 times):
but since
isDevMode
is calling in my firebase module, and it is call before enableProdMode() calling out. so I got this error
and even more, we can do tree sakeable module:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
isProdMode() ? [] : DevModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Describe the solution you’d like
If you have a solution in mind, please describe it.somekindof isProdMode()
which is can read enviroment file quickly. Doesn’t have to wait main.ts
That can be useful for reading prod
mode from library. Or multi project workspace.
Describe alternatives you’ve considered
Have you considered any alternative solutions or workarounds?solution video: https://youtu.be/UsBDLaCnALU
// environment.prod.ts
(global as any).prod = true;
// firebase.module.ts
console.log('isProd??', (global as any).prod);
The idea behind is simple.
- some magic behind (check env file or anything that know that it’s production mode) that show it’s production in varible
- allow me call
isProdMode()
before call main.ts file instead of giving mecannot enable prod mode after platform setup
like I’m callingisDevMode()
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
Uncaught Error: Cannot enable prod mode after platform setup.
I have not use isDevMode()。 The log given by the failure. open the page in the chrome,console print error:. vendor.9844cf9b240425f86ca5.
Read more >Cannot enable prod mode after platform setup. Angular 5 ...
In the sample app you provided at git/cli-reproapp the error is occurring because of this line :- export const isInDevMode = isDevMode();.
Read more >isDevMode - Angular
By default, this is true, unless enableProdMode is invoked prior to calling this method or the application is built using the Angular CLI...
Read more >@angular/core@15.0.4 - jsDocs.io
isDevMode : () => boolean;. Returns whether Angular is in development mode. By default, this is true, unless enableProdMode is invoked prior ...
Read more >Writing Your Own Extension - Quarkus
Extensions should see the configuration holistically as a Quarkus application instead of focusing on the library experience.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just place your configuration to
environments
for each type of environment, then import it in your codeAnd when you run the build/serve step with provided env, Angular CLI will replace the
environment.ts
to your destination env for you.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.