From 4baaaf37695128ee26aec538a15d94e5ac1a7df2 Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Sun, 7 Sep 2025 05:35:57 +0530 Subject: [PATCH 1/6] Fix #30509 Add type:module & rename .mjs to .js in templates --- .../{define-esbuild.mjs.ejs => define-esbuild.js.ejs} | 0 .../build-plugins/{i18n-esbuild.mjs.ejs => i18n-esbuild.js.ejs} | 0 generators/angular/templates/package.json.ejs | 1 + .../templates/{proxy.config.mjs.ejs => proxy.config.js.ejs} | 0 .../.blueprint/cli/{commands.mjs.ejs => commands.js.ejs} | 0 .../generate-sample/{command.mjs.ejs => command.js.ejs} | 0 .../generate-sample/{generator.mjs.ejs => generator.js.ejs} | 0 .../.blueprint/generate-sample/{index.mjs.ejs => index.js.ejs} | 0 .../github-build-matrix/{command.mjs.ejs => command.js.ejs} | 0 .../github-build-matrix/{generator.mjs.ejs => generator.js.ejs} | 0 .../{generator.spec.mjs.ejs => generator.spec.js.ejs} | 0 .../github-build-matrix/{index.mjs.ejs => index.js.ejs} | 0 .../generators/generator/{command.mjs.ejs => command.js.ejs} | 0 .../generator/{generator.mjs.jhi.ejs => generator.js.jhi.ejs} | 0 .../generator/{generator.spec.mjs.ejs => generator.spec.js.ejs} | 0 .../generators/generator/{index.mjs.ejs => index.js.ejs} | 0 generators/react/templates/package.json.ejs | 1 + generators/vue/templates/package.json.ejs | 1 + 18 files changed, 3 insertions(+) rename generators/angular/templates/build-plugins/{define-esbuild.mjs.ejs => define-esbuild.js.ejs} (100%) rename generators/angular/templates/build-plugins/{i18n-esbuild.mjs.ejs => i18n-esbuild.js.ejs} (100%) rename generators/angular/templates/{proxy.config.mjs.ejs => proxy.config.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/cli/{commands.mjs.ejs => commands.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/generate-sample/{command.mjs.ejs => command.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/generate-sample/{generator.mjs.ejs => generator.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/generate-sample/{index.mjs.ejs => index.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/github-build-matrix/{command.mjs.ejs => command.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/github-build-matrix/{generator.mjs.ejs => generator.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/github-build-matrix/{generator.spec.mjs.ejs => generator.spec.js.ejs} (100%) rename generators/generate-blueprint/templates/.blueprint/github-build-matrix/{index.mjs.ejs => index.js.ejs} (100%) rename generators/generate-blueprint/templates/generators/generator/{command.mjs.ejs => command.js.ejs} (100%) rename generators/generate-blueprint/templates/generators/generator/{generator.mjs.jhi.ejs => generator.js.jhi.ejs} (100%) rename generators/generate-blueprint/templates/generators/generator/{generator.spec.mjs.ejs => generator.spec.js.ejs} (100%) rename generators/generate-blueprint/templates/generators/generator/{index.mjs.ejs => index.js.ejs} (100%) diff --git a/generators/angular/templates/build-plugins/define-esbuild.mjs.ejs b/generators/angular/templates/build-plugins/define-esbuild.js.ejs similarity index 100% rename from generators/angular/templates/build-plugins/define-esbuild.mjs.ejs rename to generators/angular/templates/build-plugins/define-esbuild.js.ejs diff --git a/generators/angular/templates/build-plugins/i18n-esbuild.mjs.ejs b/generators/angular/templates/build-plugins/i18n-esbuild.js.ejs similarity index 100% rename from generators/angular/templates/build-plugins/i18n-esbuild.mjs.ejs rename to generators/angular/templates/build-plugins/i18n-esbuild.js.ejs diff --git a/generators/angular/templates/package.json.ejs b/generators/angular/templates/package.json.ejs index a32d4f0916f8..731df04713c5 100644 --- a/generators/angular/templates/package.json.ejs +++ b/generators/angular/templates/package.json.ejs @@ -21,6 +21,7 @@ "name": "<%= dasherizedBaseName %>", "version": "0.0.1-SNAPSHOT", "description": "<%= projectDescription %>", + "type": "module", "private": true, "license": "UNLICENSED", "cacheDirectories": [ diff --git a/generators/angular/templates/proxy.config.mjs.ejs b/generators/angular/templates/proxy.config.js.ejs similarity index 100% rename from generators/angular/templates/proxy.config.mjs.ejs rename to generators/angular/templates/proxy.config.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/cli/commands.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/cli/commands.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/cli/commands.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/cli/commands.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/generate-sample/command.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/generate-sample/command.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/generate-sample/command.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/generate-sample/command.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/generate-sample/generator.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/generate-sample/generator.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/generate-sample/generator.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/generate-sample/generator.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/generate-sample/index.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/generate-sample/index.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/generate-sample/index.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/generate-sample/index.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/github-build-matrix/command.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/github-build-matrix/command.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/github-build-matrix/command.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/github-build-matrix/command.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.spec.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.spec.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.spec.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/github-build-matrix/generator.spec.js.ejs diff --git a/generators/generate-blueprint/templates/.blueprint/github-build-matrix/index.mjs.ejs b/generators/generate-blueprint/templates/.blueprint/github-build-matrix/index.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/.blueprint/github-build-matrix/index.mjs.ejs rename to generators/generate-blueprint/templates/.blueprint/github-build-matrix/index.js.ejs diff --git a/generators/generate-blueprint/templates/generators/generator/command.mjs.ejs b/generators/generate-blueprint/templates/generators/generator/command.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/generators/generator/command.mjs.ejs rename to generators/generate-blueprint/templates/generators/generator/command.js.ejs diff --git a/generators/generate-blueprint/templates/generators/generator/generator.mjs.jhi.ejs b/generators/generate-blueprint/templates/generators/generator/generator.js.jhi.ejs similarity index 100% rename from generators/generate-blueprint/templates/generators/generator/generator.mjs.jhi.ejs rename to generators/generate-blueprint/templates/generators/generator/generator.js.jhi.ejs diff --git a/generators/generate-blueprint/templates/generators/generator/generator.spec.mjs.ejs b/generators/generate-blueprint/templates/generators/generator/generator.spec.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/generators/generator/generator.spec.mjs.ejs rename to generators/generate-blueprint/templates/generators/generator/generator.spec.js.ejs diff --git a/generators/generate-blueprint/templates/generators/generator/index.mjs.ejs b/generators/generate-blueprint/templates/generators/generator/index.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/generators/generator/index.mjs.ejs rename to generators/generate-blueprint/templates/generators/generator/index.js.ejs diff --git a/generators/react/templates/package.json.ejs b/generators/react/templates/package.json.ejs index 7b22c1744ee0..51c5b8a7da94 100644 --- a/generators/react/templates/package.json.ejs +++ b/generators/react/templates/package.json.ejs @@ -20,6 +20,7 @@ "name": "<%= dasherizedBaseName %>", "version": "0.0.1-SNAPSHOT", "description": "<%= projectDescription %>", + "type": "module", "private": true, "license": "UNLICENSED", "cacheDirectories": [ diff --git a/generators/vue/templates/package.json.ejs b/generators/vue/templates/package.json.ejs index 3eda6904ba6d..77b46ca6e91f 100644 --- a/generators/vue/templates/package.json.ejs +++ b/generators/vue/templates/package.json.ejs @@ -20,6 +20,7 @@ "name": "<%= dasherizedBaseName %>", "version": "0.0.0", "description": "<%= projectDescription %>", + "type": "module", "private": true, "license": "UNLICENSED", "cacheDirectories": [ From 978bf6293a60a32fb1ed105032281e82095cc579 Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Tue, 9 Sep 2025 04:24:07 +0530 Subject: [PATCH 2/6] Fix #30509 update templates for Angular, React, and Vue --- generators/angular/resources/package.json | 1 + generators/angular/templates/jest.conf.js.ejs | 11 ++- .../templates/webpack/environment.js.ejs | 2 +- .../templates/webpack/proxy.conf.js.ejs | 2 +- .../templates/webpack/webpack.custom.js.ejs | 27 +++--- .../webpack/webpack.microfrontend.js.ejs | 6 +- .../templates/cli/cli-customizations.cjs.ejs | 2 +- .../templates/cli/cli.cjs.ejs | 9 +- .../templates/cli/commands.cjs.ejs | 2 +- generators/react/resources/package.json | 1 + generators/react/templates/jest.conf.js.ejs | 83 ++++++++++--------- .../react/templates/postcss.config.js.ejs | 4 +- .../templates/webpack/environment.js.ejs | 4 +- .../react/templates/webpack/utils.js.ejs | 16 ++-- .../templates/webpack/webpack.common.js.ejs | 6 +- .../templates/webpack/webpack.dev.js.ejs | 14 +++- .../templates/webpack/webpack.prod.js.ejs | 3 + generators/vue/resources/package.json | 1 + generators/vue/templates/.postcssrc.js.ejs | 2 +- ...js.ejs => module-federation.config.js.ejs} | 10 ++- .../vue/templates/webpack/config.js.ejs | 11 ++- .../vue/templates/webpack/vue.utils.js.ejs | 5 +- .../templates/webpack/webpack.common.js.ejs | 15 +++- .../vue/templates/webpack/webpack.dev.js.ejs | 10 ++- .../vue/templates/webpack/webpack.prod.js.ejs | 13 ++- 25 files changed, 171 insertions(+), 89 deletions(-) rename generators/vue/templates/{module-federation.config.cjs.ejs => module-federation.config.js.ejs} (88%) diff --git a/generators/angular/resources/package.json b/generators/angular/resources/package.json index 81b47213749e..3b5d46955350 100644 --- a/generators/angular/resources/package.json +++ b/generators/angular/resources/package.json @@ -1,4 +1,5 @@ { + "type": "module", "dependencies": { "@angular/common": "20.2.4", "@fortawesome/angular-fontawesome": "3.0.0", diff --git a/generators/angular/templates/jest.conf.js.ejs b/generators/angular/templates/jest.conf.js.ejs index 00cc28b83065..2bd1f2a2f2e7 100644 --- a/generators/angular/templates/jest.conf.js.ejs +++ b/generators/angular/templates/jest.conf.js.ejs @@ -16,13 +16,18 @@ See the License for the specific language governing permissions and limitations under the License. -%> -const { pathsToModuleNameMapper } = require('ts-jest'); +import { pathsToModuleNameMapper } from 'ts-jest'; +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); +const tsconfig = require('./tsconfig.json'); const { compilerOptions: { paths = {}, baseUrl = './' }, -} = require('./tsconfig.json'); +} = tsconfig; + -module.exports = { +export default { transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$|dayjs/esm<% if (applicationTypeGateway && microfrontend) { %>|@angular-architects/module-federation-runtime<% } %>)'], resolver: 'jest-preset-angular/build/resolvers/ng-jest-resolver.js', globals: { diff --git a/generators/angular/templates/webpack/environment.js.ejs b/generators/angular/templates/webpack/environment.js.ejs index 953d480f8a6e..02cedbd8e080 100644 --- a/generators/angular/templates/webpack/environment.js.ejs +++ b/generators/angular/templates/webpack/environment.js.ejs @@ -1,4 +1,4 @@ -module.exports = { +export default { I18N_HASH: 'generated_hash', SERVER_API_URL: '', __VERSION__: process.env.APP_VERSION || 'DEV', diff --git a/generators/angular/templates/webpack/proxy.conf.js.ejs b/generators/angular/templates/webpack/proxy.conf.js.ejs index ab8536cd2955..09a35985523c 100644 --- a/generators/angular/templates/webpack/proxy.conf.js.ejs +++ b/generators/angular/templates/webpack/proxy.conf.js.ejs @@ -47,4 +47,4 @@ function setupProxy({ tls }) { ]; } -module.exports = setupProxy; +export default setupProxy; \ No newline at end of file diff --git a/generators/angular/templates/webpack/webpack.custom.js.ejs b/generators/angular/templates/webpack/webpack.custom.js.ejs index cb169312bf21..aa05bfe9c160 100644 --- a/generators/angular/templates/webpack/webpack.custom.js.ejs +++ b/generators/angular/templates/webpack/webpack.custom.js.ejs @@ -16,22 +16,27 @@ See the License for the specific language governing permissions and limitations under the License. -%> -const webpack = require('webpack'); -const { merge } = require('webpack-merge'); -const path = require('path'); +import webpack from 'webpack'; +import { merge } from 'webpack-merge'; +import path, { dirname } from 'path'; +import { fileURLToPath } from 'url'; <%_ if (enableTranslation) { _%> -const { hashElement } = require('folder-hash'); -const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin'); +import { hashElement } from 'folder-hash'; +import MergeJsonWebpackPlugin from 'merge-jsons-webpack-plugin'; <%_ } _%> -const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +import BrowserSyncPlugin from 'browser-sync-webpack-plugin'; +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; +import CopyWebpackPlugin from 'copy-webpack-plugin'; +import environment from './environment.js'; +import proxyConfig from './proxy.conf.js'; const WebpackNotifierPlugin = require('webpack-notifier'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const environment = require('./environment'); -const proxyConfig = require('./proxy.conf'); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); -module.exports = async (config, options, targetOptions) => { +export default async (config, options, targetOptions) => { <%_ if (enableTranslation) { _%> const languagesHash = await hashElement(path.resolve(__dirname, '<%= this.relativeDir(clientRootDir + 'webpack/', clientSrcDir) %>i18n'), { algo: 'md5', diff --git a/generators/angular/templates/webpack/webpack.microfrontend.js.ejs b/generators/angular/templates/webpack/webpack.microfrontend.js.ejs index 4f4ab08f21ae..5229a4304d8e 100644 --- a/generators/angular/templates/webpack/webpack.microfrontend.js.ejs +++ b/generators/angular/templates/webpack/webpack.microfrontend.js.ejs @@ -16,8 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. -%> -const { withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack'); -const packageJson = require('../package.json'); +import { withModuleFederationPlugin } from '@angular-architects/module-federation/webpack'; +import packageJson from '../package.json' assert { type: 'json' }; // Microfrontend api, should match across gateway and microservices. const apiVersion = '0.0.1'; @@ -39,7 +39,7 @@ sharedDependencies = { }; // eslint-disable-next-line no-unused-vars -module.exports = (config, options, targetOptions) => { +export default (config, options, targetOptions) => { return withModuleFederationPlugin({ name: '<%= lowercaseBaseName %>', <%_ if (applicationTypeMicroservice) { _%> diff --git a/generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs b/generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs index 20a8a77ad8b9..6db49670e0d9 100644 --- a/generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs +++ b/generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs @@ -1,2 +1,2 @@ // This file will not be overwritten by generate-blueprint -module.exports = {}; +export default {}; diff --git a/generators/generate-blueprint/templates/cli/cli.cjs.ejs b/generators/generate-blueprint/templates/cli/cli.cjs.ejs index 9f06eee6e866..264f1401422b 100755 --- a/generators/generate-blueprint/templates/cli/cli.cjs.ejs +++ b/generators/generate-blueprint/templates/cli/cli.cjs.ejs @@ -1,8 +1,15 @@ #!/usr/bin/env node -const { dirname, basename, join } = require('path'); +import { dirname, basename, join } from 'path'; +import { fileURLToPath } from 'url'; +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); const { version, bin } = require('../package.json'); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + // Get package name to use as namespace. // Allows blueprints to be aliased. const packagePath = dirname(__dirname); diff --git a/generators/generate-blueprint/templates/cli/commands.cjs.ejs b/generators/generate-blueprint/templates/cli/commands.cjs.ejs index 6d3cd374debf..66b6eb5ea2fb 100644 --- a/generators/generate-blueprint/templates/cli/commands.cjs.ejs +++ b/generators/generate-blueprint/templates/cli/commands.cjs.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -module.exports = { +export default { <% for (const command of commands) { %> '<%= command %>': { desc: 'Run <%= command %> sub-generator (<%= baseName %> blueprint)', diff --git a/generators/react/resources/package.json b/generators/react/resources/package.json index fa1b8b179f6b..b3ec2a82c2f0 100644 --- a/generators/react/resources/package.json +++ b/generators/react/resources/package.json @@ -1,4 +1,5 @@ { + "type": "module", "dependencies": { "@fortawesome/fontawesome-svg-core": "7.0.1", "@fortawesome/free-solid-svg-icons": "7.0.1", diff --git a/generators/react/templates/jest.conf.js.ejs b/generators/react/templates/jest.conf.js.ejs index 3c0b4385391c..c100c738b786 100644 --- a/generators/react/templates/jest.conf.js.ejs +++ b/generators/react/templates/jest.conf.js.ejs @@ -1,44 +1,9 @@ +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); const tsconfig = require('./tsconfig.test.json'); +import environment from './webpack/environment.js'; -module.exports = { - testEnvironment: 'jest-fixed-jsdom', - transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: './tsconfig.test.json', - compiler: 'typescript', - diagnostics: false, - }, - ], - }, - testEnvironmentOptions: { - url: 'http://localhost/', - }, - cacheDirectory: '/<%= this.relativeDir(clientRootDir, temporaryDir) %>jest-cache', - coverageDirectory: '/<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/', - testMatch: ['/<%= this.relativeDir(clientRootDir, clientSrcDir) %>app/**/@(*.)@(spec.ts?(x))'], - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], - coveragePathIgnorePatterns: ['/<%= this.relativeDir(clientRootDir, clientTestDir) %>'], - moduleNameMapper: mapTypescriptAliasToJestAlias({ - '\\.(css|scss)$': 'identity-obj-proxy', - sinon: require.resolve('sinon/pkg/sinon.js'), - }), - reporters: [ - 'default', - ['jest-junit', { outputDirectory: './<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/', outputName: 'TESTS-results-jest.xml' }], - ['jest-sonar', { outputDirectory: './<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/jest', outputName: 'TESTS-results-sonar.xml' }], - ], - testPathIgnorePatterns: ['/node_modules/'], - setupFiles: ['/<%= this.relativeDir(clientRootDir, clientSrcDir) %>app/setup-tests.ts'], - globals: { -<%_ if (enableTranslation) { _%> - I18N_HASH: 'generated_hash', -<%_ } _%> - ...require('./webpack/environment'), - DEVELOPMENT: false, - }, -}; function mapTypescriptAliasToJestAlias(alias = {}) { const jestAliases = { ...alias }; @@ -65,3 +30,43 @@ function mapTypescriptAliasToJestAlias(alias = {}) { }, jestAliases); return jestAliases; } + + export default { + testEnvironment: 'jest-fixed-jsdom', + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + tsconfig: './tsconfig.test.json', + compiler: 'typescript', + diagnostics: false, + }, + ], + }, + testEnvironmentOptions: { + url: 'http://localhost/', + }, + cacheDirectory: '/<%= this.relativeDir(clientRootDir, temporaryDir) %>jest-cache', + coverageDirectory: '/<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/', + testMatch: ['/<%= this.relativeDir(clientRootDir, clientSrcDir) %>app/**/@(*.)@(spec.ts?(x))'], + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + coveragePathIgnorePatterns: ['/<%= this.relativeDir(clientRootDir, clientTestDir) %>'], + moduleNameMapper: mapTypescriptAliasToJestAlias({ + '\\.(css|scss)$': 'identity-obj-proxy', + sinon: require.resolve('sinon/pkg/sinon.js'), + }), + reporters: [ + 'default', + ['jest-junit', { outputDirectory: './<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/', outputName: 'TESTS-results-jest.xml' }], + ['jest-sonar', { outputDirectory: './<%= this.relativeDir(clientRootDir, temporaryDir) %>test-results/jest', outputName: 'TESTS-results-sonar.xml' }], + ], + testPathIgnorePatterns: ['/node_modules/'], + setupFiles: ['/<%= this.relativeDir(clientRootDir, clientSrcDir) %>app/setup-tests.ts'], + globals: { + <%_ if (enableTranslation) { _%> + I18N_HASH: 'generated_hash', + <%_ } _%> + ...require('./webpack/environment'), + DEVELOPMENT: false, + }, + }; \ No newline at end of file diff --git a/generators/react/templates/postcss.config.js.ejs b/generators/react/templates/postcss.config.js.ejs index 9532ea140f28..f9bb74c2624d 100644 --- a/generators/react/templates/postcss.config.js.ejs +++ b/generators/react/templates/postcss.config.js.ejs @@ -16,6 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. -%> -module.exports = { +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +export default { plugins: [require('autoprefixer')], }; diff --git a/generators/react/templates/webpack/environment.js.ejs b/generators/react/templates/webpack/environment.js.ejs index d1f598c74be2..32fb3df9e2cb 100644 --- a/generators/react/templates/webpack/environment.js.ejs +++ b/generators/react/templates/webpack/environment.js.ejs @@ -17,10 +17,12 @@ limitations under the License. -%> <%_ if (buildToolUnknown) { _%> +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); const packageJson = require('./../package.json'); <%_ } _%> -module.exports = { +export default { <%_ if (buildToolUnknown) { _%> VERSION: packageJson.version, <%_ } else { _%> diff --git a/generators/react/templates/webpack/utils.js.ejs b/generators/react/templates/webpack/utils.js.ejs index cc2a35b8ff82..08f35fb8fb70 100644 --- a/generators/react/templates/webpack/utils.js.ejs +++ b/generators/react/templates/webpack/utils.js.ejs @@ -16,14 +16,15 @@ See the License for the specific language governing permissions and limitations under the License. -%> +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; const path = require('path'); - const tsconfig = require('../tsconfig.json'); -module.exports = { - root, - mapTypescriptAliasToWebpackAlias, -}; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); const _root = path.resolve(__dirname, '..'); @@ -55,3 +56,8 @@ function mapTypescriptAliasToWebpackAlias(alias = {}) { }, webpackAliases); return webpackAliases; } + +export default { + root, + mapTypescriptAliasToWebpackAlias, +}; \ No newline at end of file diff --git a/generators/react/templates/webpack/webpack.common.js.ejs b/generators/react/templates/webpack/webpack.common.js.ejs index 780033d0b745..8f16e3f0b9f5 100644 --- a/generators/react/templates/webpack/webpack.common.js.ejs +++ b/generators/react/templates/webpack/webpack.common.js.ejs @@ -16,6 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. -%> +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); const path = require('path'); const webpack = require('webpack'); const { merge } = require('webpack-merge'); @@ -28,7 +30,7 @@ const { hashElement } = require('folder-hash'); const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin'); <%_ } _%> const utils = require('./utils.js'); -const environment = require('./environment'); +const environment = require('./environment.js'); const getTsLoaderRule = () => { return [ @@ -51,7 +53,7 @@ const getTsLoaderRule = () => { ]; }; -module.exports = async options => { +export default async options => { const development = options.env === 'development'; <%_ if (enableTranslation) { _%> const languagesHash = await hashElement(path.resolve(__dirname, '../<%= this.relativeDir(clientRootDir, clientSrcDir) %>i18n'), { diff --git a/generators/react/templates/webpack/webpack.dev.js.ejs b/generators/react/templates/webpack/webpack.dev.js.ejs index 2e9c2b809370..0191790fda14 100644 --- a/generators/react/templates/webpack/webpack.dev.js.ejs +++ b/generators/react/templates/webpack/webpack.dev.js.ejs @@ -16,7 +16,12 @@ See the License for the specific language governing permissions and limitations under the License. -%> -const webpackMerge = require('webpack-merge').merge; +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); +const { merge: webpackMerge } = require('webpack-merge'); const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin'); const WebpackNotifierPlugin = require('webpack-notifier'); @@ -25,13 +30,16 @@ const sass = require('sass'); <%_ if (enableI18nRTL) { _%> const postcssRTLCSS = require('postcss-rtlcss'); <%_ } _%> - const utils = require('./utils.js'); const commonConfig = require('./webpack.common.js'); +// ESM equivalent of __dirname +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + const ENV = 'development'; -module.exports = async (options) => webpackMerge(await commonConfig({ env: ENV }), { +export default async (options) => webpackMerge(await commonConfig({ env: ENV }), { devtool: 'cheap-module-source-map', // https://reactjs.org/docs/cross-origin-errors.html mode: ENV, entry: [ diff --git a/generators/react/templates/webpack/webpack.prod.js.ejs b/generators/react/templates/webpack/webpack.prod.js.ejs index 1185d702fb25..b8c7a2cee8ed 100644 --- a/generators/react/templates/webpack/webpack.prod.js.ejs +++ b/generators/react/templates/webpack/webpack.prod.js.ejs @@ -16,6 +16,9 @@ See the License for the specific language governing permissions and limitations under the License. -%> +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); const webpack = require('webpack'); const webpackMerge = require('webpack-merge').merge; const MiniCssExtractPlugin = require('mini-css-extract-plugin'); diff --git a/generators/vue/resources/package.json b/generators/vue/resources/package.json index 51e42735221e..514e2b33944a 100644 --- a/generators/vue/resources/package.json +++ b/generators/vue/resources/package.json @@ -1,4 +1,5 @@ { + "type": "module", "dependencies": { "@fortawesome/fontawesome-svg-core": "7.0.1", "@fortawesome/free-solid-svg-icons": "7.0.1", diff --git a/generators/vue/templates/.postcssrc.js.ejs b/generators/vue/templates/.postcssrc.js.ejs index 39ebf318ccd6..9c9a43b8acd8 100644 --- a/generators/vue/templates/.postcssrc.js.ejs +++ b/generators/vue/templates/.postcssrc.js.ejs @@ -1,6 +1,6 @@ // https://github.com/michael-ciniawsky/postcss-load-config -module.exports = { +export default { plugins: { 'postcss-import': {}, 'postcss-url': {}, diff --git a/generators/vue/templates/module-federation.config.cjs.ejs b/generators/vue/templates/module-federation.config.js.ejs similarity index 88% rename from generators/vue/templates/module-federation.config.cjs.ejs rename to generators/vue/templates/module-federation.config.js.ejs index 83734f36ccd9..b0191bdc4ef2 100644 --- a/generators/vue/templates/module-federation.config.cjs.ejs +++ b/generators/vue/templates/module-federation.config.js.ejs @@ -16,8 +16,16 @@ See the License for the specific language governing permissions and limitations under the License. -%> +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); const packageJson = require('./package.json'); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + // Microfrontend api, should match across gateway and microservices. const apiVersion = '0.0.1'; @@ -32,7 +40,7 @@ const shareDependencies = ({ skipList = [] } = {}) => ); /** @type {import('@module-federation/runtime').Options} */ -module.exports = { +export default { name: '<%= lowercaseBaseName %>', <%_ if (applicationTypeMicroservice) { _%> exposes: { diff --git a/generators/vue/templates/webpack/config.js.ejs b/generators/vue/templates/webpack/config.js.ejs index fe10699613d9..baabc78d1acf 100644 --- a/generators/vue/templates/webpack/config.js.ejs +++ b/generators/vue/templates/webpack/config.js.ejs @@ -1,10 +1,17 @@ -'use strict'; +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); <%_ if (buildToolUnknown) { _%> const packageJson = require('./../package.json'); <%_ } _%> -module.exports = { +export default { serverApiUrl: '', <%_ if (buildToolUnknown) { _%> version: packageJson.version, diff --git a/generators/vue/templates/webpack/vue.utils.js.ejs b/generators/vue/templates/webpack/vue.utils.js.ejs index 6552b8c4165e..286f326be65f 100644 --- a/generators/vue/templates/webpack/vue.utils.js.ejs +++ b/generators/vue/templates/webpack/vue.utils.js.ejs @@ -1,4 +1,5 @@ -'use strict'; +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const sass = require('sass'); @@ -85,7 +86,7 @@ const vueLoaderConfig = production => ({ hotReload: config.dev.hotReload, }); -module.exports = { +export default { cssLoaders, styleLoaders, vueLoaderConfig, diff --git a/generators/vue/templates/webpack/webpack.common.js.ejs b/generators/vue/templates/webpack/webpack.common.js.ejs index 8b24543ed05d..634d9e781521 100644 --- a/generators/vue/templates/webpack/webpack.common.js.ejs +++ b/generators/vue/templates/webpack/webpack.common.js.ejs @@ -1,4 +1,8 @@ -'use strict'; +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); const path = require('path'); const { merge } = require('webpack-merge'); const { VueLoaderPlugin } = require('vue-loader'); @@ -10,14 +14,17 @@ const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin'); <%_ } _%> const { DefinePlugin } = require('webpack'); -const { vueLoaderConfig } = require('./vue.utils'); -const config = require('./config'); +const { vueLoaderConfig } = require('./vue.utils.js'); +const config = require('./config.js'); + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); function resolve(dir = '') { return path.join(__dirname, '..', dir); } -module.exports = async (env, options) => { +export default async (env, options) => { const development = options.mode === 'development'; <%_ if (enableTranslation) { _%> const languagesHash = await hashElement(resolve('<%= this.relativeDir(clientRootDir, clientSrcDir) %>i18n'), { diff --git a/generators/vue/templates/webpack/webpack.dev.js.ejs b/generators/vue/templates/webpack/webpack.dev.js.ejs index 8ff63e69b28d..67a36ff71e6c 100644 --- a/generators/vue/templates/webpack/webpack.dev.js.ejs +++ b/generators/vue/templates/webpack/webpack.dev.js.ejs @@ -16,13 +16,17 @@ See the License for the specific language governing permissions and limitations under the License. -%> -'use strict'; +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); const { styleLoaders } = require('./vue.utils'); -const config = require('./config'); +const config = require('./config.js'); -module.exports = (env, options) => { +export default (env, options) => { const devConfig = { module: { rules: styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }), diff --git a/generators/vue/templates/webpack/webpack.prod.js.ejs b/generators/vue/templates/webpack/webpack.prod.js.ejs index a8d6afd96db1..a71e85d9764e 100644 --- a/generators/vue/templates/webpack/webpack.prod.js.ejs +++ b/generators/vue/templates/webpack/webpack.prod.js.ejs @@ -16,14 +16,21 @@ See the License for the specific language governing permissions and limitations under the License. -%> -'use strict'; +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const require = createRequire(import.meta.url); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const WorkboxPlugin = require('workbox-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const { styleLoaders } = require('./vue.utils'); -const config = require('./config'); +const config = require('./config.js'); + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); const webpackConfig = { module: { @@ -123,4 +130,4 @@ if (config.build.bundleAnalyzerReport) { webpackConfig.plugins.push(new BundleAnalyzerPlugin()); } -module.exports = async () => webpackConfig; +export default async () => webpackConfig; From bb329aab4a8ad2d12847f10dc5e2ee32f0e01f54 Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Tue, 9 Sep 2025 17:57:04 +0530 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20correct=20missed=20.cjs=20=E2=86=92?= =?UTF-8?q?=20.js=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generators/angular/files-angular.ts | 2 +- .../templates/webpack/webpack.prod.js.ejs | 25 ++++++++----------- generators/vue/files-vue.ts | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/generators/angular/files-angular.ts b/generators/angular/files-angular.ts index 495bfb7abf1d..45d3b6703ef9 100644 --- a/generators/angular/files-angular.ts +++ b/generators/angular/files-angular.ts @@ -61,7 +61,7 @@ export const files = asWriteFilesSection({ condition: ctx => ctx.clientBundlerExperimentalEsbuild, templates: [ { sourceFile: 'angular.json.esbuild', destinationFile: 'angular.json' }, - 'proxy.config.mjs', + 'proxy.config.js', 'build-plugins/define-esbuild.mjs', ], }), diff --git a/generators/react/templates/webpack/webpack.prod.js.ejs b/generators/react/templates/webpack/webpack.prod.js.ejs index b8c7a2cee8ed..01f5ec54812e 100644 --- a/generators/react/templates/webpack/webpack.prod.js.ejs +++ b/generators/react/templates/webpack/webpack.prod.js.ejs @@ -16,26 +16,23 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import { createRequire } from 'module'; - -const require = createRequire(import.meta.url); -const webpack = require('webpack'); -const webpackMerge = require('webpack-merge').merge; -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const WorkboxPlugin = require('workbox-webpack-plugin'); -const TerserPlugin = require('terser-webpack-plugin'); -const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); -const sass = require('sass'); +import webpack from 'webpack'; +import { merge as webpackMerge } from 'webpack-merge'; +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +import WorkboxPlugin from 'workbox-webpack-plugin'; +import TerserPlugin from 'terser-webpack-plugin'; +import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'; +import sass from 'sass'; <%_ if (enableI18nRTL) { _%> -const postcssRTLCSS = require('postcss-rtlcss'); +import postcssRTLCSS from 'postcss-rtlcss'; <%_ } _%> -const utils = require('./utils.js'); -const commonConfig = require('./webpack.common.js'); +import * as utils from './utils.js'; +import commonConfig from './webpack.common.js'; const ENV = 'production'; -module.exports = async () => webpackMerge(await commonConfig({ env: ENV }), { +export default async () => webpackMerge(await commonConfig({ env: ENV }), { // devtool: 'source-map', // Enable source maps. Please note that this will slow down the build mode: ENV, entry: { diff --git a/generators/vue/files-vue.ts b/generators/vue/files-vue.ts index 978531a0565f..c2bbfb0173da 100644 --- a/generators/vue/files-vue.ts +++ b/generators/vue/files-vue.ts @@ -40,7 +40,7 @@ export const vueFiles = asWriteFilesSection({ microfrontend: [ clientRootTemplatesBlock({ condition: generator => generator.microfrontend, - templates: ['module-federation.config.cjs'], + templates: ['module-federation.config.js'], }), clientRootTemplatesBlock({ condition: ctx => ctx.microfrontend && ctx.clientBundlerWebpack, From eb7b0c8a49943f010c1a5cea02ba1f5814bcc490 Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Fri, 12 Sep 2025 04:29:59 +0530 Subject: [PATCH 4/6] Fixed missing .mjs -> .js imports --- generators/angular/files-angular.ts | 4 +-- .../templates/angular.json.esbuild.ejs | 6 ++--- .../templates/webpack/webpack.common.js.ejs | 25 +++++++++++-------- .../templates/webpack/webpack.dev.js.ejs | 4 +-- generators/vue/generator.ts | 2 +- .../vue/templates/vitest.config.mts.ejs | 2 +- .../templates/webpack/webpack.common.js.ejs | 3 +-- .../vue/templates/webpack/webpack.dev.js.ejs | 6 ++--- .../vue/templates/webpack/webpack.prod.js.ejs | 5 ++-- 9 files changed, 30 insertions(+), 27 deletions(-) diff --git a/generators/angular/files-angular.ts b/generators/angular/files-angular.ts index 45d3b6703ef9..9e151a02b1a5 100644 --- a/generators/angular/files-angular.ts +++ b/generators/angular/files-angular.ts @@ -62,12 +62,12 @@ export const files = asWriteFilesSection({ templates: [ { sourceFile: 'angular.json.esbuild', destinationFile: 'angular.json' }, 'proxy.config.js', - 'build-plugins/define-esbuild.mjs', + 'build-plugins/define-esbuild.js', ], }), clientRootTemplatesBlock({ condition: ctx => ctx.clientBundlerExperimentalEsbuild && ctx.enableTranslation, - templates: ['build-plugins/i18n-esbuild.mjs'], + templates: ['build-plugins/i18n-esbuild.js'], }), clientSrcTemplatesBlock({ condition: ctx => ctx.clientBundlerExperimentalEsbuild && ctx.enableTranslation, diff --git a/generators/angular/templates/angular.json.esbuild.ejs b/generators/angular/templates/angular.json.esbuild.ejs index 77f4e3a0f99e..94f871496738 100644 --- a/generators/angular/templates/angular.json.esbuild.ejs +++ b/generators/angular/templates/angular.json.esbuild.ejs @@ -40,9 +40,9 @@ "options": { "plugins": [ <%_ if (enableTranslation) { _%> - "build-plugins/i18n-esbuild.mjs", + "build-plugins/i18n-esbuild.js", <%_ } _%> - "build-plugins/define-esbuild.mjs" + "build-plugins/define-esbuild.js" ], "outputPath": { "base": "<%= this.relativeDir(clientRootDir, clientDistDir) %>", @@ -126,7 +126,7 @@ "options": { "buildTarget": "<%= dasherizedBaseName %>:build:development", "open": true, - "proxyConfig": "proxy.config.mjs", + "proxyConfig": "proxy.config.js", "port": <%= devServerPort %> }, "configurations": { diff --git a/generators/react/templates/webpack/webpack.common.js.ejs b/generators/react/templates/webpack/webpack.common.js.ejs index 8f16e3f0b9f5..6483c8e72ee6 100644 --- a/generators/react/templates/webpack/webpack.common.js.ejs +++ b/generators/react/templates/webpack/webpack.common.js.ejs @@ -18,19 +18,24 @@ -%> import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const path = require('path'); -const webpack = require('webpack'); -const { merge } = require('webpack-merge'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -const ESLintPlugin = require('eslint-webpack-plugin'); +import path from 'path'; +import {dirname} from 'path'; +import {fileURLToPath} from 'url'; +import webpack from 'webpack'; +import { merge } from 'webpack-merge'; +import CopyWebpackPlugin from 'copy-webpack-plugin'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; +import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import ESLintPlugin from 'eslint-webpack-plugin'; <%_ if (enableTranslation) { _%> const { hashElement } = require('folder-hash'); -const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin'); +import MergeJsonWebpackPlugin from 'merge-jsons-webpack-plugin'; <%_ } _%> -const utils = require('./utils.js'); -const environment = require('./environment.js'); +import utils from './utils.js'; +import environment from './environment.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); const getTsLoaderRule = () => { return [ diff --git a/generators/react/templates/webpack/webpack.dev.js.ejs b/generators/react/templates/webpack/webpack.dev.js.ejs index 0191790fda14..f126db3efa2c 100644 --- a/generators/react/templates/webpack/webpack.dev.js.ejs +++ b/generators/react/templates/webpack/webpack.dev.js.ejs @@ -30,8 +30,8 @@ const sass = require('sass'); <%_ if (enableI18nRTL) { _%> const postcssRTLCSS = require('postcss-rtlcss'); <%_ } _%> -const utils = require('./utils.js'); -const commonConfig = require('./webpack.common.js'); +import utils from './utils.js'; +import commonConfig from './webpack.common.js'; // ESM equivalent of __dirname const __filename = fileURLToPath(import.meta.url); diff --git a/generators/vue/generator.ts b/generators/vue/generator.ts index 89bec5ee8967..a30a0581dc20 100644 --- a/generators/vue/generator.ts +++ b/generators/vue/generator.ts @@ -108,7 +108,7 @@ export default class VueGenerator extends ClientApplicationGenerator { javaNodeBuildPaths?.push('.postcssrc.js', 'tsconfig.json', 'tsconfig.app.json'); if (microfrontend) { - javaNodeBuildPaths?.push('module-federation.config.cjs'); + javaNodeBuildPaths?.push('module-federation.config.js'); } if (clientBundlerWebpack) { javaNodeBuildPaths?.push('webpack/'); diff --git a/generators/vue/templates/vitest.config.mts.ejs b/generators/vue/templates/vitest.config.mts.ejs index 141ffb3aa73f..c219312fb7a9 100644 --- a/generators/vue/templates/vitest.config.mts.ejs +++ b/generators/vue/templates/vitest.config.mts.ejs @@ -18,7 +18,7 @@ -%> import { fileURLToPath } from 'node:url' import { mergeConfig, defineConfig } from 'vitest/config'; -import viteConfig from './vite.config.mjs' +import viteConfig from './vite.config.mts' export default mergeConfig( viteConfig, diff --git a/generators/vue/templates/webpack/webpack.common.js.ejs b/generators/vue/templates/webpack/webpack.common.js.ejs index 634d9e781521..1ae950f1f716 100644 --- a/generators/vue/templates/webpack/webpack.common.js.ejs +++ b/generators/vue/templates/webpack/webpack.common.js.ejs @@ -1,7 +1,6 @@ import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; - const require = createRequire(import.meta.url); const path = require('path'); const { merge } = require('webpack-merge'); @@ -58,7 +57,7 @@ export default async (env, options) => { }, devServer: { <%_ if (microfrontend) { _%> - hot: config.dev.hotReload, + hot: config.dev?.hotReload ?? false, <%_ } _%> static: { directory: './<%= this.relativeDir(clientRootDir, clientDistDir) %>', diff --git a/generators/vue/templates/webpack/webpack.dev.js.ejs b/generators/vue/templates/webpack/webpack.dev.js.ejs index 67a36ff71e6c..c80624e17a55 100644 --- a/generators/vue/templates/webpack/webpack.dev.js.ejs +++ b/generators/vue/templates/webpack/webpack.dev.js.ejs @@ -19,19 +19,19 @@ import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; +import config from './config.js'; +import { styleLoaders } from './vue.utils.js'; const require = createRequire(import.meta.url); const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); -const { styleLoaders } = require('./vue.utils'); -const config = require('./config.js'); export default (env, options) => { const devConfig = { module: { rules: styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }), }, - // cheap-module-eval-source-map is faster for development + // cheap-module-eval-source-map is faster for developmenst devtool: config.dev.devtool, output: { filename: 'app/[name].[contenthash].bundle.js', diff --git a/generators/vue/templates/webpack/webpack.prod.js.ejs b/generators/vue/templates/webpack/webpack.prod.js.ejs index a71e85d9764e..a688d4c4785d 100644 --- a/generators/vue/templates/webpack/webpack.prod.js.ejs +++ b/generators/vue/templates/webpack/webpack.prod.js.ejs @@ -19,6 +19,8 @@ import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; +import { styleLoaders } from './vue.utils.js'; +import config from './config.js'; const require = createRequire(import.meta.url); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -26,9 +28,6 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const WorkboxPlugin = require('workbox-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); -const { styleLoaders } = require('./vue.utils'); -const config = require('./config.js'); - const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); From 18bb199be67c24ad278f89e7e0f838bb76125404 Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Fri, 12 Sep 2025 07:28:29 +0530 Subject: [PATCH 5/6] fix:snapshot updates and some of remaining misses --- .../__snapshots__/generator.spec.ts.snap | 24 +++++++-------- generators/generate-blueprint/files.ts | 30 +++++++++---------- ...ions.cjs.ejs => cli-customizations.js.ejs} | 0 .../templates/cli/{cli.cjs.ejs => cli.js.ejs} | 0 .../cli/{commands.cjs.ejs => commands.js.ejs} | 0 .../vue/__snapshots__/generator.spec.ts.snap | 4 +-- 6 files changed, 29 insertions(+), 29 deletions(-) rename generators/generate-blueprint/templates/cli/{cli-customizations.cjs.ejs => cli-customizations.js.ejs} (100%) rename generators/generate-blueprint/templates/cli/{cli.cjs.ejs => cli.js.ejs} (100%) rename generators/generate-blueprint/templates/cli/{commands.cjs.ejs => commands.js.ejs} (100%) diff --git a/generators/generate-blueprint/__snapshots__/generator.spec.ts.snap b/generators/generate-blueprint/__snapshots__/generator.spec.ts.snap index dea89ce49208..fb87bf48c00a 100644 --- a/generators/generate-blueprint/__snapshots__/generator.spec.ts.snap +++ b/generators/generate-blueprint/__snapshots__/generator.spec.ts.snap @@ -2,16 +2,16 @@ exports[`generator - generate-blueprint with all option should match snapshot 1`] = ` { - ".blueprint/cli/commands.mjs": { + ".blueprint/cli/commands.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/command.mjs": { + ".blueprint/generate-sample/command.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/generator.mjs": { + ".blueprint/generate-sample/generator.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/index.mjs": { + ".blueprint/generate-sample/index.js": { "stateCleared": "modified", }, ".blueprint/generate-sample/templates/samples/sample.jdl": { @@ -26,10 +26,10 @@ exports[`generator - generate-blueprint with all option should match snapshot 1` "README.md": { "stateCleared": "modified", }, - "cli/cli-customizations.cjs": { + "cli/cli-customizations.js": { "stateCleared": "modified", }, - "cli/cli.cjs": { + "cli/cli.js": { "stateCleared": "modified", }, "generators/angular/command.js": { @@ -1576,16 +1576,16 @@ exports[`generator - generate-blueprint with all option should match snapshot 1` exports[`generator - generate-blueprint with default config should write files and match snapshot 1`] = ` { - ".blueprint/cli/commands.mjs": { + ".blueprint/cli/commands.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/command.mjs": { + ".blueprint/generate-sample/command.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/generator.mjs": { + ".blueprint/generate-sample/generator.js": { "stateCleared": "modified", }, - ".blueprint/generate-sample/index.mjs": { + ".blueprint/generate-sample/index.js": { "stateCleared": "modified", }, ".blueprint/generate-sample/templates/samples/sample.jdl": { @@ -1600,10 +1600,10 @@ exports[`generator - generate-blueprint with default config should write files a "README.md": { "stateCleared": "modified", }, - "cli/cli-customizations.cjs": { + "cli/cli-customizations.js": { "stateCleared": "modified", }, - "cli/cli.cjs": { + "cli/cli.js": { "stateCleared": "modified", }, "package.json": { diff --git a/generators/generate-blueprint/files.ts b/generators/generate-blueprint/files.ts index 9c2bf7b87e22..ec848241d327 100644 --- a/generators/generate-blueprint/files.ts +++ b/generators/generate-blueprint/files.ts @@ -34,22 +34,22 @@ export const files = asWriteFilesSection({ 'tsconfig.json', 'vitest.config.ts', 'vitest.test-setup.ts', - '.blueprint/cli/commands.mjs', - '.blueprint/generate-sample/command.mjs', - '.blueprint/generate-sample/generator.mjs', - '.blueprint/generate-sample/index.mjs', + '.blueprint/cli/commands.js', + '.blueprint/generate-sample/command.js', + '.blueprint/generate-sample/generator.js', + '.blueprint/generate-sample/index.js', // Always write cli for devBlueprint usage - 'cli/cli.cjs', - { sourceFile: 'cli/cli-customizations.cjs', override: false }, + 'cli/cli.js', + { sourceFile: 'cli/cli-customizations.js', override: false }, ], }, { condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION] && ctx.githubWorkflows, templates: [ - '.blueprint/github-build-matrix/command.mjs', - '.blueprint/github-build-matrix/generator.mjs', - '.blueprint/github-build-matrix/generator.spec.mjs', - '.blueprint/github-build-matrix/index.mjs', + '.blueprint/github-build-matrix/command.js', + '.blueprint/github-build-matrix/generator.js', + '.blueprint/github-build-matrix/generator.spec.js', + '.blueprint/github-build-matrix/index.js', ], }, { @@ -62,7 +62,7 @@ export const files = asWriteFilesSection({ }, { condition: ctx => ctx.commands.length > 0, - templates: ['cli/commands.cjs'], + templates: ['cli/commands.js'], }, ], }); @@ -73,20 +73,20 @@ export const generatorFiles = asWriteFilesSection({ path: 'generators/generator', to: ctx => `${ctx.application.blueprintsPath}${ctx.generator.replaceAll(':', '/generators/')}`, templates: [ - { sourceFile: 'index.mjs', destinationFile: ctx => `index.${ctx.blueprintMjsExtension}` }, + { sourceFile: 'index.js', destinationFile: ctx => `index.${ctx.blueprintMjsExtension}` }, { - sourceFile: 'command.mjs', + sourceFile: 'command.js', destinationFile: ctx => `command.${ctx.blueprintMjsExtension}`, override: data => !data.ignoreExistingGenerators, }, { - sourceFile: 'generator.mjs.jhi', + sourceFile: 'generator.js.jhi', destinationFile: ctx => `generator.${ctx.blueprintMjsExtension}.jhi`, override: data => !data.ignoreExistingGenerators, }, { condition: data => !data.generator.startsWith('entity') && !data.application[LOCAL_BLUEPRINT_OPTION], - sourceFile: 'generator.spec.mjs', + sourceFile: 'generator.spec.js', destinationFile: data => `generator.spec.${data.blueprintMjsExtension}`, override: data => !data.ignoreExistingGenerators, }, diff --git a/generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs b/generators/generate-blueprint/templates/cli/cli-customizations.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/cli/cli-customizations.cjs.ejs rename to generators/generate-blueprint/templates/cli/cli-customizations.js.ejs diff --git a/generators/generate-blueprint/templates/cli/cli.cjs.ejs b/generators/generate-blueprint/templates/cli/cli.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/cli/cli.cjs.ejs rename to generators/generate-blueprint/templates/cli/cli.js.ejs diff --git a/generators/generate-blueprint/templates/cli/commands.cjs.ejs b/generators/generate-blueprint/templates/cli/commands.js.ejs similarity index 100% rename from generators/generate-blueprint/templates/cli/commands.cjs.ejs rename to generators/generate-blueprint/templates/cli/commands.js.ejs diff --git a/generators/vue/__snapshots__/generator.spec.ts.snap b/generators/vue/__snapshots__/generator.spec.ts.snap index 7839f05e7b03..18d832de90af 100644 --- a/generators/vue/__snapshots__/generator.spec.ts.snap +++ b/generators/vue/__snapshots__/generator.spec.ts.snap @@ -1117,7 +1117,7 @@ exports[`generator - vue microservice-jwt-skipUserManagement(false)-withAdminUi( "clientRoot/eslint.config.mjs": { "stateCleared": "modified", }, - "clientRoot/module-federation.config.cjs": { + "clientRoot/module-federation.config.js": { "stateCleared": "modified", }, "clientRoot/package.json": { @@ -1663,7 +1663,7 @@ exports[`generator - vue microservice-oauth2-withAdminUi(true)-skipJhipsterDepen "eslint.config.mjs": { "stateCleared": "modified", }, - "module-federation.config.cjs": { + "module-federation.config.js": { "stateCleared": "modified", }, "package.json": { From ac5af561dd1e888c7dfb7393651104d7365ada9f Mon Sep 17 00:00:00 2001 From: abhishek-Rj Date: Fri, 12 Sep 2025 07:59:11 +0530 Subject: [PATCH 6/6] test(angular): update snapshots after switching proxy.config to .js --- .../angular/__snapshots__/generator.spec.ts.snap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generators/angular/__snapshots__/generator.spec.ts.snap b/generators/angular/__snapshots__/generator.spec.ts.snap index c2a21060cea3..0e9253e67b07 100644 --- a/generators/angular/__snapshots__/generator.spec.ts.snap +++ b/generators/angular/__snapshots__/generator.spec.ts.snap @@ -35,7 +35,7 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa "clientRoot/package.json": { "stateCleared": "modified", }, - "clientRoot/proxy.config.mjs": { + "clientRoot/proxy.config.js": { "stateCleared": "modified", }, "clientRoot/src/404.html": { @@ -763,7 +763,7 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend "clientRoot/package.json": { "stateCleared": "modified", }, - "clientRoot/proxy.config.mjs": { + "clientRoot/proxy.config.js": { "stateCleared": "modified", }, "clientRoot/src/404.html": { @@ -3176,7 +3176,7 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi( "package.json": { "stateCleared": "modified", }, - "proxy.config.mjs": { + "proxy.config.js": { "stateCleared": "modified", }, "src/main/webapp/404.html": { @@ -4298,7 +4298,7 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe "package.json": { "stateCleared": "modified", }, - "proxy.config.mjs": { + "proxy.config.js": { "stateCleared": "modified", }, "src/main/webapp/404.html": { @@ -4993,7 +4993,7 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin "package.json": { "stateCleared": "modified", }, - "proxy.config.mjs": { + "proxy.config.js": { "stateCleared": "modified", }, "src/main/webapp/404.html": {