This commit is contained in:
Pete Gonzalez 2020-07-20 14:50:09 -07:00
Родитель 9cb102dc47
Коммит 176c64aed4
3 изменённых файлов: 22 добавлений и 9 удалений

Просмотреть файл

@ -29,7 +29,7 @@ There isn't a Heft-specific file for this task. Heft looks for ESLint's config
- **Consistency:** Using one standard name **".eslintrc.js"** makes it easy to search these files, perform bulk edits, and copy configuration recipes between projects.
- **Workarounds:** Using the `.js` file extension enables JavaScript expressions in the file. This is practice is generally discouraged because code expressions are harder to validate, and expressions can depend on environmental inputs that are invisible to caches. However, for historical reasons, ESLint's config file format has some limitations that can only be solved with scripts (for example using `__dirname` to resolve file paths).
Do not place a centralized **.eslintrc.js** in the monorepo root folder. This violates Rush's principle that projects should be independent and easily movable between monorepos.
It's not recommended to place a centralized **.eslintrc.js** in the monorepo root folder. This violates Rush's principle that projects should be independent and easily movable between monorepos.
Instead, each project should have its own **.eslintrc.js** file. We recommend to use the [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) shared configuration, which is specifically tailored for large scale monorepos, and based on the [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) parser and ruleset. If you need additional custom lint rules, it's recommended to create a custom NPM package that extends from `@rushstack/eslint-config`.
@ -55,3 +55,5 @@ However, if you use the [VS Code extension for ESLint](https://marketplace.visua
```bash
$ rush add --package eslint --dev
```
(Alternatively, the VS Code extension is also able to load a globally installed `eslint` package; however, its version may not match the version required by the local branch.)

Просмотреть файл

@ -33,7 +33,7 @@ Generally your Jest configuration should simply extend Heft's standard preset:
}
```
***Note:** If you find yourself frequently adding lots of custom settings to this file, please create a GitHub issue and tell us about it. Our aim is to provide a configuration that minimizes the need for project-specific customizations.*
_**Note:** If you find yourself frequently adding lots of custom settings to this file, please create a GitHub issue and tell us about it. Our aim is to provide a configuration that minimizes the need for project-specific customizations._
## package.json dependencies

Просмотреть файл

@ -12,7 +12,7 @@ This task invokes the [Webpack](https://webpack.js.org/) tool to produce applica
- Combining many small .js files into one large file for faster downloads
- Improving performance by applying various compiler optimizations such as inlining and dead code elimination ("tree shaking")
- Compacting and obfuscating code by shortening identifiers ("uglifying")
- Compressing and obfuscating code by shortening identifiers (by default, using the [Terser](https://terser.org/) tool)
- Embedding assets such as .css or even images
Webpack also has the ability to act as a general purpose build system, for example by invoking a compiler or linter, however Heft does not use it that way. Heft invokes the TypeScript compiler to produce intermediate .js files which become the inputs for other tasks such as Jest or Webpack. This reduces the number of compiler passes, and avoids the need for compiler optimizations to be reimplemented multiple times for different contexts (`ts-loader`, `ts-jest`, etc).
@ -43,18 +43,19 @@ The [heft-webpack-test](https://github.com/microsoft/rushstack/tree/master/build
const path = require('path');
module.exports = {
mode: 'development',
resolve: {
// Note: Do not specify '.ts' or '.tsx' here. Webpack runs as a postprocess after the compiler.
extensions: ['.js', '.jsx', '.json']
},
entry: {
'localization-test-A': path.join(__dirname, 'lib', 'indexA.js'),
'localization-test-B': path.join(__dirname, 'lib', 'indexB.js')
'test-A': path.join(__dirname, 'lib', 'indexA.js'),
'test-B': path.join(__dirname, 'lib', 'indexB.js')
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]_[locale]_[contenthash].js',
chunkFilename: '[id].[name]_[locale]_[contenthash].js'
filename: '[name]_[contenthash].js',
chunkFilename: '[id].[name]_[contenthash].js'
}
};
```
@ -62,8 +63,6 @@ module.exports = {
## package.json dependencies
None -- Heft loads the `@microsoft/api-extractor` package from the `@microsoft/rush-stack-compiler-*` bundle. See the [typescript]({% link pages/heft_tasks/typescript.md %}) task documentation for details.
Heft has direct dependencies on the Webpack packages that it needs, so you don't need to add Webpack to your project's **package.json** file.
You will need to add `@types/webpack-env` to your project:
@ -71,3 +70,15 @@ You will need to add `@types/webpack-env` to your project:
```bash
$ rush add --package @types/webpack-env --exact --dev
```
Since they are global types, this package needs to be added to your TypeScript configuration like this:
**<project folder>/tsconfig.json**
```
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.7/includes/tsconfig-web.json",
"compilerOptions": {
"types": [ "webpack-env" ]
}
}
```