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

fix(module-federation): add tsconfig file for linting with TS webpack #20150 #20210

Merged
merged 1 commit into from
Nov 13, 2023
Merged
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
5 changes: 5 additions & 0 deletions docs/generated/packages/angular/generators/setup-mf.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
"type": "boolean",
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
"default": true
},
"setParserOptionsProject": {
"type": "boolean",
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
"default": false
}
},
"required": ["appName", "mfType"],
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/generators/host/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export async function hostInternal(tree: Tree, schema: Schema) {
prefix: options.prefix,
typescriptConfiguration,
standalone: options.standalone,
setParserOptionsProject: options.setParserOptionsProject,
});

let installTasks = [appInstallTask];
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function remoteInternal(tree: Tree, schema: Schema) {
standalone: options.standalone,
prefix: options.prefix,
typescriptConfiguration,
setParserOptionsProject: options.setParserOptionsProject,
});

const installSwcHelpersTask = addDependenciesToPackageJson(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2020"
},
"include": [
"src/main.ts",
<% if(type === "remote") { %> "src/remote-entry/<% if(standalone) { %>entry.routes.ts", <% } else { %> entry.module.ts", <% } } %>
"webpack.config.ts",
"webpack.prod.config.ts"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ export function generateWebpackConfig(
standalone: options.standalone,
}
);

if (!options.setParserOptionsProject) {
tree.delete(joinPathFragments(appRoot, 'tsconfig.lint.json'));
}
}
1 change: 1 addition & 0 deletions packages/angular/src/generators/setup-mf/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Schema {
standalone?: boolean;
skipE2E?: boolean;
typescriptConfiguration?: boolean;
setParserOptionsProject?: boolean;
}

export interface NormalizedOptions extends Schema {
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/src/generators/setup-mf/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
"type": "boolean",
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
"default": true
},
"setParserOptionsProject": {
"type": "boolean",
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
"default": false
}
},
"required": ["appName", "mfType"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"include": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.ts",
"src/**/*.tsx",
"webpack.config.ts",
"webpack.prod.config.ts"
]
}
6 changes: 6 additions & 0 deletions packages/react/src/generators/host/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ export async function hostGeneratorInternal(
updateProjectConfiguration(host, options.projectName, projectConfig);
}

if (!options.setParserOptionsProject) {
host.delete(
joinPathFragments(options.appProjectRoot, 'tsconfig.lint.json')
);
}

if (!options.skipFormat) {
await formatFiles(host);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"include": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.ts",
"src/**/*.tsx",
"webpack.config.ts",
"webpack.prod.config.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"include": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.ts",
"src/**/*.tsx",
"webpack.config.ts",
"webpack.prod.config.ts"
]
}
5 changes: 5 additions & 0 deletions packages/react/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export async function remoteGeneratorInternal(host: Tree, schema: Schema) {
);
updateProjectConfiguration(host, options.projectName, projectConfig);
}
if (!options.setParserOptionsProject) {
host.delete(
joinPathFragments(options.appProjectRoot, 'tsconfig.lint.json')
);
}

if (!options.skipFormat) {
await formatFiles(host);
Expand Down