-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* knip experiment * some more config * run `knip --fix` once * more configuration, fix issues * Remove deprecated `resetApolloContext` export * add another exlusion * run prettier * some cleanup * api-extractor * config adjustments * add CI job * remove `isNullish` * add a small integration test showing various re-export situations a wrapping library might use * prettier
- Loading branch information
Showing
39 changed files
with
602 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/client": patch | ||
--- | ||
|
||
Remove deprecated `resetApolloContext` export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Look for dead code and unused dependencies | ||
|
||
on: push | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
name: Ubuntu/Node v20 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Install dependencies (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
- name: Run knip | ||
run: npm run knip |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"vite-swc", | ||
"node-standard", | ||
"node-esm", | ||
"wrapping-library", | ||
"shared" | ||
], | ||
"devDependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"devDependencies": { | ||
"typescript": "^5.7.3" | ||
}, | ||
"dependencies": { | ||
"@apollo/client": "^3.12.7" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TypedDocumentNode, OperationVariables } from "@apollo/client"; | ||
import { useQuery } from "@apollo/client/react"; | ||
import { getMarkupFromTree } from "@apollo/client/react/ssr"; | ||
import { relayStylePagination } from "@apollo/client/utilities"; | ||
import { MockSubscriptionLink, MockLink } from "@apollo/client/testing"; | ||
|
||
/** | ||
* This file simulates a library re-exporting functions that wrap Apollo Client | ||
* functionality or exporting objects created with AC utilities. | ||
* | ||
* This is here to ensure that with the introduction of the `exports` field, | ||
* TypeScript compilation errors on declaration emit are avoided. | ||
*/ | ||
|
||
export function useWrappedQuery<TData, TVariables extends OperationVariables>( | ||
query: TypedDocumentNode<TData, TVariables> | ||
) { | ||
return useQuery(query); | ||
} | ||
|
||
export const fieldPolicy = relayStylePagination(); | ||
export const mockSubscriptionLink = new MockSubscriptionLink(); | ||
export const mockLinkWrapper = ( | ||
...args: ConstructorParameters<typeof MockLink> | ||
) => new MockLink(...args); | ||
|
||
export const mockGetMarkupFromTree = ( | ||
...options: Parameters<typeof getMarkupFromTree> | ||
) => getMarkupFromTree(...options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// @ts-check | ||
|
||
import { join } from "node:path"; | ||
import { map } from "./config/entryPoints.js"; | ||
import { readFileSync } from "node:fs"; | ||
|
||
const packageJSON = JSON.parse(readFileSync("package.json", "utf-8")); | ||
|
||
const packageEntries = map(({ dirs, bundleName = "index.ts" }) => | ||
join("src", ...dirs, bundleName) | ||
); | ||
|
||
const scriptEntries = Array.from( | ||
Object.values(packageJSON.scripts) | ||
.join("\n") | ||
.matchAll(/(config\/.*?\.[jt]s)/g) | ||
) | ||
.map((match) => match[1]) | ||
.filter((value, index, arr) => index === arr.indexOf(value)); | ||
|
||
/** @type{import('knip').KnipConfig}*/ | ||
const config = { | ||
exclude: ["optionalPeerDependencies", "unresolved"], | ||
entry: [] | ||
.concat(packageEntries) | ||
.concat(scriptEntries) | ||
.concat([ | ||
"src/cache/inmemory/fixPolyfills.native.ts", | ||
"src/react/types/types.documentation.ts", | ||
"eslint-local-rules/index.js", | ||
]), | ||
project: ["src/**/*.ts", "config/*.[jt]s", "eslint-local-rules/*.[jt]s"], | ||
ignore: ["integration-tests/**/*", ".yalc/**/*"], | ||
ignoreBinaries: ["jq"], | ||
ignoreDependencies: [ | ||
/@size-limit\/.*/, | ||
/eslint-.*/, | ||
// used by `recast` | ||
"@babel/parser", | ||
// called in a script, but with `xargs` | ||
"tsx", | ||
// TS types referenced by "rollup-plugin-terser" | ||
"terser", | ||
// used as a reporter by the `test:coverage` script | ||
"jest-junit", | ||
], | ||
jest: { | ||
config: "config/jest.config.js", | ||
entry: [ | ||
"src/config/jest/setup.ts", | ||
"src/testing/matchers/index.d.ts", | ||
"**/__tests__/**/*.[jt]s?(x)", | ||
"**/*.test.[jt]s?(x)", | ||
"src/**/__benches__/*.bench.ts", | ||
], | ||
}, | ||
typescript: { | ||
config: [ | ||
"tsconfig.json", | ||
"src/tsconfig.json", | ||
"eslint-local-rules/tsconfig.json", | ||
], | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.