From 8340cb7c347b98fa9c334719926adebdff6fee24 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Fri, 21 May 2021 11:05:41 +0100 Subject: [PATCH] chore: set `module` to `esnext` in `tsconfig.json` (#7256) The main `tsconfig.json` file is only used for API Extractor, and by VSCode to provide type information. It is _not_ used to compile Puppeteer for shipping. Therefore we can specify `module: "esnext"` in here so that VSCode knows we can use all the latest and greatest module features (primarily, dynamic imports). In `tsconfig.cjs.json` and `tsconfig.esm.json` we set the `module` setting for CJS/ESM respectively. --- tsconfig.base.json | 1 - tsconfig.json | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 10d347f1561..571f4cc62e4 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,7 +5,6 @@ "checkJs": true, "target": "ES2019", "moduleResolution": "node", - "module": "ES2015", "declaration": true, "declarationMap": true, "resolveJsonModule": true, diff --git a/tsconfig.json b/tsconfig.json index 69717ed6d9b..d35ef12857d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,15 @@ /** - * This configuration only exists for the API Extractor tool. See the details in - * CONTRIBUTING.md that describes our TypeScript setup. -*/ + * This configuration only exists for the API Extractor tool and for VSCode to use. It is NOT the tsconfig used for compilation. + * For CJS builds, `tsconfig.cjs.json` is used, and for ESM, it's `tsconfig.esm.json`. + * See the details in CONTRIBUTING.md that describes our TypeScript setup. + */ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true + "noEmit": true, + // This module setting is just for VSCode so it doesn't error when we use + // dynamic imports. + "module": "esnext" }, "include": ["src"] }