diff --git a/package.json b/package.json index 394f5c0ab..3e07966d3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint:fix": "prettier --write '{src,test}/**/*.{ts,md}' README.md package.json", "pretest": "npm run -s lint", "test": "jest --coverage", - "test:typescript": "npx tsc --noEmit --declaration --noUnusedLocals test/typescript-validate.ts" + "test:typescript": "npx tsc --noEmit --declaration --noUnusedLocals --allowImportingTsExtensions test/typescript-validate.ts" }, "repository": "github:octokit/core.js", "keywords": [ @@ -72,6 +72,9 @@ "functions": 100, "lines": 100 } + }, + "moduleNameMapper": { + "^(.+)\\.jsx?$": "$1" } }, "release": { diff --git a/scripts/build.mjs b/scripts/build.mjs index 2a9f9db26..668c39cdf 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/index.ts b/src/index.ts index d4c6cffe0..ca21b027a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,8 +13,8 @@ import type { RequestParameters, ReturnTypeOf, UnionToIntersection, -} from "./types"; -import { VERSION } from "./version"; +} from "./types.js"; +import { VERSION } from "./version.js"; const noop = () => {}; const consoleWarn = console.warn.bind(console); diff --git a/src/types.ts b/src/types.ts index cf3082765..1ab7efda1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,7 @@ import * as OctokitTypes from "@octokit/types"; import { RequestError } from "@octokit/request-error"; -import { Octokit } from "."; +import type { Octokit } from "./index.js"; export type RequestParameters = OctokitTypes.RequestParameters; diff --git a/test/agent-ca/agent-ca-test.test.ts b/test/agent-ca/agent-ca-test.test.ts index 12cde6c7a..a31b3c0c1 100644 --- a/test/agent-ca/agent-ca-test.test.ts +++ b/test/agent-ca/agent-ca-test.test.ts @@ -1,9 +1,9 @@ -import { createServer, type Server } from "https"; -import { readFileSync } from "fs"; -import { resolve } from "path"; +import { createServer, type Server } from "node:https"; +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; import { fetch as undiciFetch, Agent } from "undici"; import { request } from "@octokit/request"; -import { type AddressInfo } from "net"; +import { type AddressInfo } from "node:net"; const ca = readFileSync(resolve(__dirname, "./ca.crt")); diff --git a/test/agent-proxy/agent-proxy-test.test.ts b/test/agent-proxy/agent-proxy-test.test.ts index 3a924d359..f659a926b 100644 --- a/test/agent-proxy/agent-proxy-test.test.ts +++ b/test/agent-proxy/agent-proxy-test.test.ts @@ -9,11 +9,11 @@ * https://github.com/nodejs/undici/blob/512cdadc403874571cd5035a6c41debab1165310/test/proxy-agent.js#L370-L418 * Released under the MIT license */ -import { Server, createServer } from "http"; -import { type AddressInfo } from "net"; +import { Server, createServer } from "node:http"; +import { type AddressInfo } from "node:net"; import { ProxyServer, createProxy } from "proxy"; import { ProxyAgent, fetch as undiciFetch } from "undici"; -import { Octokit } from "../../src"; +import { Octokit } from "../../src/index.ts"; describe("client proxy", () => { let server: Server; diff --git a/test/auth.test.ts b/test/auth.test.ts index 3b6e3cef4..30bd96b1a 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -5,7 +5,7 @@ import { createActionAuth } from "@octokit/auth-action"; import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; import { install as installFakeTimers, type Clock } from "@sinonjs/fake-timers"; -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; const userAgent = `octokit-core.js/0.0.0-development ${getUserAgent()}`; diff --git a/test/constructor.test.ts b/test/constructor.test.ts index 9c8247a41..0a0bb54aa 100644 --- a/test/constructor.test.ts +++ b/test/constructor.test.ts @@ -1,4 +1,4 @@ -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; import fetchMock from "fetch-mock"; describe("Smoke test", () => { diff --git a/test/defaults.test.ts b/test/defaults.test.ts index 3dda4e867..ad38d2064 100644 --- a/test/defaults.test.ts +++ b/test/defaults.test.ts @@ -2,7 +2,7 @@ import fetchMock from "fetch-mock"; import { getUserAgent } from "universal-user-agent"; import { createActionAuth } from "@octokit/auth-action"; -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; const userAgent = `octokit-core.js/0.0.0-development ${getUserAgent()}`; diff --git a/test/graphql.test.ts b/test/graphql.test.ts index 02e2ee977..845cdf9e8 100644 --- a/test/graphql.test.ts +++ b/test/graphql.test.ts @@ -1,6 +1,6 @@ import fetchMock from "fetch-mock"; -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; describe("octokit.graphql()", () => { it("is a function", () => { diff --git a/test/hook.test.ts b/test/hook.test.ts index e97df3a76..3da18bc4d 100644 --- a/test/hook.test.ts +++ b/test/hook.test.ts @@ -1,7 +1,7 @@ import { getUserAgent } from "universal-user-agent"; import fetchMock from "fetch-mock"; -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; const userAgent = `octokit-core.js/0.0.0-development ${getUserAgent()}`; diff --git a/test/issues.test.ts b/test/issues.test.ts index 97923b18e..b932be142 100644 --- a/test/issues.test.ts +++ b/test/issues.test.ts @@ -1,4 +1,4 @@ -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; import fetchMock from "fetch-mock"; /* diff --git a/test/log.test.ts b/test/log.test.ts index ad98c919d..a8d639388 100644 --- a/test/log.test.ts +++ b/test/log.test.ts @@ -14,7 +14,7 @@ describe("octokit.log", () => { const error = jest .spyOn(console, "error") .mockImplementation(() => calls.push("error")); - const Octokit = (await import("../src")).Octokit; + const Octokit = (await import("../src/index.ts")).Octokit; const octokit = new Octokit(); @@ -39,7 +39,7 @@ describe("octokit.log", () => { }); it("has .debug(), .info(), .warn(), and .error() functions", async () => { - const Octokit = (await import("../src")).Octokit; + const Octokit = (await import("../src/index.ts")).Octokit; const octokit = new Octokit(); expect(typeof octokit.log.debug).toBe("function"); @@ -49,7 +49,7 @@ describe("octokit.log", () => { }); it("all .log.*() methods can be overwritten", async () => { - const Octokit = (await import("../src")).Octokit; + const Octokit = (await import("../src/index.ts")).Octokit; const calls: String[] = []; const octokit = new Octokit({ diff --git a/test/plugin.test.ts b/test/plugin.test.ts index ed9160a97..88c80c02e 100644 --- a/test/plugin.test.ts +++ b/test/plugin.test.ts @@ -1,4 +1,4 @@ -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; const pluginFoo = () => { return { foo: "bar" }; diff --git a/test/request.test.ts b/test/request.test.ts index 4e392723b..5058d22be 100644 --- a/test/request.test.ts +++ b/test/request.test.ts @@ -1,7 +1,7 @@ import { getUserAgent } from "universal-user-agent"; import fetchMock from "fetch-mock"; -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; const userAgent = `octokit-core.js/0.0.0-development ${getUserAgent()}`; diff --git a/test/smoke.test.ts b/test/smoke.test.ts index 5fe60b8f1..1a71acaae 100644 --- a/test/smoke.test.ts +++ b/test/smoke.test.ts @@ -1,4 +1,4 @@ -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; describe("Smoke test", () => { it("is a function", () => { diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index b0961e18c..5e8dc2487 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/**/*"] } diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts index 2951ef869..313f688bd 100644 --- a/test/typescript-validate.ts +++ b/test/typescript-validate.ts @@ -2,7 +2,7 @@ // THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING // ************************************************************ -import { Octokit } from "../src"; +import { Octokit } from "../src/index.ts"; export function expectType(what: T) {}