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

Vite mf #27493

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Vite mf #27493

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .blueprint/generate-sample/templates/samples/mf-simple.jdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Microservice stack sample to test compilation and base microfrontend functionality.
*
* @example
* jhipster.cjs generate-sample mf-simple.jdl --client-framework vue
*/

application {
config {
applicationType gateway
baseName gateway
clientFramework angular
creationTimestamp 1617901618886
databaseType no
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
packageName jhipster.tech.gateway
serviceDiscoveryType eureka
testFrameworks [cypress]
microfrontends [notification]
}
}

application {
config {
applicationType microservice
baseName notification
creationTimestamp 1617901618887
clientFramework angular
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
packageName jhipster.tech.notification
prodDatabaseType postgresql
serverPort 8081
serviceDiscoveryType eureka
testFrameworks [cypress]
}
entities Notification
}

@ChangelogDate(20210408164814)
entity Notification {
title String required
}

deployment {
deploymentType docker-compose,
appsFolders [gateway, notification]
dockerRepositoryName "hipsterslabs"
monitoring no
serviceDiscoveryType eureka
}

deployment {
deploymentType kubernetes,
appsFolders [gateway, notification]
dockerRepositoryName "hipsterslabs"
monitoring no
serviceDiscoveryType eureka
}
13 changes: 13 additions & 0 deletions .github/workflows/vue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ jobs:
if: steps.compare.outputs.equals != 'true'
run: npm run ci:e2e:run --if-present
timeout-minutes: 15
- name: Store the application
uses: actions/upload-artifact@v4
if: always() && steps.backend.outcome == 'failure'
with:
name: app-${{ matrix.name }}
include-hidden-files: true
path: |
${{ github.workspace }}/app/**/*
!**/app/build/**
!**/app/target/**
!**/app/*/build/**
!**/app/*/target/**
!**/node_modules/**
- name: 'BACKEND: Store failure logs'
uses: actions/upload-artifact@v4
if: always() && steps.backend.outcome == 'failure'
Expand Down
2 changes: 1 addition & 1 deletion generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default class CoreGenerator extends YeomanGenerator<JHipsterGeneratorOpti
enableGradleEnterprise: false,
pages: [],
});
return configWithDefaults;
return configWithDefaults as ApplicationConfiguration;
}

/**
Expand Down
22 changes: 22 additions & 0 deletions generators/client/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ const command = {
],
scope: 'storage',
},
clientTheme: {
cli: {
type: String,
hide: true,
},
scope: 'storage',
},
clientThemeVariant: {
cli: {
type: String,
hide: true,
},
scope: 'storage',
},
clientBundler: {
cli: {
type: String,
hide: true,
},
choices: ['webpack', 'vite'],
scope: 'storage',
},
microfrontend: {
description: 'Enable microfrontend support',
cli: {
Expand Down
2 changes: 1 addition & 1 deletion generators/client/files-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const files = {
templates: ['README.md.jhi.client', '.prettierignore.jhi.client'],
},
clientRootTemplatesBlock({
condition: generator => generator.microfrontend && (generator.clientFrameworkVue || generator.clientFrameworkReact),
condition: generator => generator.microfrontend && generator.clientFrameworkReact,
templates: ['webpack/webpack.microfrontend.js.jhi'],
}),
{
Expand Down
4 changes: 1 addition & 3 deletions generators/client/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
source.addWebpackConfig({
config: `${conditional}require('./webpack.microfrontend')(config, options, targetOptions)`,
});
} else if (application.clientFrameworkVue || application.clientFrameworkReact) {
} else if (application.clientFrameworkReact) {
source.addWebpackConfig({ config: "require('./webpack.microfrontend')({ serve: options.env.WEBPACK_SERVE })" });
} else {
throw new Error(`Client framework ${application.clientFramework} doesn't support microfrontends`);
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,21 @@ task webapp_test(type: NpmTask) {
inputs.files("tsconfig.json", "tsconfig.app.json")
.withPropertyName("tsconfig")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ if (microfrontend) { _%>

def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>")
webpackDevFiles.exclude("webpack.prod.js")
inputs.files(webpackDevFiles)
.withPropertyName("webpack-dir")
inputs.files(".postcssrc")
.withPropertyName("postcssrc")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } else { _%>
<%_ } _%>
<%_ if (clientBundlerVite && clientFrameworkBuiltIn) { _%>

inputs.files("vite.config.ts")
inputs.files("vite.config.mts")
.withPropertyName("vite")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>
<%_ } _%>
<%_ if (microfrontend && clientFrameworkBuiltIn && clientFrameworkVue) { _%>

inputs.files(".postcssrc")
.withPropertyName("postcssrc")
inputs.files("module-federation.config.mts")
.withPropertyName("module-federation")
.withPathSensitivity(PathSensitivity.RELATIVE)
<%_ } _%>

Expand Down
7 changes: 7 additions & 0 deletions generators/java/generators/bootstrap/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const command = {
scope: 'storage',
description: 'The package name for the generated application',
},
packageFolder: {
cli: {
type: String,
hide: true,
},
scope: 'storage',
},
},
import: [],
} as const satisfies JHipsterCommandDefinition;
Expand Down
11 changes: 8 additions & 3 deletions generators/maven/generators/frontend-plugin/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default class FrontendPluginGenerator extends BaseApplicationGenerator {
clientFrameworkAngular,
clientFrameworkReact,
clientFrameworkVue,
clientFrameworkBuiltIn,
clientBundlerVite,
microfrontend,
srcMainWebapp,
} = application;
Expand All @@ -57,10 +59,13 @@ export default class FrontendPluginGenerator extends BaseApplicationGenerator {
checksumIncludedFiles.push('.postcss.config.js', 'webpack/*.*');
} else if (clientFrameworkVue) {
checksumIncludedFiles.push('.postcssrc.js', 'tsconfig.app.json');
}
if (clientFrameworkBuiltIn && clientFrameworkVue) {
if (clientBundlerVite) {
checksumIncludedFiles.push('vite.config.mts');
}
if (microfrontend) {
checksumIncludedFiles.push('webpack/*.*');
} else {
checksumIncludedFiles.push('vite.config.ts');
checksumIncludedFiles.push('module-federation.config.mts');
}
}
source.addMavenDefinition!({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,13 @@ public class SecurityConfiguration {
<%_ if (!skipClient) { _%>
.requestMatchers(mvc.pattern("/index.html"), mvc.pattern("/*.js"), mvc.pattern("/*.txt"), mvc.pattern("/*.json"), mvc.pattern("/*.map"), mvc.pattern("/*.css")).permitAll()
.requestMatchers(mvc.pattern("/*.ico"), mvc.pattern("/*.png"), mvc.pattern("/*.svg"), mvc.pattern("/*.webapp")).permitAll()
<%_ if (clientFrameworkVue) { _%>
<%_ if (clientBundlerVite) { _%>
.requestMatchers(mvc.pattern("/assets/**")).permitAll()
<%_ if (microfrontend) { _%>
.requestMatchers(mvc.pattern("/app/**")).permitAll()
.requestMatchers(mvc.pattern("/i18n/**")).permitAll()
<%_ } _%>
<%_ } else { _%>
.requestMatchers(mvc.pattern("/app/**")).permitAll()
.requestMatchers(mvc.pattern("/i18n/**")).permitAll()
<%_ } _%>
.requestMatchers(mvc.pattern("/content/**")).permitAll()
<%_ } _%>
.requestMatchers(mvc.pattern("/swagger-ui/**")).permitAll()
<%_ } _%>
<%_ if (authenticationTypeJwt) { _%>
Expand All @@ -227,7 +223,11 @@ public class SecurityConfiguration {
<%_ if (applicationTypeGateway) { _%>
<%_ if (microfrontend) { _%>
// microfrontend resources are loaded by webpack without authentication, they need to be public
<%_ if (clientBundlerVite) { _%>
.requestMatchers(mvc.pattern("/services/*/assets/**")).permitAll()
<%_ } _%>
.requestMatchers(mvc.pattern("/services/*/*.js")).permitAll()
.requestMatchers(mvc.pattern("/services/*/content/*.js")).permitAll()
.requestMatchers(mvc.pattern("/services/*/*.txt")).permitAll()
.requestMatchers(mvc.pattern("/services/*/*.json")).permitAll()
.requestMatchers(mvc.pattern("/services/*/*.js.map")).permitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,16 @@ public class SecurityConfiguration {
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.securityMatcher(new NegatedServerWebExchangeMatcher(new OrServerWebExchangeMatcher(
<%_ if (clientFrameworkVue) { _%>
pathMatchers(
<%_ if (clientBundlerVite) { _%>
"/assets/**",
<%_ if (microfrontend) { _%>
<%_ } else { _%>
"/app/**",
"/i18n/**",
"/content/**",
<%_ } _%>
<%_ } _%>
"/swagger-ui/**"
)
<%_ } else { _%>
pathMatchers("/app/**", "/i18n/**", "/content/**", "/swagger-ui/**")
<%_ } _%>
)))
<%_ if (!applicationTypeMicroservice) { _%>
.cors(withDefaults())
Expand Down Expand Up @@ -286,10 +283,16 @@ public class SecurityConfiguration {
<%_ if (applicationTypeGateway) { _%>
<%_ if (microfrontend) { _%>
// microfrontend resources are loaded by webpack without authentication, they need to be public
<%_ if (clientBundlerVite) { _%>
.pathMatchers("/services/*/assets/**").permitAll()
.pathMatchers("/services/*/*.js").permitAll()
<%_ } else { _%>
.pathMatchers("/services/*/*.js").permitAll()
.pathMatchers("/services/*/content/*.js").permitAll()
.pathMatchers("/services/*/*.txt").permitAll()
.pathMatchers("/services/*/*.json").permitAll()
.pathMatchers("/services/*/*.js.map").permitAll()
<%_ } _%>
<%_ } _%>
.pathMatchers("/services/*/management/health/readiness").permitAll()
.pathMatchers("/services/*/v3/api-docs").hasAuthority(AuthoritiesConstants.ADMIN)
Expand Down
43 changes: 5 additions & 38 deletions generators/vue/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1092,9 +1092,6 @@ exports[`generator - vue microservice-jwt-skipUserManagement(false)-withAdminUi(
"clientRoot/src/main/webapp/app/entities/entities-menu.component.ts": {
"stateCleared": "modified",
},
"clientRoot/src/main/webapp/app/entities/entities-menu.spec.ts": {
"stateCleared": "modified",
},
"clientRoot/src/main/webapp/app/entities/entities-menu.vue": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1395,9 +1392,6 @@ exports[`generator - vue microservice-jwt-skipUserManagement(false)-withAdminUi(
"clientRoot/src/main/webapp/manifest.webapp": {
"stateCleared": "modified",
},
"clientRoot/src/main/webapp/microfrontends/entities-menu-test.vue": {
"stateCleared": "modified",
},
"clientRoot/src/main/webapp/microfrontends/entities-menu.component-test.ts": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1431,22 +1425,10 @@ exports[`generator - vue microservice-jwt-skipUserManagement(false)-withAdminUi(
"clientRoot/vitest.config.mts": {
"stateCleared": "modified",
},
"clientRoot/webpack/config.js": {
"stateCleared": "modified",
},
"clientRoot/webpack/vue.utils.js": {
"stateCleared": "modified",
},
"clientRoot/webpack/webpack.common.js": {
"stateCleared": "modified",
},
"clientRoot/webpack/webpack.dev.js": {
"module-federation.config.mts": {
"stateCleared": "modified",
},
"clientRoot/webpack/webpack.microfrontend.js": {
"stateCleared": "modified",
},
"clientRoot/webpack/webpack.prod.js": {
"package.json": {
"stateCleared": "modified",
},
}
Expand Down Expand Up @@ -1475,6 +1457,9 @@ exports[`generator - vue microservice-oauth2-withAdminUi(true)-skipJhipsterDepen
"eslint.config.mjs": {
"stateCleared": "modified",
},
"module-federation.config.mts": {
"stateCleared": "modified",
},
"package.json": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1907,24 +1892,6 @@ exports[`generator - vue microservice-oauth2-withAdminUi(true)-skipJhipsterDepen
"vitest.config.mts": {
"stateCleared": "modified",
},
"webpack/config.js": {
"stateCleared": "modified",
},
"webpack/vue.utils.js": {
"stateCleared": "modified",
},
"webpack/webpack.common.js": {
"stateCleared": "modified",
},
"webpack/webpack.dev.js": {
"stateCleared": "modified",
},
"webpack/webpack.microfrontend.js": {
"stateCleared": "modified",
},
"webpack/webpack.prod.js": {
"stateCleared": "modified",
},
}
`;

Expand Down
Loading
Loading