Skip to content

Commit

Permalink
Switch moduleResolution to Bundler / Node16
Browse files Browse the repository at this point in the history
1. For student projects, we'll switch to `Bundler`, to avoid problems with
   `Node16` module resolution eg. vercel/next.js#52562
   or vercel/next.js#41189
2. For the ESLint configuration, we'll switch to `Node16`

More background:

- typescript-eslint/typescript-eslint#7213 (comment)
- typescript-eslint/typescript-eslint#7185 (comment)

Next.js also recently changed their default `moduleResolution` from `Node` to
`Bundler`:

- vercel/next.js#51957
  • Loading branch information
karlhorky committed Jul 19, 2023
1 parent cc7e769 commit ab585b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@typescript-eslint/utils/dist').TSESLint.Linter.Config} */
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
const config = {
extends: ['upleveled'],
};
Expand Down
6 changes: 3 additions & 3 deletions index.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@typescript-eslint/utils/dist').TSESLint.Linter.RuleLevelAndOptions} */
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.RuleLevelAndOptions} */
const noRestrictedSyntaxOptions = [
'warn',
// Currently it is not possible to use Markdown eg. links in ESLint warnings / error messages
Expand Down Expand Up @@ -192,7 +192,7 @@ Prefer an if...else statement like this:
* https://github.com/facebook/create-react-app/blob/main/packages/eslint-config-react-app/index.js
* https://github.com/facebook/create-react-app/blob/main/packages/eslint-config-react-app/base.js
*
* @type {import('@typescript-eslint/utils/dist').TSESLint.Linter.Config['rules']}
* @type {import('@typescript-eslint/utils').TSESLint.Linter.Config['rules']}
*/
const eslintConfigReactAppRules = {
'array-callback-return': 'warn',
Expand Down Expand Up @@ -419,7 +419,7 @@ const eslintConfigReactAppRules = {
'react-hooks/rules-of-hooks': 'error',
};

/** @type {import('@typescript-eslint/utils/dist').TSESLint.Linter.Config} */
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
const config = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down
2 changes: 1 addition & 1 deletion templates/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@typescript-eslint/utils/dist').TSESLint.Linter.Config} */
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
const config = {
extends: ['upleveled'],
};
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"$schema": "https://json.schemastore.org/tsconfig",
"display": "UpLeveled Node + React TSConfig",
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"target": "es2015",
"moduleResolution": "node",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"target": "ES2015",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"isolatedModules": true,
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"checkJs": true,
"target": "esnext"
"target": "ESNext",
"module": "Node16",
"moduleResolution": "Node16"
},
"include": [
"**/.eslintrc.cjs",
Expand Down

0 comments on commit ab585b7

Please sign in to comment.