-
Notifications
You must be signed in to change notification settings - Fork 12k
replaceBootstrap transformer fails when bootstrapModule() call is not chained with platformBrowserDynamic() call #8880
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
Comments
I found a workaround for this by using:
However, a better error message or a comment in the generated main.ts would at least be an improvement. |
I have the same issue when trying to fork my code in
// main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { UnderConstructionModule } from './under-construction/under-construction.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
if (environment.production) {
platformBrowserDynamic().bootstrapModule( UnderConstructionModule )
.catch( err => console.log( err ) );
} else {
platformBrowserDynamic().bootstrapModule( AppModule )
.catch( err => console.log( err ) );
} Without --prod modifier, VersionsAngular CLI: 1.7.4 @ angular/cli: 1.7.4 |
Hello, I am facing the same issue of mcgraphix with: Versions`Angular CLI: 6.1.1 Package Version@angular-devkit/architect 0.7.1 Do you know if you will work on this limitation and when ? Thank you very much. |
Versions As @JavierFuentes and @guisaas mentioned there is an issue when use fork in the main.ts. It affects I believe all environments with production=true flag. Furthermore if you run ng serve or ng build with --configuration={evnironmentValue}, application will fail with "No NgModule metadata found for..." Thanks! |
I've used workaround with angular.json -> configurations -> fileReplacements section. Replace your main.ts with another one that contains the second module. Works for me. |
Any updates on this? I have a related issue, I'd like to create the custom platform:
And get the same error, only with AOT:
Chaining it directly doesn't help:
Produces the same error. |
Heya, does using We try to identify the |
@filipesilva Hi! It's not related to my usecase. In my case, I want to create a custom platform based on platformBrowserDynamic, and then bootstrap an app with it.
and this
leads to AOT error that I described |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
Error: No NgModule metadata found for 'function (){}'.
Observed behavior
Complete stack trace:
Desired behavior
It should work identically as when the calls are chained.
Mention any other details that might be useful (optional)
The reason for making this change to split into two lines is that in my case, in the handler for the promise returned from bootstrapModule() I need to do some initialization and I need access to the platfor. Calling platformBrowserDynamic() seems to return a different platform if you call it a second time so I need the one used to call bootstrapModule on:
The only workaround at the moment for this is to create a separate main-prod.ts file, eject the webpack config and then modify it to use a different main file for prod vs. dev build.
The text was updated successfully, but these errors were encountered: