From 83ac1f834e86ed44c885bec381374f9e3dc08392 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:16:35 -0500 Subject: [PATCH] refactor: use `node:` specifier imports and full relative path imports (#524) * refactor: replace NodeJS internal module imports with `node:` specifier imports * refactor: use full relative import paths --- package.json | 3 +++ scripts/build.mjs | 2 +- src/error.ts | 2 +- src/graphql.ts | 4 ++-- src/index.ts | 4 ++-- src/types.ts | 2 +- src/with-defaults.ts | 4 ++-- test/tsconfig.test.json | 3 ++- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 8c12c4ae..e22c4aae 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,9 @@ "functions": 100, "lines": 100 } + }, + "moduleNameMapper": { + "^(.+)\\.jsx?$": "$1" } }, "release": { diff --git a/scripts/build.mjs b/scripts/build.mjs index 7c4257c2..60a7f18b 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -1,6 +1,6 @@ // @ts-check import esbuild from "esbuild"; -import { copyFile, readFile, writeFile, rm } from "fs/promises"; +import { copyFile, readFile, writeFile, rm } from "node:fs/promises"; import { glob } from "glob"; /** diff --git a/src/error.ts b/src/error.ts index 50c8de59..00f11095 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,5 +1,5 @@ import type { ResponseHeaders } from "@octokit/types"; -import type { GraphQlEndpointOptions, GraphQlQueryResponse } from "./types"; +import type { GraphQlEndpointOptions, GraphQlQueryResponse } from "./types.js"; type ServerResponseData = Required>; diff --git a/src/graphql.ts b/src/graphql.ts index 54d71425..38deed66 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -1,12 +1,12 @@ import { request as Request } from "@octokit/request"; import type { ResponseHeaders } from "@octokit/types"; -import { GraphqlResponseError } from "./error"; +import { GraphqlResponseError } from "./error.js"; import type { GraphQlEndpointOptions, RequestParameters, GraphQlQueryResponse, GraphQlQueryResponseData, -} from "./types"; +} from "./types.js"; const NON_VARIABLE_OPTIONS = [ "method", diff --git a/src/index.ts b/src/index.ts index 3a5ae78d..4ea6fa9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ import { request } from "@octokit/request"; import { getUserAgent } from "universal-user-agent"; -import { VERSION } from "./version"; +import { VERSION } from "./version.js"; -import { withDefaults } from "./with-defaults"; +import { withDefaults } from "./with-defaults.js"; export const graphql = withDefaults(request, { headers: { diff --git a/src/types.ts b/src/types.ts index c71c40d5..21f151e5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,7 +4,7 @@ import type { EndpointInterface, } from "@octokit/types"; -import { graphql } from "./graphql"; +import type { graphql } from "./graphql.js"; export type GraphQlEndpointOptions = EndpointOptions & { variables?: { [key: string]: unknown }; diff --git a/src/with-defaults.ts b/src/with-defaults.ts index 6664fbcb..1fae2cb9 100644 --- a/src/with-defaults.ts +++ b/src/with-defaults.ts @@ -3,8 +3,8 @@ import type { graphql as ApiInterface, Query, RequestParameters, -} from "./types"; -import { graphql } from "./graphql"; +} from "./types.js"; +import { graphql } from "./graphql.js"; export function withDefaults( request: typeof Request, diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index b0961e18..5e8dc248 100644 --- a/test/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -3,7 +3,8 @@ "compilerOptions": { "emitDeclarationOnly": false, "noEmit": true, - "verbatimModuleSyntax": false + "verbatimModuleSyntax": false, + "allowImportingTsExtensions": true }, "include": ["src/**/*"] }