Repository: jhipster/jhipster-lite (java)

Issue:
react core build && dev error
On main, when running `npm run build` on a `react-core` application got:

```sh
npm run build

> jhipster-sample-application@0.0.0 build
> tsc && vite build --emptyOutDir

✘ [ERROR] "vite-tsconfig-paths" resolved to an ESM file. ESM file cannot be loaded by `require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]

    node_modules/esbuild/lib/main.js:1225:27:
      1225 │         let result = await callback({
           ╵                            ^

    at file:///tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/vite/dist/node/chunks/dep-BaOMuo4I.js:66566:23
    at requestCallbacks.on-resolve (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:1225:28)
    at handleRequest (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:647:17)
    at handleIncomingPacket (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:672:7)
    at Socket.readFromStdout (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:600:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)

  This error came from the "onResolve" callback registered here:

    node_modules/esbuild/lib/main.js:1150:20:
      1150 │       let promise = setup({
           ╵                     ^

    at setup (file:///tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/vite/dist/node/chunks/dep-BaOMuo4I.js:66528:18)
    at handlePlugins (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:1150:21)
    at buildOrContextImpl (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:873:5)
    at Object.buildOrContext (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:699:5)
    at /tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:2023:15
    at new Promise (<anonymous>)
    at Object.build (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:2022:25)
    at build (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:1873:51)
    at bundleConfigFile (file:///tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/vite/dist/node/chunks/dep-BaOMuo4I.js:66483:24)

  The plugin "externalize-deps" was triggered by this import

    vite.config.ts:2:26:
      2 │ import tsconfigPaths from 'vite-tsconfig-paths';
        ╵                           ~~~~~~~~~~~~~~~~~~~~~

failed to load config from /tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/vite.config.ts
error during build:
Error: Build failed with 1 error:
node_modules/esbuild/lib/main.js:1225:27: ERROR: [plugin: externalize-deps] "vite-tsconfig-paths" resolved to an ESM file. ESM file cannot be loaded by `require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.
    at failureErrorWithLog (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:1472:15)
    at /tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:945:25
    at runOnEndCallbacks (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:1315:45)
    at buildResponseToResult (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:943:7)
    at /tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:970:16
    at responseCallbacks.<computed> (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:677:12)
    at Socket.readFromStdout (/tmp/9dfbbae6-b568-45d1-bd38-e70d29cdb962/node_modules/esbuild/lib/main.js:600:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
```

With:

```sh
node --version
v20.17.0
```

And 

```sh
npm --version
10.8.2
```

Pull request description:
fix(react): use type module
Fixes #10795

Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
index 35a21ed56..36f73fab9 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
@@ -1,6 +1,7 @@
 package tech.jhipster.lite.generator.client.react.core.domain;
 
 import static tech.jhipster.lite.module.domain.JHipsterModule.*;
+import static tech.jhipster.lite.module.domain.packagejson.NodeModuleFormat.MODULE;
 import static tech.jhipster.lite.module.domain.packagejson.VersionSource.COMMON;
 import static tech.jhipster.lite.module.domain.packagejson.VersionSource.REACT;
 
@@ -37,6 +38,7 @@ public class ReactCoreModulesFactory {
           .and()
         .and()
       .packageJson()
+        .type(MODULE)
         .addDevDependency(packageName("@testing-library/dom"), REACT)
         .addDevDependency(packageName("@testing-library/react"), REACT)
         .addDevDependency(packageName("@types/node"), COMMON)
diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/security/jwt/domain/ReactJwtModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/security/jwt/domain/ReactJwtModuleFactory.java
index 2215293a7..35efb70b4 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/react/security/jwt/domain/ReactJwtModuleFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/react/security/jwt/domain/ReactJwtModuleFactory.java
@@ -1,7 +1,6 @@
 package tech.jhipster.lite.generator.client.react.security.jwt.domain;
 
 import static tech.jhipster.lite.module.domain.JHipsterModule.*;
-import static tech.jhipster.lite.module.domain.packagejson.NodeModuleFormat.MODULE;
 import static tech.jhipster.lite.module.domain.packagejson.VersionSource.COMMON;
 import static tech.jhipster.lite.module.domain.packagejson.VersionSource.REACT;
 
@@ -46,7 +45,6 @@ public class ReactJwtModuleFactory {
     //@formatter:off
     return moduleBuilder(properties)
       .packageJson()
-        .type(MODULE)
         .addDependency(packageName("react-hook-form"), REACT)
         .addDependency(packageName("axios"), REACT)
         .addDependency(packageName("@nextui-org/react"), REACT)


Test patch:
diff --git a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
index d200f9851..5b77b0300 100644
--- a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java
@@ -21,6 +21,7 @@ class ReactCoreModulesFactoryTest {
 
     assertThatModuleWithFiles(module, packageJsonFile(), lintStagedConfigFile())
       .hasFile("package.json")
+      .containing("\"type\": \"module\"")
       .containing(nodeDependency("@testing-library/dom"))
       .containing(nodeDependency("@testing-library/react"))
       .containing(nodeDependency("@types/node"))