fix(react): fix issues with react ts setup (#29312)

Fixes a couple of things:

1. React application should ignore `eslint.config.js`,
`eslint.config.cjs`, and `eslint.config.mjs` files since they are not
part of the app runtime.
2. React lib generators should always run `npm install`. It currently
runs only when `package.json` has changed, but we need to run it to link
packages regardless of `package.json` changes.
This commit is contained in:
Jack Hsu 2024-12-11 15:00:56 -05:00 committed by GitHub
parent 726c07d324
commit c2eae0e297
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 8 deletions

View File

@ -136,7 +136,7 @@ export async function expoLibraryGeneratorInternal(
// Always run install to link packages. // Always run install to link packages.
if (options.isUsingTsSolutionConfig) { if (options.isUsingTsSolutionConfig) {
tasks.push(() => installPackagesTask(host)); tasks.push(() => installPackagesTask(host, true));
} }
tasks.push(() => { tasks.push(() => {

View File

@ -136,7 +136,7 @@ export async function reactNativeLibraryGeneratorInternal(
// Always run install to link packages. // Always run install to link packages.
if (options.isUsingTsSolutionConfig) { if (options.isUsingTsSolutionConfig) {
tasks.push(() => installPackagesTask(host)); tasks.push(() => installPackagesTask(host, true));
} }
tasks.push(() => { tasks.push(() => {

View File

@ -1335,6 +1335,9 @@ describe('app', () => {
"vite.config.mts", "vite.config.mts",
"vitest.config.ts", "vitest.config.ts",
"vitest.config.mts", "vitest.config.mts",
"eslint.config.js",
"eslint.config.cjs",
"eslint.config.mjs",
], ],
"extends": "../tsconfig.base.json", "extends": "../tsconfig.base.json",
"include": [ "include": [

View File

@ -361,11 +361,19 @@ export async function applicationGeneratorInternal(
); );
} }
updateTsconfigFiles(host, options.appProjectRoot, 'tsconfig.app.json', { updateTsconfigFiles(
host,
options.appProjectRoot,
'tsconfig.app.json',
{
jsx: 'react-jsx', jsx: 'react-jsx',
module: 'esnext', module: 'esnext',
moduleResolution: 'bundler', moduleResolution: 'bundler',
}); },
options.linter === 'eslint'
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
: undefined
);
if (!options.skipFormat) { if (!options.skipFormat) {
await formatFiles(host); await formatFiles(host);

View File

@ -286,7 +286,7 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) {
// Always run install to link packages. // Always run install to link packages.
if (options.isUsingTsSolutionConfig) { if (options.isUsingTsSolutionConfig) {
tasks.push(() => installPackagesTask(host)); tasks.push(() => installPackagesTask(host, true));
} }
tasks.push(() => { tasks.push(() => {