Skip to content

Commit efbc16f

Browse files
authored
fix: TypeScript ESM compatibility fixes for moduleResolution: NodeNext (#107)
fix: output proper esm
1 parent 9b161ba commit efbc16f

File tree

11 files changed

+509
-427
lines changed

11 files changed

+509
-427
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lib/
2-
socket.io-websocket-only.cjs
2+
socket.io-websocket-only.js
33
doc/resource
44
coverage/
55
build/

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dist"
2424
],
2525
"devDependencies": {
26-
"@rollup/plugin-commonjs": "^24.0.1",
26+
"@rollup/plugin-commonjs": "^25.0.0",
2727
"@types/uuid": "^9.0.0",
2828
"cross-fetch": "^3.1.5",
2929
"dayjs": "^1.11.7",
@@ -33,10 +33,10 @@
3333
"lint-staged": "^13.1.0",
3434
"msw": "^1.0.0",
3535
"prettier": "^2.8.3",
36-
"typescript": "^4.9.5",
37-
"vite": "^4.1.1",
38-
"vite-plugin-dts": "^1.7.2",
39-
"vitest": "^0.28.4"
36+
"typescript": "^5.0.4",
37+
"vite": "^4.3.8",
38+
"vite-plugin-dts": "^2.3.0",
39+
"vitest": "^0.31.1"
4040
},
4141
"repository": {
4242
"type": "git",

source/event_hub.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// :copyright: Copyright (c) 2016 ftrack
22
import { v4 as uuidV4 } from "uuid";
33
import loglevel from "loglevel";
4-
import io, { SocketIO } from "./socket.io-websocket-only.cjs";
5-
import { Event } from "./event";
4+
import * as io from "./socket.io-websocket-only.js";
5+
import { Event } from "./event.js";
66
import {
77
EventServerConnectionTimeoutError,
88
EventServerReplyTimeoutError,
99
EventServerPublishError,
1010
NotUniqueError,
11-
} from "./error";
12-
import { Data } from "./types";
11+
} from "./error.js";
12+
import { Data } from "./types.js";
1313

1414
interface BaseActionData {
1515
selection: Array<{
@@ -132,7 +132,7 @@ export class EventHub {
132132
};
133133
private _unsentEvents: ConnectionCallback[];
134134
private _subscribers: Subscriber[];
135-
private _socketIo: SocketIO | null;
135+
private _socketIo: io.SocketIO | null;
136136

137137
/**
138138
* Construct EventHub instance with API credentials.

source/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// :copyright: Copyright (c) 2016 ftrack
22

3-
export * from "./event";
4-
export * from "./event_hub";
5-
export * from "./session";
6-
export * from "./types";
3+
export * from "./event.js";
4+
export * from "./event_hub.js";
5+
export * from "./session.js";
6+
export * from "./types.js";
77

8-
export * as error from "./error";
9-
export * as operation from "./operation";
10-
export * as projectSchema from "./project_schema";
8+
export * as error from "./error.js";
9+
export * as operation from "./operation.js";
10+
export * as projectSchema from "./project_schema.js";
1111

12-
export { SERVER_LOCATION_ID } from "./constant";
12+
export { SERVER_LOCATION_ID } from "./constant.js";

source/project_schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// :copyright: Copyright (c) 2016 ftrack
22

3-
import * as operation from "./operation";
4-
import { Session } from "./session";
5-
import { Data, QueryResponse } from "./types";
3+
import * as operation from "./operation.js";
4+
import { Session } from "./session.js";
5+
import { Data, QueryResponse } from "./types.js";
66
/**
77
* Project schema namespace
88
* @namespace project_schema

source/session.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import moment from "moment";
33
import loglevel from "loglevel";
44
import { v4 as uuidV4 } from "uuid";
55

6-
import { EventHub } from "./event_hub";
7-
import * as operation from "./operation";
6+
import { EventHub } from "./event_hub.js";
7+
import * as operation from "./operation.js";
88
import {
99
ServerPermissionDeniedError,
1010
ServerValidationError,
1111
ServerError,
1212
AbortError,
1313
CreateComponentError,
14-
} from "./error";
15-
import { SERVER_LOCATION_ID } from "./constant";
14+
} from "./error.js";
15+
import { SERVER_LOCATION_ID } from "./constant.js";
1616

17-
import normalizeString from "./util/normalize_string";
17+
import normalizeString from "./util/normalize_string.js";
1818
import type {
1919
ActionResponse,
2020
CallOptions,
@@ -35,8 +35,8 @@ import type {
3535
SearchResponse,
3636
SessionOptions,
3737
UpdateResponse,
38-
} from "./types";
39-
import { convertToIsoString } from "./util/convert_to_iso_string";
38+
} from "./types.js";
39+
import { convertToIsoString } from "./util/convert_to_iso_string.js";
4040

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

File renamed without changes.
File renamed without changes.

tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"compilerOptions": {
33
"target": "ESNext",
44
"useDefineForClassFields": true,
5-
"module": "ESNext",
5+
"module": "NodeNext",
66
"lib": ["ESNext", "DOM"],
7-
"moduleResolution": "Node",
87
"strict": true,
98
"resolveJsonModule": true,
109
"isolatedModules": true,
@@ -17,5 +16,5 @@
1716
"allowJs": false
1817
},
1918
"include": ["source"],
20-
"exclude": ["source/socket.io-websocket-only.cjs"]
19+
"exclude": ["source/socket.io-websocket-only.js"]
2120
}

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default defineConfig({
3030
loglevel: "log",
3131
},
3232
},
33-
plugins: [commonjs({ include: "./source/socket.io-websocket-only.cjs" })],
33+
plugins: [commonjs({ include: "./source/socket.io-websocket-only.js" })],
3434
},
3535
},
3636
plugins: [dts()],

0 commit comments

Comments
 (0)