Skip to content

Commit c9989cc

Browse files
authored
client: add client bundler for internal organization. (#27507)
1 parent c509a5a commit c9989cc

File tree

26 files changed

+331
-122
lines changed

26 files changed

+331
-122
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Microservice stack sample to test compilation and base microfrontend functionality.
3+
*
4+
* @example
5+
* jhipster.cjs generate-sample mf-simple.jdl --client-framework vue
6+
*/
7+
8+
application {
9+
config {
10+
applicationType gateway
11+
baseName gateway
12+
clientFramework angular
13+
creationTimestamp 1617901618886
14+
databaseType no
15+
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
16+
packageName jhipster.tech.gateway
17+
serviceDiscoveryType eureka
18+
testFrameworks [cypress]
19+
microfrontends [notification]
20+
}
21+
}
22+
23+
application {
24+
config {
25+
applicationType microservice
26+
baseName notification
27+
creationTimestamp 1617901618887
28+
clientFramework angular
29+
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
30+
packageName jhipster.tech.notification
31+
prodDatabaseType postgresql
32+
serverPort 8081
33+
serviceDiscoveryType eureka
34+
testFrameworks [cypress]
35+
}
36+
entities Notification
37+
}
38+
39+
@ChangelogDate(20210408164814)
40+
entity Notification {
41+
title String required
42+
}
43+
44+
deployment {
45+
deploymentType docker-compose,
46+
appsFolders [gateway, notification]
47+
dockerRepositoryName "hipsterslabs"
48+
monitoring no
49+
serviceDiscoveryType eureka
50+
}
51+
52+
deployment {
53+
deploymentType kubernetes,
54+
appsFolders [gateway, notification]
55+
dockerRepositoryName "hipsterslabs"
56+
monitoring no
57+
serviceDiscoveryType eureka
58+
}

.github/workflows/angular.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ jobs:
144144
run: npm install
145145
timeout-minutes: 7
146146
- name: 'TESTS: packaging'
147+
id: packaging
147148
if: steps.compare.outputs.equals != 'true'
148149
run: npm run ci:e2e:package
149150
timeout-minutes: 12
150151
- name: 'TESTS: frontend'
152+
id: frontend
151153
if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' && (matrix.sonar-analyse == 'true' || needs.build-matrix.outputs.client != 'false')
152154
run: npm run ci:frontend:test
153155
timeout-minutes: 15
@@ -160,6 +162,21 @@ jobs:
160162
if: steps.compare.outputs.equals != 'true'
161163
run: npm run ci:e2e:run --if-present
162164
timeout-minutes: 15
165+
- name: Store the application
166+
uses: actions/upload-artifact@v4
167+
if: always() && (steps.backend.outcome == 'failure' || steps.e2e.outcome == 'failure' || steps.frontend.outcome == 'failure' || steps.packaging.outcome == 'failure')
168+
with:
169+
name: app-${{ matrix.name }}
170+
include-hidden-files: true
171+
path: |
172+
${{ github.workspace }}/app/**/*
173+
!**/app/build/**
174+
!**/app/*/build/**
175+
!**/app/.gradle/**
176+
!**/app/*/.gradle/**
177+
!**/app/target/**
178+
!**/app/*/target/**
179+
!**/node_modules/**
163180
- name: 'BACKEND: Store failure logs'
164181
uses: actions/upload-artifact@v4
165182
if: always() && steps.backend.outcome == 'failure'

.github/workflows/react.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ jobs:
144144
run: npm install
145145
timeout-minutes: 7
146146
- name: 'TESTS: packaging'
147+
id: packaging
147148
if: steps.compare.outputs.equals != 'true'
148149
run: npm run ci:e2e:package
149150
timeout-minutes: 12
150151
- name: 'TESTS: frontend'
152+
id: frontend
151153
if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' && needs.build-matrix.outputs.client != 'false'
152154
run: npm run ci:frontend:test
153155
timeout-minutes: 15
@@ -160,6 +162,21 @@ jobs:
160162
if: steps.compare.outputs.equals != 'true'
161163
run: npm run ci:e2e:run --if-present
162164
timeout-minutes: 15
165+
- name: Store the application
166+
uses: actions/upload-artifact@v4
167+
if: always() && (steps.backend.outcome == 'failure' || steps.e2e.outcome == 'failure' || steps.frontend.outcome == 'failure' || steps.packaging.outcome == 'failure')
168+
with:
169+
name: app-${{ matrix.name }}
170+
include-hidden-files: true
171+
path: |
172+
${{ github.workspace }}/app/**/*
173+
!**/app/build/**
174+
!**/app/*/build/**
175+
!**/app/.gradle/**
176+
!**/app/*/.gradle/**
177+
!**/app/target/**
178+
!**/app/*/target/**
179+
!**/node_modules/**
163180
- name: 'BACKEND: Store failure logs'
164181
uses: actions/upload-artifact@v4
165182
if: always() && steps.backend.outcome == 'failure'

.github/workflows/vue.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ jobs:
144144
run: npm install
145145
timeout-minutes: 7
146146
- name: 'TESTS: packaging'
147+
id: packaging
147148
if: steps.compare.outputs.equals != 'true'
148149
run: npm run ci:e2e:package
149150
timeout-minutes: 12
150151
- name: 'TESTS: frontend'
152+
id: frontend
151153
if: steps.compare.outputs.equals != 'true' && matrix.skip-frontend-tests != 'true' && needs.build-matrix.outputs.client != 'false'
152154
run: npm run ci:frontend:test
153155
timeout-minutes: 15
@@ -160,6 +162,21 @@ jobs:
160162
if: steps.compare.outputs.equals != 'true'
161163
run: npm run ci:e2e:run --if-present
162164
timeout-minutes: 15
165+
- name: Store the application
166+
uses: actions/upload-artifact@v4
167+
if: always() && (steps.backend.outcome == 'failure' || steps.e2e.outcome == 'failure' || steps.frontend.outcome == 'failure' || steps.packaging.outcome == 'failure')
168+
with:
169+
name: app-${{ matrix.name }}
170+
include-hidden-files: true
171+
path: |
172+
${{ github.workspace }}/app/**/*
173+
!**/app/build/**
174+
!**/app/*/build/**
175+
!**/app/.gradle/**
176+
!**/app/*/.gradle/**
177+
!**/app/target/**
178+
!**/app/*/target/**
179+
!**/node_modules/**
163180
- name: 'BACKEND: Store failure logs'
164181
uses: actions/upload-artifact@v4
165182
if: always() && steps.backend.outcome == 'failure'

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ exports[`generator - app with default config should match snapshot 1`] = `
254254
"capitalizedBaseName": "Jhipster",
255255
"caret": undefined,
256256
"cjsExtension": ".cjs",
257+
"clientBundler": "webpack",
258+
"clientBundlerAny": true,
259+
"clientBundlerVite": false,
260+
"clientBundlerWebpack": true,
257261
"clientDistDir": "target/classes/static/",
258262
"clientFramework": "angular",
259263
"clientFrameworkAngular": true,
@@ -894,6 +898,10 @@ exports[`generator - app with gateway should match snapshot 1`] = `
894898
"capitalizedBaseName": "Jhipster",
895899
"caret": undefined,
896900
"cjsExtension": ".cjs",
901+
"clientBundler": "webpack",
902+
"clientBundlerAny": true,
903+
"clientBundlerVite": false,
904+
"clientBundlerWebpack": true,
897905
"clientDistDir": "target/classes/static/",
898906
"clientFramework": "angular",
899907
"clientFrameworkAngular": true,
@@ -1529,10 +1537,15 @@ exports[`generator - app with microservice should match snapshot 1`] = `
15291537
"capitalizedBaseName": "Jhipster",
15301538
"caret": undefined,
15311539
"cjsExtension": ".cjs",
1540+
"clientBundler": undefined,
1541+
"clientBundlerAny": true,
1542+
"clientBundlerVite": false,
1543+
"clientBundlerWebpack": false,
15321544
"clientDistDir": "target/classes/static/",
15331545
"clientFramework": "no",
15341546
"clientFrameworkAngular": false,
15351547
"clientFrameworkAny": false,
1548+
"clientFrameworkBuiltIn": false,
15361549
"clientFrameworkNo": true,
15371550
"clientFrameworkReact": false,
15381551
"clientFrameworkVue": false,

generators/base-core/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export default class CoreGenerator extends YeomanGenerator<JHipsterGeneratorOpti
259259
enableGradleEnterprise: false,
260260
pages: [],
261261
});
262-
return configWithDefaults;
262+
return configWithDefaults as ApplicationConfiguration;
263263
}
264264

265265
/**

generators/bootstrap-application-base/generator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export default class BootstrapApplicationBase extends BaseApplicationGenerator {
183183

184184
backendTypeSpringBoot: ({ backendType }) => backendType === 'Java',
185185
backendTypeJavaAny: ({ backendTypeSpringBoot }) => backendTypeSpringBoot,
186+
clientFrameworkBuiltIn: ({ clientFramework }) => ['angular', 'vue', 'react'].includes(clientFramework),
186187
});
187188
},
188189
userRelationship({ applicationDefaults }) {

generators/client/command.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ const command = {
6363
],
6464
scope: 'storage',
6565
},
66+
clientTheme: {
67+
cli: {
68+
type: String,
69+
hide: true,
70+
},
71+
scope: 'storage',
72+
},
73+
clientThemeVariant: {
74+
cli: {
75+
type: String,
76+
hide: true,
77+
},
78+
scope: 'storage',
79+
},
80+
clientBundler: {
81+
cli: {
82+
type: String,
83+
hide: true,
84+
},
85+
choices: ['webpack', 'vite'],
86+
scope: 'storage',
87+
},
6688
microfrontend: {
6789
description: 'Enable microfrontend support',
6890
cli: {

generators/client/generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
154154

155155
prepareForTemplates({ application }) {
156156
application.webappLoginRegExp = LOGIN_REGEX_JS;
157-
application.clientFrameworkBuiltIn = [ANGULAR, VUE, REACT].includes(application.clientFramework);
158157
},
159158

160159
addExternalResource({ application, source }) {
@@ -244,7 +243,7 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
244243
},
245244

246245
microfrontend({ application, source }) {
247-
if (!application.microfrontend || !application.clientFrameworkBuiltIn) {
246+
if (!application.microfrontend || !application.clientFrameworkBuiltIn || !application.clientBundlerWebpack) {
248247
return;
249248
}
250249
if (application.clientFrameworkAngular) {

generators/client/templates/webpack/webpack.microfrontend.js.jhi.ejs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ _&>
2828

2929
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
3030
<&- fragments.importsSection() &>
31+
<%_ if (!clientFrameworkVue) { _%>
3132
const packageJson = require('../package.json');
3233
// Microfrontend api, should match across gateway and microservices.
3334
const apiVersion = '0.0.1';
@@ -41,6 +42,7 @@ const shareDependencies = ({ skipList = [] } = {}) =>
4142
.filter(([dependency]) => !skipList.includes(dependency))
4243
.map(([dependency, version]) => [dependency, { ...sharedDefaults, version, requiredVersion: version }]),
4344
);
45+
<%_ } _%>
4446

4547
module.exports = () => {
4648
return {
@@ -51,14 +53,20 @@ module.exports = () => {
5153
},
5254
<&- fragments.configSection() &>
5355
plugins: [
54-
new ModuleFederationPlugin({
55-
<%_ if (applicationTypeMicroservice) { _%>
56+
new ModuleFederationPlugin(
57+
<%_ if (clientFrameworkVue) { _%>
58+
require('../module-federation.config.cjs'),
59+
<%_ } else { -%>
60+
{
61+
<%_ if (applicationTypeMicroservice) { _%>
5662
name: '<%= lowercaseBaseName %>',
5763
filename: 'remoteEntry.js',
58-
<%_ } _%>
64+
<%_ } _%>
5965
shareScope: 'default',
6066
<&- fragments.moduleFederationSection() &>
61-
}),
67+
}
68+
<%_ } -%>
69+
),
6270
<&- fragments.pluginsSection() &>
6371
],
6472
output: {

generators/gradle/generators/node-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,29 @@ task webapp_test(type: NpmTask) {
6666
inputs.files("tsconfig.json", "tsconfig.app.json")
6767
.withPropertyName("tsconfig")
6868
.withPathSensitivity(PathSensitivity.RELATIVE)
69-
<%_ if (microfrontend) { _%>
7069
71-
def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>")
72-
webpackDevFiles.exclude("webpack.prod.js")
73-
inputs.files(webpackDevFiles)
74-
.withPropertyName("webpack-dir")
70+
inputs.files(".postcssrc")
71+
.withPropertyName("postcssrc")
7572
.withPathSensitivity(PathSensitivity.RELATIVE)
76-
<%_ } else { _%>
73+
<%_ } _%>
74+
<%_ if (clientBundlerVite && clientFrameworkBuiltIn) { _%>
7775
78-
inputs.files("vite.config.ts")
76+
inputs.files("vite.config.mts")
7977
.withPropertyName("vite")
8078
.withPathSensitivity(PathSensitivity.RELATIVE)
79+
<%_ } _%>
80+
<%_ if (clientFrameworkVue) { _%>
81+
<%_ if (clientBundlerWebpack) { _%>
82+
def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>")
83+
webpackDevFiles.exclude("webpack.prod.js")
84+
inputs.files(webpackDevFiles)
85+
.withPropertyName("webpack-dir")
8186
<%_ } _%>
82-
83-
inputs.files(".postcssrc")
84-
.withPropertyName("postcssrc")
87+
<%_ if (microfrontend) { _%>
88+
inputs.files("module-federation.config.cjs")
89+
.withPropertyName("module-federation")
8590
.withPathSensitivity(PathSensitivity.RELATIVE)
91+
<%_ } _%>
8692
<%_ } _%>
8793
8894
outputs.dir("build/test-results/jest/")

generators/java/generators/bootstrap/command.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ const command = {
5050
scope: 'storage',
5151
description: 'The package name for the generated application',
5252
},
53+
packageFolder: {
54+
cli: {
55+
type: String,
56+
hide: true,
57+
},
58+
scope: 'storage',
59+
},
5360
},
5461
import: [],
5562
} as const satisfies JHipsterCommandDefinition;

generators/maven/generators/frontend-plugin/generator.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export default class FrontendPluginGenerator extends BaseApplicationGenerator {
4040
clientFrameworkAngular,
4141
clientFrameworkReact,
4242
clientFrameworkVue,
43+
clientFrameworkBuiltIn,
44+
clientBundlerVite,
45+
clientBundlerWebpack,
4346
microfrontend,
4447
srcMainWebapp,
4548
} = application;
@@ -52,15 +55,20 @@ export default class FrontendPluginGenerator extends BaseApplicationGenerator {
5255
'tsconfig.json',
5356
];
5457
if (clientFrameworkAngular) {
55-
checksumIncludedFiles.push('tsconfig.app.json', 'webpack/*.*');
58+
checksumIncludedFiles.push('tsconfig.app.json');
5659
} else if (clientFrameworkReact) {
57-
checksumIncludedFiles.push('.postcss.config.js', 'webpack/*.*');
60+
checksumIncludedFiles.push('.postcss.config.js');
5861
} else if (clientFrameworkVue) {
5962
checksumIncludedFiles.push('.postcssrc.js', 'tsconfig.app.json');
6063
if (microfrontend) {
64+
checksumIncludedFiles.push('module-federation.config.cjs');
65+
}
66+
}
67+
if (clientFrameworkBuiltIn) {
68+
if (clientBundlerWebpack) {
6169
checksumIncludedFiles.push('webpack/*.*');
62-
} else {
63-
checksumIncludedFiles.push('vite.config.ts');
70+
} else if (clientBundlerVite) {
71+
checksumIncludedFiles.push('vite.config.mts');
6472
}
6573
}
6674
source.addMavenDefinition!({

0 commit comments

Comments
 (0)