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

"Remove Bootstrap" with angular 19 #19858

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8b4da66
[POC] Remove bootstrap from Spartacus
pawelfras Sep 30, 2024
7021c7c
chore: Upgrade to Angular 18 - NX Migration
pawelfras Nov 25, 2024
1aab1a4
chore: Upgrade to Angular 18 - Angular CLI migration
pawelfras Nov 25, 2024
da09c85
chore: Upgrade to Angular 18 - Angular packages migration
pawelfras Nov 25, 2024
09fed9b
chore: Upgrade to Angular 18 - update ng-packagr to 18.2.1
pawelfras Nov 25, 2024
3a08381
chore: Upgrade to Angular 18 - NgRx upgrade
pawelfras Nov 25, 2024
bb3dfb5
chore: Upgrade to Angular 18 - Upgrade Angular-related libraries
pawelfras Nov 26, 2024
a3efbbc
chore: Upgrade to Angular 18 - Linting
pawelfras Oct 16, 2024
09def4a
chore: Upgrade to Angular 18 - Fix build issues
pawelfras Oct 10, 2024
36d1d73
chore: Upgrade TypeScript ESLint packages
pawelfras Nov 26, 2024
0d87021
chore: Prettier fix
pawelfras Nov 26, 2024
9a4c7e9
fix: Issues raised by unit tests
pawelfras Oct 14, 2024
ea7caf7
Add license header
github-actions[bot] Nov 26, 2024
fae4573
fix typo
pawelfras Nov 26, 2024
5734b1b
chore: update dependencies
pawelfras Nov 26, 2024
1518aee
fix: Issues raised by schematics unit tests
pawelfras Nov 26, 2024
d0a6754
fix: Issues raised by schematics unit tests
pawelfras Nov 26, 2024
d657d33
chore: Upgrade to Angular 18 - Linter For Styles
pawelfras Oct 28, 2024
2c0b621
fix: Issues raised by E2E tests
pawelfras Nov 27, 2024
c860074
chore: Upgrade to Angular 18 - Replace deprecated TSESLint.RuleTester
pawelfras Nov 18, 2024
41ff83e
fix: Schematics issues
pawelfras Nov 15, 2024
5a38094
chore: Upgrade to Angular 18 - Replace deprecated RouterTestingModule
pawelfras Nov 15, 2024
9a2cbef
chore: Migration docs
pawelfras Nov 28, 2024
5a15804
refactor after review
pawelfras Dec 9, 2024
aa18bcd
update package-lock file
pawelfras Dec 9, 2024
880b121
Merge branch 'develop-next-major' into epic/upgrade-to-angular-18
pawelfras Dec 9, 2024
ca64f33
Merge branch 'develop-next-major' into epic/upgrade-to-angular-18
pawelfras Dec 9, 2024
97a7ad8
fix stylelint issue
pawelfras Dec 10, 2024
b4865a5
Merge remote-tracking branch 'origin/poc-remove-bootstrap' into chore…
kpawelczak Dec 10, 2024
be03907
Update extra-webpack.config.js
kpawelczak Dec 11, 2024
2244194
Update bootstrap.scss
kpawelczak Dec 11, 2024
158766c
chore: Nx migration (all packages and their migration)
pawelfras Dec 12, 2024
f95bd2c
chore: Change Version Range Specifier For Typescript
pawelfras Dec 12, 2024
54ca560
fix: Build issues
pawelfras Dec 13, 2024
51ae9c4
chore: Update '@angular-builders/custom-webpack' to '19.0.0-beta.0'
pawelfras Dec 13, 2024
71152c8
fix: Issues In Unit Tests
pawelfras Dec 4, 2024
f77c7eb
chore: Update dependencies
pawelfras Dec 16, 2024
5389096
Merge branch 'develop-next-major' into chore/CXSPA-9094-remove-bootsrap
kpawelczak Dec 17, 2024
1126c06
fix: Fix issues with schematics and related unit tests
pawelfras Dec 17, 2024
e3e935d
chore: Fix linter issues
pawelfras Dec 17, 2024
4048f17
chore: Fix prettier issues
pawelfras Dec 17, 2024
34574a8
chore: Update NgRx to v19.0.0-beta.0
pawelfras Dec 17, 2024
b1bc98c
chore: Upgrade `@typescript-eslint` packages to 8.18.1
pawelfras Dec 17, 2024
6d1bf09
chore: Update package-lock file
pawelfras Dec 17, 2024
ccf37f2
chore: Upgrade NgRx to stable version 19.0.0
pawelfras Dec 18, 2024
c1fa528
chore: Update dependencies and package-lock file
pawelfras Dec 18, 2024
6bdbab6
- Added Bootstrap SCSS imports in `styles.scss`
Platonn Dec 17, 2024
0decd69
Refactor modal dialogs to use Bootstrap in HTML instead custom CSS cl…
Platonn Dec 17, 2024
5f26018
Import '@spartacus/styles/scss/core' in the storefrontapp BEFORE impo…
Platonn Dec 17, 2024
3984894
fix: Jest tests issues
pawelfras Dec 18, 2024
85526ca
Trigger Build
pawelfras Dec 19, 2024
a004277
Trigger Build
pawelfras Dec 19, 2024
7f46595
package-lock.json
kpawelczak Dec 19, 2024
fda646d
prettier fix
kpawelczak Dec 20, 2024
8da6be2
chore: Initial migration docs
pawelfras Dec 24, 2024
ef4ede7
refactor: Adjust installation schematics for SSR to use `server/index…
pawelfras Dec 30, 2024
89b2d08
docs: Update migration docs
pawelfras Dec 31, 2024
2cc93dd
Add license header
github-actions[bot] Jan 2, 2025
b0afc4d
Revert "Add license header"
kpawelczak Jan 2, 2025
dcf31e6
Merge branch 'develop-next-major' into bootstrap-spa-copy-headers
kpawelczak Jan 2, 2025
1ec74e0
chore Upgrade '@angular-builders/custom-webpack' to version 19.0.0
pawelfras Jan 7, 2025
010afb9
test and fix dialogs affected by the removal of extended bootstrap cl…
Pio-Bar Jan 7, 2025
3fb0b3a
Add license header
github-actions[bot] Jan 7, 2025
587ce7b
Revert "Add license header"
pawelfras Jan 7, 2025
c304b34
Add license header
github-actions[bot] Jan 7, 2025
0daa7ed
fix package-lock
kpawelczak Jan 7, 2025
894804b
Merge branch 'epic/CXSPA-9094-bootstrap' of https://github.com/SAP/sp…
kpawelczak Jan 7, 2025
64abdfb
move to vendor
kpawelczak Jan 7, 2025
3850b1e
update deps
kpawelczak Jan 7, 2025
bd7b987
Create bootstrap.md
kpawelczak Jan 7, 2025
7840e87
Update _image.scss
kpawelczak Jan 7, 2025
d64c33a
Update _image.scss
kpawelczak Jan 7, 2025
f94b44c
fix style errors
kpawelczak Jan 7, 2025
2f39a22
Update index_spec.ts.snap
kpawelczak Jan 7, 2025
7e87602
no bootstrap spartacus installation (#19797)
kpawelczak Jan 8, 2025
c59ccf8
Revert "Add license header"
pawelfras Jan 8, 2025
b5500cb
Merge branch 'develop-next-major' into epic/upgrade-to-angular-19
pawelfras Jan 8, 2025
d0b289e
add bootstrap license (#19801)
kpawelczak Jan 9, 2025
0689bfd
rm imports
kpawelczak Jan 9, 2025
f554f79
Update project.json
kpawelczak Jan 9, 2025
d399c2f
Merge branch 'epic/upgrade-to-angular-19' into epic/CXSPA-90943-boots…
kpawelczak Jan 13, 2025
4ee044d
remove bootstrap import
kpawelczak Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
],
"plugins": ["deprecation", "@typescript-eslint", "@nx", "@stylistic/ts"],
"rules": {
"@angular-eslint/no-host-metadata-property": "off",
"deprecation/deprecation": "warn",
"prefer-arrow/prefer-arrow-functions": "off",
"space-before-function-paren": "off",
Expand All @@ -30,6 +29,7 @@
"no-fallthrough": "off",
"prefer-const": "off",
"@angular-eslint/use-lifecycle-interface": "error",
"@angular-eslint/prefer-standalone": "off",
"@stylistic/ts/quotes": "off",
"@stylistic/ts/member-delimiter-style": [
"error",
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ feature-libs/smartedit/assets/webApplicationInjector.js
coverage

/.nx/cache
/.nx/workspace-data
/.nx/workspace-data
projects/storefrontstyles/vendor/**/*.scss
10 changes: 8 additions & 2 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
"margin-inline"
],
"declaration-property-value-disallowed-list": {
"text-align": ["right", "left"]
"text-align": [
"right",
"left"
]
},
"scss/comment-no-loud": true
}
},
"ignoreFiles": [
"projects/storefrontstyles/vendor/**/*.scss"
]
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ Many improvements are coming! All tasks will be posted to our GitHub issue track

Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the [LICENSE](LICENSE) file.

15 changes: 12 additions & 3 deletions core-libs/setup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ const { defaultTransformerOptions } = require('jest-preset-angular/presets');
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
preset: 'jest-preset-angular',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/',
}),
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/',
}),
// mapping required to use `beasties` from node modules that has proper ES module format
// instead of the version internalized by the Angular Team which file format is not supported
// by Jest.
// for more, see: https://github.com/angular/angular-cli/pull/28228
// and: https://github.com/angular/angular-cli/pull/28726
'^../third_party/beasties/index.js$':
'<rootDir>/../../node_modules/beasties',
},
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
Expand Down
6 changes: 3 additions & 3 deletions core-libs/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@angular/core": "^18.2.9",
"@angular/ssr": "^18.2.9",
"@angular/core": "^19.0.3",
"@angular/ssr": "^19.0.4",
"@spartacus/cart": "2211.32.0-1",
"@spartacus/core": "2211.32.0-1",
"@spartacus/order": "2211.32.0-1",
"@spartacus/user": "2211.32.0-1"
},
"optionalDependencies": {
"@angular/platform-server": "^18.2.9",
"@angular/platform-server": "^19.0.3",
"express": "^4.21.2"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { CommonEngineOptions, CommonEngineRenderOptions } from '@angular/ssr';
import {
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr/node';
import { NgSetupOptions } from '../engine/ng-express-engine';
import {
OptimizedSsrEngine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ exports[`CxCommonEngine should handle APP_INITIALIZER errors the standard Angula

