Skip to content
Draft
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
3 changes: 2 additions & 1 deletion cli/cli-jdl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('allows customizing JDL definitions', () => {
await helpers
.prepareTemporaryDir()
.withFiles({
'.blueprint/app/index.mjs': `export const command = {
'.blueprint/package.json': JSON.stringify({ type: 'module' }),
'.blueprint/app/index.js': `export const command = {
configs: {
fooConfig: {
jdl: {
Expand Down
2 changes: 1 addition & 1 deletion cli/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const buildCommands = ({
return command;
} catch (error) {
try {
const { default: command } = await import(`./${key}.mjs`);
const { default: command } = await import(`./${key}.cjs`);
return command;
} catch {
throw error;
Expand Down
14 changes: 7 additions & 7 deletions generators/angular/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa
"clientRoot/angular.json": {
"stateCleared": "modified",
},
"clientRoot/eslint.config.mjs": {
"clientRoot/eslint.config.js": {
"stateCleared": "modified",
},
"clientRoot/jest.conf.js": {
Expand Down Expand Up @@ -759,7 +759,7 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend
"clientRoot/angular.json": {
"stateCleared": "modified",
},
"clientRoot/eslint.config.mjs": {
"clientRoot/eslint.config.js": {
"stateCleared": "modified",
},
"clientRoot/jest.conf.js": {
Expand Down Expand Up @@ -1725,7 +1725,7 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi
"clientRoot/angular.json": {
"stateCleared": "modified",
},
"clientRoot/eslint.config.mjs": {
"clientRoot/eslint.config.js": {
"stateCleared": "modified",
},
"clientRoot/jest.conf.js": {
Expand Down Expand Up @@ -2448,7 +2448,7 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD
"angular.json": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"eslint.config.js": {
"stateCleared": "modified",
},
"jest.conf.js": {
Expand Down Expand Up @@ -3181,7 +3181,7 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(
"angular.json": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"eslint.config.js": {
"stateCleared": "modified",
},
"jest.conf.js": {
Expand Down Expand Up @@ -4315,7 +4315,7 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe
"angular.json": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"eslint.config.js": {
"stateCleared": "modified",
},
"jest.conf.js": {
Expand Down Expand Up @@ -5024,7 +5024,7 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin
"angular.json": {
"stateCleared": "modified",
},
"eslint.config.mjs": {
"eslint.config.js": {
"stateCleared": "modified",
},
"jest.conf.js": {
Expand Down
6 changes: 3 additions & 3 deletions generators/angular/files-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export const files = asWriteFilesSection({
condition: ctx => ctx.clientBundlerExperimentalEsbuild,
templates: [
{ sourceFile: 'angular.json.esbuild', destinationFile: 'angular.json' },
'proxy.config.mjs',
'build-plugins/define-esbuild.mjs',
'proxy.config.js',
'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,
Expand Down
10 changes: 10 additions & 0 deletions generators/angular/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ describe(`generator - ${clientFramework}`, () => {
runResult.assertNoFileContent(`${clientRootDir}package.json`, /VERSION_MANAGED_BY_CLIENT_VUE/);
});

it('should use ESM by default in package.json', () => {
runResult.assertFileContent(`${clientRootDir}package.json`, /"type": "module"/);
});

it('should not create files with .mjs extension', () => {
const generatedFiles = runResult.getStateSnapshot();
const mjsFiles = Object.keys(generatedFiles).filter(file => file.endsWith('.mjs'));
expect(mjsFiles).toHaveLength(0);
});

describe('withAdminUi', () => {
const { applicationType, withAdminUi, clientRootDir = '' } = sampleConfig;
const clientSrcDir = `${clientRootDir}${clientRootDir ? 'src/' : CLIENT_MAIN_SRC_DIR}`;
Expand Down
2 changes: 1 addition & 1 deletion generators/angular/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class AngularGenerator extends BaseApplicationGenerator<
applicationDefauts({ application, applicationDefaults }) {
applicationDefaults({
__override__: true,
eslintConfigFile: app => `eslint.config.${app.packageJsonType === 'module' ? 'js' : 'mjs'}`,
eslintConfigFile: _app => `eslint.config.js`,
webappEnumerationsDir: app => `${app.clientSrcDir}app/entities/enumerations/`,
angularLocaleId: app => app.nativeLanguageDefinition.angularLocale ?? defaultLanguage.angularLocale!,
});
Expand Down
6 changes: 3 additions & 3 deletions generators/angular/templates/angular.json.esbuild.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>",
Expand Down Expand Up @@ -126,7 +126,7 @@
"options": {
"buildTarget": "<%= dasherizedBaseName %>:build:development",
"open": true,
"proxyConfig": "proxy.config.mjs",
"proxyConfig": "proxy.config.js",
"port": <%= devServerPort %>
},
"configurations": {
Expand Down
2 changes: 1 addition & 1 deletion generators/angular/templates/jest.conf.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
} = require('./tsconfig.json');

module.exports = {
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$|dayjs/esm<% if (applicationTypeGateway && microfrontend) { %>|@angular-architects/module-federation-runtime<% } %>)'],
transformIgnorePatterns: ['node_modules/(?!.*\\.js$|dayjs/esm<% if (applicationTypeGateway && microfrontend) { %>|@angular-architects/module-federation-runtime<% } %>)'],
resolver: 'jest-preset-angular/build/resolvers/ng-jest-resolver.js',
globals: {
__VERSION__: 'test',
Expand Down
1 change: 1 addition & 0 deletions generators/angular/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"version": "0.0.1-SNAPSHOT",
"description": "<%= projectDescription %>",
"private": true,
"type": "module",
"license": "UNLICENSED",
"cacheDirectories": [
"node_modules"
Expand Down
31 changes: 11 additions & 20 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"camelizedBaseName": "jhipster",
"capitalizedBaseName": "Jhipster",
"caret": undefined,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": "webpack",
Expand Down Expand Up @@ -467,7 +467,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"com.mycompany.myapp",
],
"entitySuffix": "",
"eslintConfigFile": "eslint.config.mjs",
"eslintConfigFile": "eslint.config.js",
"feignClient": false,
"filterEntitiesAndPropertiesForClient": [Function],
"filterEntitiesForClient": [Function],
Expand Down Expand Up @@ -632,7 +632,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"messageBrokerPulsar": false,
"microfrontend": false,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": {
Expand Down Expand Up @@ -765,10 +765,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierExtensions": "md,json,yml,js,cjs,mjs,ts,cts,mts,java,html,css,scss",
Expand Down Expand Up @@ -895,7 +892,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"camelizedBaseName": "jhipster",
"capitalizedBaseName": "Jhipster",
"caret": undefined,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": "webpack",
Expand Down Expand Up @@ -1121,7 +1118,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"com.mycompany.myapp",
],
"entitySuffix": "",
"eslintConfigFile": "eslint.config.mjs",
"eslintConfigFile": "eslint.config.js",
"feignClient": false,
"filterEntitiesAndPropertiesForClient": [Function],
"filterEntitiesForClient": [Function],
Expand Down Expand Up @@ -1280,7 +1277,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"messageBrokerPulsar": false,
"microfrontend": undefined,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": {
Expand Down Expand Up @@ -1413,10 +1410,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierExtensions": "md,json,yml,js,cjs,mjs,ts,cts,mts,java,html,css,scss",
Expand Down Expand Up @@ -1541,7 +1535,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"camelizedBaseName": "jhipster",
"capitalizedBaseName": "Jhipster",
"caret": undefined,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": undefined,
Expand Down Expand Up @@ -1913,7 +1907,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"messageBrokerPulsar": false,
"microfrontend": false,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": {
Expand Down Expand Up @@ -1985,10 +1979,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierExtensions": "md,json,yml,js,cjs,mjs,ts,cts,mts,java",
Expand Down
10 changes: 8 additions & 2 deletions generators/base/blueprints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,21 @@ describe('generator - base - local blueprint', () => {
before(async () => {
await helpers
.runJHipster(BLUEPRINT_NS, { useEnvironmentBuilder: true })
.withFiles({ '.blueprint/app/index.mjs': BLUEPRINT_CONTENTS })
.withFiles({
'.blueprint/app/index.js': BLUEPRINT_CONTENTS,
'.blueprint/package.json': { type: 'module' },
})
.commitFiles()
.withJHipsterConfig();
});

it('creates expected default files', () => {
expect(runResult.getStateSnapshot()).toMatchInlineSnapshot(`
{
".blueprint/app/index.mjs": {
".blueprint/app/index.js": {
"stateCleared": "modified",
},
".blueprint/package.json": {
"stateCleared": "modified",
},
".yo-rc.json": {
Expand Down
9 changes: 3 additions & 6 deletions generators/ci-cd/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports[`generator - ci-cd cli with multiples values should match context snapsh
"ciCdIntegrationsSonar": false,
"ciCdJenkins": true,
"ciCdTravis": false,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": "webpack",
Expand Down Expand Up @@ -230,7 +230,7 @@ exports[`generator - ci-cd cli with multiples values should match context snapsh
"messageBrokerPulsar": false,
"microfrontend": undefined,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": {
Expand Down Expand Up @@ -302,10 +302,7 @@ exports[`generator - ci-cd cli with multiples values should match context snapsh
],
"packageJsonNodeEngine": undefined,
"packageJsonScripts": {},
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierTabWidth": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`generator - client:bootstrap bootstrapping default config should prepar
"camelizedBaseName": "jhipster",
"capitalizedBaseName": "Jhipster",
"caret": undefined,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": "webpack",
Expand Down Expand Up @@ -181,7 +181,7 @@ exports[`generator - client:bootstrap bootstrapping default config should prepar
"messageBrokerPulsar": false,
"microfrontend": false,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": Any<Object>,
Expand All @@ -192,10 +192,7 @@ exports[`generator - client:bootstrap bootstrapping default config should prepar
"packageFolder": undefined,
"packageJsonNodeEngine": undefined,
"packageJsonScripts": Any<Object>,
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierTabWidth": undefined,
Expand Down
1 change: 1 addition & 0 deletions generators/common/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ This application was generated using JHipster JHIPSTER_VERSION, you can find doc
"package.json": {
"contents": "{
"private": true,
"type": "module",
"dependencies": {},
"devDependencies": {
"generator-jhipster": "JHIPSTER_VERSION",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`generator - common:bootstrap bootstrapping default config should prepar
"camelizedBaseName": "jhipster",
"capitalizedBaseName": "Jhipster",
"caret": undefined,
"cjsExtension": ".js",
"cjsExtension": ".cjs",
"cli": undefined,
"cliName": undefined,
"clientBundler": "webpack",
Expand Down Expand Up @@ -174,7 +174,7 @@ exports[`generator - common:bootstrap bootstrapping default config should prepar
"messageBrokerPulsar": false,
"microfrontend": false,
"microfrontends": undefined,
"mjsExtension": ".mjs",
"mjsExtension": ".js",
"monorepository": undefined,
"nativeLanguage": "en",
"nativeLanguageDefinition": Any<Object>,
Expand All @@ -185,10 +185,7 @@ exports[`generator - common:bootstrap bootstrapping default config should prepar
"packageFolder": undefined,
"packageJsonNodeEngine": undefined,
"packageJsonScripts": Any<Object>,
"packageJsonType": "commonjs",
"packageJsonTypeAny": true,
"packageJsonTypeCommonjs": true,
"packageJsonTypeModule": false,
"packageJsonType": "module",
"packageName": "com.mycompany.myapp",
"pkType": undefined,
"prettierTabWidth": undefined,
Expand Down
Loading
Loading