Skip to content

fix: TypeScript ESM compatibility fixes for moduleResolution: NodeNext #107

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

Merged
merged 1 commit into from
May 22, 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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lib/
socket.io-websocket-only.cjs
socket.io-websocket-only.js
doc/resource
coverage/
build/
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dist"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-commonjs": "^25.0.0",
"@types/uuid": "^9.0.0",
"cross-fetch": "^3.1.5",
"dayjs": "^1.11.7",
Expand All @@ -33,10 +33,10 @@
"lint-staged": "^13.1.0",
"msw": "^1.0.0",
"prettier": "^2.8.3",
"typescript": "^4.9.5",
"vite": "^4.1.1",
"vite-plugin-dts": "^1.7.2",
"vitest": "^0.28.4"
"typescript": "^5.0.4",
"vite": "^4.3.8",
"vite-plugin-dts": "^2.3.0",
"vitest": "^0.31.1"
},
"repository": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions source/event_hub.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// :copyright: Copyright (c) 2016 ftrack
import { v4 as uuidV4 } from "uuid";
import loglevel from "loglevel";
import io, { SocketIO } from "./socket.io-websocket-only.cjs";
import { Event } from "./event";
import * as io from "./socket.io-websocket-only.js";
import { Event } from "./event.js";
import {
EventServerConnectionTimeoutError,
EventServerReplyTimeoutError,
EventServerPublishError,
NotUniqueError,
} from "./error";
import { Data } from "./types";
} from "./error.js";
import { Data } from "./types.js";

interface BaseActionData {
selection: Array<{
Expand Down Expand Up @@ -132,7 +132,7 @@ export class EventHub {
};
private _unsentEvents: ConnectionCallback[];
private _subscribers: Subscriber[];
private _socketIo: SocketIO | null;
private _socketIo: io.SocketIO | null;

/**
* Construct EventHub instance with API credentials.
Expand Down
16 changes: 8 additions & 8 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// :copyright: Copyright (c) 2016 ftrack

export * from "./event";
export * from "./event_hub";
export * from "./session";
export * from "./types";
export * from "./event.js";
export * from "./event_hub.js";
export * from "./session.js";
export * from "./types.js";

export * as error from "./error";
export * as operation from "./operation";
export * as projectSchema from "./project_schema";
export * as error from "./error.js";
export * as operation from "./operation.js";
export * as projectSchema from "./project_schema.js";

export { SERVER_LOCATION_ID } from "./constant";
export { SERVER_LOCATION_ID } from "./constant.js";
6 changes: 3 additions & 3 deletions source/project_schema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// :copyright: Copyright (c) 2016 ftrack

import * as operation from "./operation";
import { Session } from "./session";
import { Data, QueryResponse } from "./types";
import * as operation from "./operation.js";
import { Session } from "./session.js";
import { Data, QueryResponse } from "./types.js";
/**
* Project schema namespace
* @namespace project_schema
Expand Down
14 changes: 7 additions & 7 deletions source/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import moment from "moment";
import loglevel from "loglevel";
import { v4 as uuidV4 } from "uuid";

import { EventHub } from "./event_hub";
import * as operation from "./operation";
import { EventHub } from "./event_hub.js";
import * as operation from "./operation.js";
import {
ServerPermissionDeniedError,
ServerValidationError,
ServerError,
AbortError,
CreateComponentError,
} from "./error";
import { SERVER_LOCATION_ID } from "./constant";
} from "./error.js";
import { SERVER_LOCATION_ID } from "./constant.js";

import normalizeString from "./util/normalize_string";
import normalizeString from "./util/normalize_string.js";
import type {
ActionResponse,
CallOptions,
Expand All @@ -35,8 +35,8 @@ import type {
SearchResponse,
SessionOptions,
UpdateResponse,
} from "./types";
import { convertToIsoString } from "./util/convert_to_iso_string";
} from "./types.js";
import { convertToIsoString } from "./util/convert_to_iso_string.js";

const logger = loglevel.getLogger("ftrack_api");

Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"module": "NodeNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
"isolatedModules": true,
Expand All @@ -17,5 +16,5 @@
"allowJs": false
},
"include": ["source"],
"exclude": ["source/socket.io-websocket-only.cjs"]
"exclude": ["source/socket.io-websocket-only.js"]
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineConfig({
loglevel: "log",
},
},
plugins: [commonjs({ include: "./source/socket.io-websocket-only.cjs" })],
plugins: [commonjs({ include: "./source/socket.io-websocket-only.js" })],
},
},
plugins: [dts()],
Expand Down
Loading