Skip to content

Commit

Permalink
fix(module-federation): add tsconfig file for linting with TS webpack #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Nov 13, 2023
1 parent 27aa505 commit c7c845d
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 0 deletions.
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

1 comment on commit c7c845d

@vercel
Copy link

@vercel vercel bot commented on c7c845d Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.