Skip to content

Commit ddcde48

Browse files
committed
angular: drop browser-sync-webpack-plugin support for non microfrontends
1 parent dc30974 commit ddcde48

File tree

6 files changed

+65
-45
lines changed

6 files changed

+65
-45
lines changed

generators/angular/__snapshots__/generator.spec.ts.snap

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa
3232
"clientRoot/package.json": {
3333
"stateCleared": "modified",
3434
},
35+
"clientRoot/proxy.config.mjs": {
36+
"stateCleared": "modified",
37+
},
3538
"clientRoot/src/404.html": {
3639
"stateCleared": "modified",
3740
},
@@ -671,9 +674,6 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa
671674
"clientRoot/webpack/logo-jhipster.png": {
672675
"stateCleared": "modified",
673676
},
674-
"clientRoot/webpack/proxy.conf.js": {
675-
"stateCleared": "modified",
676-
},
677677
"clientRoot/webpack/webpack.custom.js": {
678678
"stateCleared": "modified",
679679
},
@@ -702,15 +702,13 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa
702702
"dependencies": {},
703703
"devDependencies": {
704704
"@angular-builders/custom-webpack": null,
705-
"browser-sync-webpack-plugin": null,
706705
"copy-webpack-plugin": null,
707706
"eslint-webpack-plugin": null,
708707
"webpack-bundle-analyzer": null,
709708
"webpack-merge": null,
710709
"webpack-notifier": null,
711710
},
712711
"overrides": {
713-
"browser-sync": "BROWSER_SYNC_VERSION",
714712
"webpack": "WEBPACK_VERSION",
715713
},
716714
},
@@ -750,6 +748,9 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend
750748
"clientRoot/package.json": {
751749
"stateCleared": "modified",
752750
},
751+
"clientRoot/proxy.config.mjs": {
752+
"stateCleared": "modified",
753+
},
753754
"clientRoot/src/404.html": {
754755
"stateCleared": "modified",
755756
},
@@ -1611,9 +1612,6 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend
16111612
"clientRoot/webpack/logo-jhipster.png": {
16121613
"stateCleared": "modified",
16131614
},
1614-
"clientRoot/webpack/proxy.conf.js": {
1615-
"stateCleared": "modified",
1616-
},
16171615
"clientRoot/webpack/webpack.custom.js": {
16181616
"stateCleared": "modified",
16191617
},
@@ -1645,7 +1643,6 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend
16451643
},
16461644
"devDependencies": {
16471645
"@angular-builders/custom-webpack": null,
1648-
"browser-sync-webpack-plugin": null,
16491646
"copy-webpack-plugin": null,
16501647
"eslint-webpack-plugin": null,
16511648
"folder-hash": null,
@@ -1655,7 +1652,6 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend
16551652
"webpack-notifier": null,
16561653
},
16571654
"overrides": {
1658-
"browser-sync": "BROWSER_SYNC_VERSION",
16591655
"webpack": "WEBPACK_VERSION",
16601656
},
16611657
},
@@ -1695,6 +1691,9 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi
16951691
"clientRoot/package.json": {
16961692
"stateCleared": "modified",
16971693
},
1694+
"clientRoot/proxy.config.mjs": {
1695+
"stateCleared": "modified",
1696+
},
16981697
"clientRoot/src/404.html": {
16991698
"stateCleared": "modified",
17001699
},
@@ -2310,9 +2309,6 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi
23102309
"clientRoot/webpack/logo-jhipster.png": {
23112310
"stateCleared": "modified",
23122311
},
2313-
"clientRoot/webpack/proxy.conf.js": {
2314-
"stateCleared": "modified",
2315-
},
23162312
"clientRoot/webpack/webpack.custom.js": {
23172313
"stateCleared": "modified",
23182314
},
@@ -2349,18 +2345,24 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi
23492345
"dependencies": {},
23502346
"devDependencies": {
23512347
"@angular-builders/custom-webpack": null,
2352-
"browser-sync-webpack-plugin": null,
23532348
"copy-webpack-plugin": null,
23542349
"eslint-webpack-plugin": null,
23552350
"webpack-bundle-analyzer": null,
23562351
"webpack-merge": null,
23572352
"webpack-notifier": null,
23582353
},
23592354
"overrides": {
2360-
"browser-sync": "BROWSER_SYNC_VERSION",
23612355
"webpack": "WEBPACK_VERSION",
23622356
},
23632357
},
2358+
{
2359+
"devDependencies": {
2360+
"browser-sync-webpack-plugin": null,
2361+
},
2362+
"overrides": {
2363+
"browser-sync": "BROWSER_SYNC_VERSION",
2364+
},
2365+
},
23642366
],
23652367
}
23662368
`;
@@ -2397,6 +2399,9 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD
23972399
"package.json": {
23982400
"stateCleared": "modified",
23992401
},
2402+
"proxy.config.mjs": {
2403+
"stateCleared": "modified",
2404+
},
24002405
"src/main/webapp/404.html": {
24012406
"stateCleared": "modified",
24022407
},
@@ -3021,9 +3026,6 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD
30213026
"webpack/logo-jhipster.png": {
30223027
"stateCleared": "modified",
30233028
},
3024-
"webpack/proxy.conf.js": {
3025-
"stateCleared": "modified",
3026-
},
30273029
"webpack/webpack.custom.js": {
30283030
"stateCleared": "modified",
30293031
},
@@ -3059,7 +3061,6 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD
30593061
},
30603062
"devDependencies": {
30613063
"@angular-builders/custom-webpack": null,
3062-
"browser-sync-webpack-plugin": null,
30633064
"copy-webpack-plugin": null,
30643065
"eslint-webpack-plugin": null,
30653066
"folder-hash": null,
@@ -3069,10 +3070,17 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD
30693070
"webpack-notifier": null,
30703071
},
30713072
"overrides": {
3072-
"browser-sync": "BROWSER_SYNC_VERSION",
30733073
"webpack": "WEBPACK_VERSION",
30743074
},
30753075
},
3076+
{
3077+
"devDependencies": {
3078+
"browser-sync-webpack-plugin": null,
3079+
},
3080+
"overrides": {
3081+
"browser-sync": "BROWSER_SYNC_VERSION",
3082+
},
3083+
},
30763084
],
30773085
}
30783086
`;
@@ -3109,6 +3117,9 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(
31093117
"package.json": {
31103118
"stateCleared": "modified",
31113119
},
3120+
"proxy.config.mjs": {
3121+
"stateCleared": "modified",
3122+
},
31123123
"src/main/webapp/404.html": {
31133124
"stateCleared": "modified",
31143125
},
@@ -4141,9 +4152,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(
41414152
"webpack/logo-jhipster.png": {
41424153
"stateCleared": "modified",
41434154
},
4144-
"webpack/proxy.conf.js": {
4145-
"stateCleared": "modified",
4146-
},
41474155
"webpack/webpack.custom.js": {
41484156
"stateCleared": "modified",
41494157
},
@@ -4172,7 +4180,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(
41724180
},
41734181
"devDependencies": {
41744182
"@angular-builders/custom-webpack": null,
4175-
"browser-sync-webpack-plugin": null,
41764183
"copy-webpack-plugin": null,
41774184
"eslint-webpack-plugin": null,
41784185
"folder-hash": null,
@@ -4182,7 +4189,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(
41824189
"webpack-notifier": null,
41834190
},
41844191
"overrides": {
4185-
"browser-sync": "BROWSER_SYNC_VERSION",
41864192
"webpack": "WEBPACK_VERSION",
41874193
},
41884194
},
@@ -4222,6 +4228,9 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe
42224228
"package.json": {
42234229
"stateCleared": "modified",
42244230
},
4231+
"proxy.config.mjs": {
4232+
"stateCleared": "modified",
4233+
},
42254234
"src/main/webapp/404.html": {
42264235
"stateCleared": "modified",
42274236
},
@@ -4834,9 +4843,6 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe
48344843
"webpack/logo-jhipster.png": {
48354844
"stateCleared": "modified",
48364845
},
4837-
"webpack/proxy.conf.js": {
4838-
"stateCleared": "modified",
4839-
},
48404846
"webpack/webpack.custom.js": {
48414847
"stateCleared": "modified",
48424848
},
@@ -4862,15 +4868,13 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe
48624868
"dependencies": {},
48634869
"devDependencies": {
48644870
"@angular-builders/custom-webpack": null,
4865-
"browser-sync-webpack-plugin": null,
48664871
"copy-webpack-plugin": null,
48674872
"eslint-webpack-plugin": null,
48684873
"webpack-bundle-analyzer": null,
48694874
"webpack-merge": null,
48704875
"webpack-notifier": null,
48714876
},
48724877
"overrides": {
4873-
"browser-sync": "BROWSER_SYNC_VERSION",
48744878
"webpack": "WEBPACK_VERSION",
48754879
},
48764880
},
@@ -4910,6 +4914,9 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin
49104914
"package.json": {
49114915
"stateCleared": "modified",
49124916
},
4917+
"proxy.config.mjs": {
4918+
"stateCleared": "modified",
4919+
},
49134920
"src/main/webapp/404.html": {
49144921
"stateCleared": "modified",
49154922
},
@@ -5531,9 +5538,6 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin
55315538
"webpack/logo-jhipster.png": {
55325539
"stateCleared": "modified",
55335540
},
5534-
"webpack/proxy.conf.js": {
5535-
"stateCleared": "modified",
5536-
},
55375541
"webpack/webpack.custom.js": {
55385542
"stateCleared": "modified",
55395543
},
@@ -5559,15 +5563,13 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin
55595563
"dependencies": {},
55605564
"devDependencies": {
55615565
"@angular-builders/custom-webpack": null,
5562-
"browser-sync-webpack-plugin": null,
55635566
"copy-webpack-plugin": null,
55645567
"eslint-webpack-plugin": null,
55655568
"webpack-bundle-analyzer": null,
55665569
"webpack-merge": null,
55675570
"webpack-notifier": null,
55685571
},
55695572
"overrides": {
5570-
"browser-sync": "BROWSER_SYNC_VERSION",
55715573
"webpack": "WEBPACK_VERSION",
55725574
},
55735575
},