exports[`CxCommonEngine should handle errors propagated from SSR 1`] = `"test error"`;

exports[`CxCommonEngine should not override providers passed to options 1`] = `"<html data-critters-container><head></head><body><cx-token ng-version="18.2.9" ng-server-context="ssr">message:test</cx-token></body></html>"`;
exports[`CxCommonEngine should not override providers passed to options 1`] = `"<html data-beasties-container><head></head><body><cx-token ng-version="19.0.3" ng-server-context="ssr">message:test</cx-token></body></html>"`;

exports[`CxCommonEngine should return html if no errors 1`] = `"<html data-critters-container><head></head><body><cx-mock ng-version="18.2.9" ng-server-context="ssr">some template</cx-mock></body></html>"`;
exports[`CxCommonEngine should return html if no errors 1`] = `"<html data-beasties-container><head></head><body><cx-mock ng-version="19.0.3" ng-server-context="ssr">some template</cx-mock></body></html>"`;
8 changes: 7 additions & 1 deletion core-libs/setup/ssr/engine/cx-common-engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { PROPAGATE_ERROR_TO_SERVER } from '../error-handling/error-response/prop
import { CxCommonEngine } from './cx-common-engine';

// Test how the CxCommonEngine handles successful server-side rendering
@Component({ selector: 'cx-mock', template: 'some template' })
@Component({
selector: 'cx-mock',
template: 'some template',
standalone: false,
})
export class SuccessComponent {}

