Closed adisreyaj closed 4 years ago
Looks like ɵBrowserPlatformLocation
should be imported from @angular/common
.
Ref: Angular Github
I guess the issue is because ng add single-spa-angular
instead of installing the version 4, is installing v3. So the schematic is failing to identify the Angular version I guess.
Why was this issue closed? I am reopening. We should discuss what is needed for Angular 10 support and then implement it.
Looks like ɵBrowserPlatformLocation should be imported from @angular/common.
It is:
I guess the issue is because ng add single-spa-angular instead of installing the version 4, is installing v
Interesting, that's true.
I guess the issue is because ng add single-spa-angular instead of installing the version 4, is installing v3. So the schematic is failing to identify the Angular version I guess.
That seems like it is related to the following code? I'm not sure why that code would stop working in Angular 10.
I have actually tried again and it is still installing single-spa-angular: ^3.5.3
.
ng add single-spa-angular
Here is the dependencies list from package.json
:
{
"dependencies": {
"@angular-builders/custom-webpack": "^8",
"@angular/animations": "~10.0.0",
"@angular/common": "~10.0.0",
"@angular/compiler": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"rxjs": "~6.5.5",
"single-spa-angular": "^3.5.3",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
}
}
We didn't fix anything related to this, so it is not surprising that it isn't working yet. My comments above were to help brainstorm a solution - if anyone would like to send in a pull request with a fix, that would be appreciated.
We didn't fix anything related to this, so it is not surprising that it isn't working yet. My comments above were to help brainstorm a solution - if anyone would like to send in a pull request with a fix, that would be appreciated.
Yup..I was just trying to confirm the issue and add some additional info if needed.
Hey guys I made exactly the same process for my project (described in Demonstration part of the issue). Am I the only one that had to do these moves :
main.single-spa.ts
fileimport singleSpaAngular, { getSingleSpaExtraProviders } from 'single-spa-angular';
->
import { getSingleSpaExtraProviders, singleSpaAngular } from 'single-spa-angular';
"single-spa-angular": "^3.6.0",
"single-spa-angular": "^4.2.0",
"single-spa": "^4.4.4",
I think that's pretty all I remember on my side in addition to what you already did of course.
Ah yes I updated as well the version of custom-webpack "@angular-builders/custom-webpack": "^10.0.0-beta.0",
but I think it's not mandatory.
Hi @celian-garcia, the changes to the import
s were part of the Angular 8 to Angular 9 migration and are documented in https://github.com/single-spa/single-spa-angular/releases/tag/v4.0.0. Angular 10 also uses single-spa-angular@4.x, so anybody upgrading from Angular <= 8 to Angular 10 will need to make those changes.
Okay thanks for the info. I didn't really migrate actually I just made ng new + ng add single-spa-angular but maybe I should have explicitely mention the version of single-spa-angular somehow.
Why was this issue closed? I am reopening. We should discuss what is needed for Angular 10 support and then implement it.
Yes, we would like to upgrade our single-spa apps to Angular 10, and resolving this issue would be great. Happy to contribute my time if needed.
Hey guys I made exactly the same process for my project (described in Demonstration part of the issue). Am I the only one that had to do these moves :
Update the
main.single-spa.ts
fileimport singleSpaAngular, { getSingleSpaExtraProviders } from 'single-spa-angular';
->
import { getSingleSpaExtraProviders, singleSpaAngular } from 'single-spa-angular';
Updated the single-spa version
"single-spa-angular": "^3.6.0",
"single-spa-angular": "^4.2.0", "single-spa": "^4.4.4",
I think that's pretty all I remember on my side in addition to what you already did of course.
Ah yes I updated as well the version of custom-webpack
"@angular-builders/custom-webpack": "^10.0.0-beta.0",
but I think it's not mandatory.
I did exactly the same.
Hi @helumalai, yes if you have time and would like to contribute any changes needed for Angular 10 support, that would be greatly appreciated! @Den-dp has made a lot of progress on some related issues, as reported in https://github.com/single-spa/single-spa-angular/issues/249. I am happy to review pull requests to address the issues.
Hi, I'm using the single-spa CLI to create an angular app. I have made some changes to build and run the code (@celian-garcia thanks 😄 ) but I found this little problem when acessing the url playground:
Cannot read property 'injector' of undefined - at single-spa-angular.js:198
Have anyone faced this point?
Angular version: 10 Single Spa Angular: 4.2.0
Hi @maximillianfx I don't remember such an error. What is your main.single-spa.ts ? Mine is like this :
import { enableProdMode, NgZone } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Router } from '@angular/router';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { getSingleSpaExtraProviders, singleSpaAngular } from 'single-spa-angular';
import { singleSpaPropsSubject } from './single-spa/single-spa-props';
if (environment.production) {
enableProdMode();
}
const lifecycles = singleSpaAngular({
bootstrapFunction: singleSpaProps => {
singleSpaPropsSubject.next(singleSpaProps);
return platformBrowserDynamic(getSingleSpaExtraProviders()).bootstrapModule(AppModule);
},
template: '<abilities-root />',
Router,
NgZone,
});
export const bootstrap = lifecycles.bootstrap;
export const mount = lifecycles.mount;
export const unmount = lifecycles.unmount;
Edit: You'll need to modify the template
part according to your app component selector
Oh :/, my main.single-spa.ts:
import { enableProdMode, NgZone } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Router } from '@angular/router';
import { ɵAnimationEngine as AnimationEngine } from '@angular/animations/browser';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { singleSpaAngular, getSingleSpaExtraProviders } from 'single-spa-angular';
import { singleSpaPropsSubject } from './single-spa/single-spa-props';
if (environment.production) {
enableProdMode();
}
const lifecycles = singleSpaAngular({
bootstrapFunction: singleSpaProps => {
singleSpaPropsSubject.next(singleSpaProps);
return platformBrowserDynamic(getSingleSpaExtraProviders()).bootstrapModule(AppModule);
},
template: '<app-root />',
Router,
NgZone: NgZone,
AnimationEngine: AnimationEngine,
});
export const bootstrap = lifecycles.bootstrap;
export const mount = lifecycles.mount;
export const unmount = lifecycles.unmount;
I've read on the single spa docs the support for Angular 9. I will make a project using Angular CLI 9 and re-test.
Hello! Using this approach and angular in 9.1.7 the project is running!
Hello! Using this approach and angular in 9.1.7 the project is running!
It works on Angular 9 without any issues. Only problem is with 10. The schematic is somehow installing the version 3 of single-spa-angular instead of version 4
Hello, here is an example of a working project https://github.com/milobella/application-web, the project in itself is still in construction but the spa part is functional, with Angular 10.0.3
and single-spa-angular 4.2.0
.
@joeldenning I would be happy to contribute to ameliorate but I don't really get what is needed at the end. Maybe there is some gaps in the schematic ? I will create soon a new component from scratch, I should see at this moment if anything is missing.
Hey guys. I've checked the ng add single-spa-angular
command with Angular 10, it installed the latest version:
For me it works perfectly now.
Thanks for clarifying @celian-garcia @adisreyaj was this issue resolved? Can it be closed?
@arturovt Looks like the issue is solved.
Demonstration
ng add single-spa-angular
schematicsAPP_BASE_HREF
andEmptyRouteComponent
inAppModule
npm run serve:single-spa
Outcome
Once we run the the serve comnand, the compiler throws in this error:
Looks like the main.single-spa.ts file is not picked up by TypeScript. So I added it along in the
tsconfig.app.json
file like so:Now the error seems to be fixed. But it throws in a new one: