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(types): Fix module/moduleResolution options for TypeScript 5.2 #3251

Merged
merged 2 commits into from
Jul 16, 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: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/esm/index.js",
"type": "commonjs",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn’t actually do anything as is, but having a placeholder makes using sed a lot easier.

"exports": {
".": {
"require": "./lib/index.js",
Expand Down Expand Up @@ -113,8 +114,10 @@
"update-sponsors": "ts-node --esm -TO '{\"module\":\"node16\",\"target\":\"es2019\"}' scripts/fetch-sponsors.mts",
"bench": "npm run benchmark",
"build": "npm run build:cjs && npm run build:esm",
"make-esm": "sed -i '' 's/\"type\": \"commonjs\"/\"type\": \"module\"/g' package.json",
"make-cjs": "sed -i '' 's/\"type\": \"module\"/\"type\": \"commonjs\"/g' package.json",
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/cheeriojs/cheerio/$(git rev-parse HEAD)/src/",
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"build:esm": "npm run make-esm && npm run build:cjs -- --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json; npm run make-cjs",
"prepublishOnly": "npm run build",
"prepare": "husky install"
},
Expand Down
12 changes: 5 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"compilerOptions": {
/* Basic Options */
"target": "es5",
"module": "commonjs",
"module": "node16",
"lib": ["ES2015.Core"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "lib",
// esModuleInterop is implied by `--module node16`,
// but ts-jest doesn't recognize that and needs it listed.
"esModuleInterop": true,

/* Strict Type-Checking Options */
"strict": true,
Expand All @@ -20,12 +23,7 @@
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

/* Module Resolution Options */
"esModuleInterop": true,
"moduleResolution": "node16",
"resolveJsonModule": true
Comment on lines -26 to -28
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--module node16 implies all three of these things (though I had to add the explicit esModuleInterop back; see the comment above)

"noUnusedParameters": true
},
"include": ["src"],
"exclude": [
Expand Down