Skip to content

Commit 610a476

Browse files
committed
angular: drop browser-sync-webpack-plugin support for non microfrontends
1 parent 1d9dca7 commit 610a476

File tree

7 files changed

+49
-30
lines changed

7 files changed

+49
-30
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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
},
@@ -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
},
@@ -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
`;
@@ -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
`;
@@ -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
},
@@ -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
},
@@ -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: 5 additions & 1 deletion
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');
@@ -32,7 +34,7 @@ const ESLintPlugin = require('eslint-webpack-plugin');
3234
const environment = require('./environment');
3335
const proxyConfig = require('./proxy.conf');
3436

35-
module.exports = async (config, options, targetOptions) => {
37+
module.exports = async (config, _options, targetOptions) => {
3638
<%_ if (enableTranslation) { _%>
3739
const languagesHash = await hashElement(path.resolve(__dirname, '<%= this.relativeDir(clientRootDir + 'webpack/', clientSrcDir) %>i18n'), {
3840
algo: 'md5',
@@ -60,6 +62,7 @@ module.exports = async (config, options, targetOptions) => {
6062
if (config.devServer) {
6163
config.devServer.proxy = proxyConfig({ tls });
6264
}
65+
<%_ if (microfrontend) { _%>
6366
6467
if (targetOptions.target === 'serve' || config.watch) {
6568
config.plugins.push(
@@ -102,6 +105,7 @@ module.exports = async (config, options, targetOptions) => {
102105
),
103106
);
104107
}
108+
<%_ } _%>
105109

106110
if (config.mode === 'production') {
107111
config.plugins.push(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
329329
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
330330
"devR2dbcUrl": undefined,
331331
"devServerPort": 4200,
332-
"devServerPortProxy": 9000,
332+
"devServerPortProxy": undefined,
333333
"dockerContainers": {
334334
"apache/kafka-native": "apache-kafka-native-placeholder",
335335
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
@@ -998,7 +998,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
998998
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
999999
"devR2dbcUrl": "r2dbc:postgresql://localhost:5432/jhipster",
10001000
"devServerPort": 4200,
1001-
"devServerPortProxy": 9000,
1001+
"devServerPortProxy": undefined,
10021002
"dockerContainers": {
10031003
"apache/kafka-native": "apache-kafka-native-placeholder",
10041004
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",

generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,15 +3536,15 @@ data:
35363536
"redirectUris": [
35373537
"http://jhgate.default.example.com/*",
35383538
"https://jhgate.default.example.com/*", "http://localhost:8080/*",
3539-
"https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*",
3539+
"https://localhost:8080/*","http://localhost:4200/*",
35403540
"http://localhost:8100/*",
35413541
"http://127.0.0.1:8761/*",
35423542
"dev.localhost.ionic:*"
35433543
],
35443544
"webOrigins": [
35453545
"http://jhgate.default.example.com",
35463546
"https://jhgate.default.example.com", "http://localhost:8080",
3547-
"https://localhost:8080","http://localhost:4200", "http://localhost:9000",
3547+
"https://localhost:8080","http://localhost:4200",
35483548
"http://localhost:8100",
35493549
"http://127.0.0.1:8761"
35503550
],
@@ -6969,15 +6969,15 @@ data:
69696969
"redirectUris": [
69706970
"http://jhgate.default.example.com/*",
69716971
"https://jhgate.default.example.com/*", "http://localhost:8080/*",
6972-
"https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*",
6972+
"https://localhost:8080/*","http://localhost:4200/*",
69736973
"http://localhost:8100/*",
69746974
"http://127.0.0.1:8761/*",
69756975
"dev.localhost.ionic:*"
69766976
],
69776977
"webOrigins": [
69786978
"http://jhgate.default.example.com",
69796979
"https://jhgate.default.example.com", "http://localhost:8080",
6980-
"https://localhost:8080","http://localhost:4200", "http://localhost:9000",
6980+
"https://localhost:8080","http://localhost:4200",
69816981
"http://localhost:8100",
69826982
"http://127.0.0.1:8761"
69836983
],

generators/workspaces/generator.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,22 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator {
187187

188188
if (applications.some(app => app.clientFrameworkAngular)) {
189189
const {
190-
dependencies: { rxjs },
191190
devDependencies: { webpack: webpackVersion, 'browser-sync': browserSyncVersion },
192191
} = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json'));
193192

194193
this.packageJson.merge({
195-
devDependencies: {
196-
rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437
197-
},
198194
overrides: {
199-
'browser-sync': browserSyncVersion,
200195
webpack: webpackVersion,
201196
},
202197
});
198+
199+
if (applications.some(app => app.microfrontend)) {
200+
this.packageJson.merge({
201+
overrides: {
202+
'browser-sync': browserSyncVersion,
203+
},
204+
});
205+
}
203206
}
204207

205208
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)