generators/angular/generator.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default class AngularGenerator extends BaseApplicationGenerator<DefaultTa
176176
};
177177
}
178178

179-
if (application.clientRootDir) {
179+
if (application.clientRootDir && application.microfrontend) {
180180
// Overrides only works if added in root package.json
181181
this.packageJson.merge({
182182
overrides: {
@@ -324,7 +324,6 @@ export default class AngularGenerator extends BaseApplicationGenerator<DefaultTa
324324
: {},
325325
devDependencies: {
326326
'@angular-builders/custom-webpack': null,
327-
'browser-sync-webpack-plugin': null,
328327
'copy-webpack-plugin': null,
329328
'eslint-webpack-plugin': null,
330329
'webpack-bundle-analyzer': null,
@@ -333,10 +332,20 @@ export default class AngularGenerator extends BaseApplicationGenerator<DefaultTa
333332
...(enableTranslation ? { 'folder-hash': null, 'merge-jsons-webpack-plugin': null } : {}),
334333
},
335334
overrides: {
336-
'browser-sync': nodeDependencies['browser-sync'],
337335
webpack: nodeDependencies.webpack,
338336
},
339337
});
338+
339+
if (application.microfrontend) {
340+
source.mergeClientPackageJson!({
341+
devDependencies: {
342+
'browser-sync-webpack-plugin': null,
343+
},
344+
overrides: {
345+
'browser-sync': nodeDependencies['browser-sync'],
346+
},
347+
});
348+
}
340349
}
341350
},
342351
addWebsocketDependencies({ application, source }) {

generators/angular/templates/webpack/webpack.custom.js.ejs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const path = require('path');
2323
const { hashElement } = require('folder-hash');
2424
const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin');
2525
<%_ } _%>
26+
<%_ if (microfrontend) { _%>
2627
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
28+
<%_ } _%>
2729
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
2830
const WebpackNotifierPlugin = require('webpack-notifier');
2931
const CopyWebpackPlugin = require('copy-webpack-plugin');
@@ -53,6 +55,7 @@ module.exports = async (config, options, targetOptions) => {
5355
}),
5456
);
5557
}
58+
<%_ if (microfrontend) { _%>
5659
5760
// configuring proxy for back end service
5861
const tls = config.devServer?.server?.type === 'https';
@@ -98,6 +101,7 @@ module.exports = async (config, options, targetOptions) => {
98101
),
99102
);
100103
}
104+
<%_ } _%>
101105
102106
if (config.mode === 'production') {
103107
config.plugins.push(

generators/app/__snapshots__/generator.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
332332
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
333333
"devR2dbcUrl": undefined,
334334
"devServerPort": 4200,
335-
"devServerPortProxy": 9000,
335+
"devServerPortProxy": undefined,
336336
"dockerContainers": {
337337
"apache/kafka-native": "apache-kafka-native-placeholder",
338338
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
@@ -1004,7 +1004,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
10041004
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
10051005
"devR2dbcUrl": "r2dbc:postgresql://localhost:5432/jhipster",
10061006
"devServerPort": 4200,
1007-
"devServerPortProxy": 9000,
1007+
"devServerPortProxy": undefined,
10081008
"dockerContainers": {
10091009
"apache/kafka-native": "apache-kafka-native-placeholder",
10101010
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",

generators/workspaces/generator.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,18 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator {
192192
} = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json'));
193193

194194
this.packageJson.merge({
195-
devDependencies: {
196-
rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437
197-
},
198195
overrides: {
199-
'browser-sync': browserSyncVersion,
200196
webpack: webpackVersion,
201197
},
202198
});
199+
200+
if (applications.some(app => app.microfrontend)) {
201+
this.packageJson.merge({
202+
overrides: {
203+
'browser-sync': browserSyncVersion,
204+
},
205+
});
206+
}
203207
}
204208

205209
if (applications.some(app => app.backendTypeJavaAny)) {

lib/jhipster/default-application-options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export function getConfigForClientApplication(options: ApplicationDefaults = {})
130130
} else {
131131
options.devServerPort ??= 9060;
132132
}
133-
options.devServerPortProxy ??= options.clientBundler === 'webpack' ? 9000 : undefined;
133+
options.devServerPortProxy ??=
134+
options.clientBundler === 'webpack' && (clientFramework !== 'angular' || options.microfrontend) ? 9000 : undefined;
134135

135136
return options;
136137
}

0 commit comments

Comments
 (0)