@NgModule({
Expand All @@ -22,6 +26,7 @@ export class SuccessServerModule {}
@Component({
selector: 'cx-response',
template: ``,
standalone: false,
})
export class WithPropagatedErrorComponent {
constructor() {
Expand All @@ -43,6 +48,7 @@ export const SOME_TOKEN = new InjectionToken<string>('SOME_TOKEN');
@Component({
selector: 'cx-token',
template: `message:{{ someToken }}`,
standalone: false,
})
export class TokenComponent {
someToken = inject(SOME_TOKEN);
Expand Down
2 changes: 1 addition & 1 deletion core-libs/setup/ssr/engine/cx-common-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CommonEngine,
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr';
} from '@angular/ssr/node';
import { PROPAGATE_ERROR_TO_SERVER } from '../error-handling/error-response/propagate-error-to-server';

/**
Expand Down
14 changes: 12 additions & 2 deletions core-libs/setup/ssr/engine/ng-express-engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { ngExpressEngine } from './ng-express-engine';
* - https://github.com/angular/universal/blob/e798d256de5e4377b704e63d993dc56ea35df97d/modules/express-engine/spec/mock.server.module.ts
*
*/
@Component({ selector: 'cx-mock', template: 'some template' })
@Component({
selector: 'cx-mock',
template: 'some template',
standalone: false,
})
export class MockComponent {}

/**
Expand Down Expand Up @@ -57,7 +61,11 @@ export class MockServerModule {}
* - https://github.com/angular/universal/blob/e798d256de5e4377b704e63d993dc56ea35df97d/modules/express-engine/spec/mock.server.module.ts
*
*/
@Component({ selector: 'cx-request', template: `url:{{ _req.url }}` })
@Component({
selector: 'cx-request',
template: `url:{{ _req.url }}`,
standalone: false,
})
export class RequestComponent {
constructor(@Inject(REQUEST) public readonly _req: any) {}
}
Expand Down Expand Up @@ -94,6 +102,7 @@ export class RequestServerModule {}
@Component({
selector: 'cx-response',
template: `statusCode:{{ _res.statusCode }}`,
standalone: false,
})
export class ResponseComponent {
constructor(@Inject(RESPONSE) public readonly _res: any) {}
Expand Down Expand Up @@ -144,6 +153,7 @@ export const SOME_TOKEN = new InjectionToken<string>('SOME_TOKEN');
@Component({
selector: 'cx-token',
template: `message:{{ _someToken.message }}`,
standalone: false,
})
export class TokenComponent {
constructor(@Inject(SOME_TOKEN) public readonly _someToken: any) {}
Expand Down
5 changes: 4 additions & 1 deletion core-libs/setup/ssr/engine/ng-express-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import { StaticProvider } from '@angular/core';
import { CommonEngineOptions, CommonEngineRenderOptions } from '@angular/ssr';
import {
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr/node';
import { Request, Response } from 'express';
import { REQUEST, RESPONSE } from '../tokens/express.tokens';
import { CxCommonEngine } from './cx-common-engine';
Expand Down
5 changes: 4 additions & 1 deletion core-libs/setup/ssr/optimized-engine/rendering-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class RenderingCache {
if (this.options?.cacheSize) {
this.renders.delete(key);
if (this.renders.size >= this.options.cacheSize) {
this.renders.delete(this.renders.keys().next().value);
const oldestKey = this.renders.keys().next().value;
if (oldestKey !== undefined) {
this.renders.delete(oldestKey);
}
}
}
// cache only if shouldCacheRenderingResult return true
Expand Down
53 changes: 53 additions & 0 deletions docs/migration/2211_ng18/bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Spartacus migration - Bootstrap

1. Uninstall Bootstrap
If the bootstrap package is still installed in your project, uninstall it to avoid conflicts. Use
the following command:
```npm uninstall bootstrap```
2. Update `styles.scss`
Modify the `styles.scss` file to integrate Spartacus styles along with Bootstrap. Proper import order is critical for
styles to be applied correctly.
### Steps to Update:
1. Place the following import for styles-config at the top of the file:
```@import 'styles-config';```
2. Add Spartacus core styles first. Importing Spartacus styles before Bootstrap ensures core styles load as a
priority.
3. Follow this by importing Bootstrap styles using the Bootstrap copy provided by Spartacus. Ensure the order of
Bootstrap imports matches the sequence below for consistency.
4. Conclude with the Spartacus index styles.


Final file structure should look like this:

```styles.scss
// ORDER IMPORTANT: Spartacus core first
@import '@spartacus/styles/scss/core';

// ORDER IMPORTANT: Bootstrap next
@import '@spartacus/styles/vendor/bootstrap/scss/reboot';
@import '@spartacus/styles/vendor/bootstrap/scss/type';
@import '@spartacus/styles/vendor/bootstrap/scss/grid';
@import '@spartacus/styles/vendor/bootstrap/scss/utilities';
@import '@spartacus/styles/vendor/bootstrap/scss/transitions';
@import '@spartacus/styles/vendor/bootstrap/scss/dropdown';
@import '@spartacus/styles/vendor/bootstrap/scss/card';
@import '@spartacus/styles/vendor/bootstrap/scss/nav';
@import '@spartacus/styles/vendor/bootstrap/scss/buttons';
@import '@spartacus/styles/vendor/bootstrap/scss/forms';
@import '@spartacus/styles/vendor/bootstrap/scss/custom-forms';
@import '@spartacus/styles/vendor/bootstrap/scss/modal';
@import '@spartacus/styles/vendor/bootstrap/scss/close';
@import '@spartacus/styles/vendor/bootstrap/scss/alert';
@import '@spartacus/styles/vendor/bootstrap/scss/tooltip';

@import '@spartacus/styles/index';
```
3. Individual imports.
If your application directly imports specific Bootstrap classes in any of your stylesheets, replace those imports with the corresponding Spartacus imports. For example:
```
// Original import
@import '~bootstrap/scss/reboot';

// Replace with
@import '@spartacus/styles/vendor/bootstrap/scss/reboot';
```
38 changes: 0 additions & 38 deletions docs/migration/2211_ng18/migration.md

This file was deleted.

53 changes: 53 additions & 0 deletions docs/migration/2211_ng19/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# (EARLY NOTES) Migrating a custom app to use Spartacus with Angular v18

Before upgrading Spartacus to the new version with Angular 18, you need to first:
- upgrade to the latest 2211.x of Spartacus
- upgrade Angular to version v18 and then to v19

## Update Angular to 18 and 19

### Update Angular to 18 and 3rd party deps to be compatible with Angular 18

Follow the [Angular guidelines for upgrading from v17 to v18](https://angular.dev/update-guide?v=17.0-18.0&l=3) and bump the Angular version locally, and update other 3rd party dependencies from Angular ecosystem to versions compatible with Angular 18 (e.g. `@ng-select/ng-select@13`, `@ngrx/store@18`, `ngx-infinite-scroll@18`):

```bash
ng update @angular/core@18 @angular/cli@18 @ng-select/ng-select@13 @ngrx/store@18 ngx-infinite-scroll@18 --force
git add .
git commit -m "update angular 18 and 3rd party deps angular 18 compatible"
```
Note: Do not select `use-application-builder` migration when migrating to Angular 18. Applications created before SPA 2211.19 doesn't support this builder. Applications created starting from 2211.19 already supports it.

### Update Angular to 19 and 3rd party deps to be compatible with Angular 19

Follow the [Angular guidelines for upgrading from v18 to v19](https://angular.dev/update-guide?v=18.0-19.0&l=3) and bump the Angular version locally, and update other 3rd party dependencies from Angular ecosystem to versions compatible with Angular 19 (e.g. `@ng-select/ng-select@14`, `@ngrx/store@19`, `ngx-infinite-scroll@19`):

```bash
ng update @angular/cli@19 @angular/core@19 ngx-infinite-scroll@19 @ng-select/ng-select@14 @ngrx/store@19 angular-oauth2-oidc@19 --force
git add .
git commit -m "update angular 19 and 3rd party deps angular 19 compatible"
```

Note: Unselect `use-application-builder` migration when migrating to Angular 19. Applications created before SPA 2211.19 doesn't support this builder. Applications created starting from 2211.19 already supports it.

## Run Spartacus update

After successfully updating the application to Angular 19, execute this command to initiate the Spartacus update process.

```bash
ng update @spartacus/schematics@latest
```

### If using Server Side Rendering (SSR) and `application` builder

For applications using `application` builder having SSR support, you need to adjust the `server.ts` file to be compatible with the output generated by the builder.

```diff
/* ... */
- const indexHtml = path.join(browserDistFolder, 'index.html');
+ const indexHtml = path.join(serverDistFolder, 'index.server.html');
```





7 changes: 6 additions & 1 deletion feature-libs/asm/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["schematics/**/*.d.ts"]
"ignorePatterns": ["schematics/**/*.d.ts"],
"overrides": [
{
"files": ["*.ts"]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

@Pipe({
name: 'cxTranslate',
standalone: false,
})
class MockTranslatePipe implements PipeTransform {
transform(): any {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum BIND_CART_DIALOG_ACTION {
@Component({
selector: 'cx-asm-bind-cart-dialog',
templateUrl: './asm-bind-cart-dialog.component.html',
standalone: false,
})
export class AsmBindCartDialogComponent {
BIND_CART_ACTION = BIND_CART_DIALOG_ACTION;
Expand Down
Loading
Loading