Skip to content

Commit

Permalink
Updating to support possible ES modules and fix imports to work under…
Browse files Browse the repository at this point in the history
… Node.js 19 properly, #220
  • Loading branch information
peter-murray committed Apr 10, 2023
1 parent dd8d950 commit 30c4eb2
Show file tree
Hide file tree
Showing 64 changed files with 295 additions and 309 deletions.
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
169 changes: 71 additions & 98 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"email": "[email protected]"
}
],
"type": "module",
"main": "dist/cjs/index.js",
"types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js",
Expand All @@ -17,7 +18,7 @@
"require": "./dist/cjs/index.js"
},
"scripts": {
"test": "mocha -r ts-node/register \\\"src/**/*.test.ts\\\" \\\"src/**/*.test.js\\\"",
"test": "mocha -r ts-node/esm \\\"src/**/*.test.ts\\\" \\\"src/**/*.test.js\\\"",
"build": "tsc -p tsconfig.json && tsc -p tsconfig_esm.json",
"prepublishOnly": "npm run build"
},
Expand All @@ -32,13 +33,12 @@
"@peter-murray/hue-bridge-model": "^2.0.1",
"bottleneck": "^2.19.5",
"node-dns-sd": "^1.0.1",
"node-fetch": "^2.6.1"
"node-fetch": "^3.3.1"
},
"devDependencies": {
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"@types/node": "^18.15.11",
"@types/node-fetch": "^2.5.12",
"chai": "~4.3.4",
"mocha": "^9.1.3",
"ts-node": "^10.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/ApiError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HueError } from './HueError';
import { HueError } from './HueError.js';

export class ApiError extends Error {

Expand Down
32 changes: 16 additions & 16 deletions src/api/Api.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Remote } from './Remote';
import { Cache } from './Cache';
import { ConfigParameters, HueApiConfig } from './HueApiConfig';
import { RemoteApi } from './http/RemoteApi';
import { Transport } from './http/Transport';
import { Capabilities } from './Capabilities';
import { Configuration } from './Configuration';
import { Groups } from './Groups';
import { Lights } from './Lights';
import { ResourceLinks } from './ResourceLinks';
import { Rules } from './Rules';
import { Scenes } from './Scenes';
import { Schedules } from './Schedules';
import { Sensors } from './Sensors';
import { Users } from './Users';
import { Remote } from './Remote.js';
import { Cache } from './Cache.js';
import { ConfigParameters, HueApiConfig } from './HueApiConfig.js';
import { RemoteApi } from './http/RemoteApi.js';
import { Transport } from './http/Transport.js';
import { Capabilities } from './Capabilities.js';
import { Configuration } from './Configuration.js';
import { Groups } from './Groups.js';
import { Lights } from './Lights.js';
import { ResourceLinks } from './ResourceLinks.js';
import { Rules } from './Rules.js';
import { Scenes } from './Scenes.js';
import { Schedules } from './Schedules.js';
import { Sensors } from './Sensors.js';
import { Users } from './Users.js';

import { model } from '@peter-murray/hue-bridge-model';
import { HueApiRateLimits } from './HueApiRateLimits';
import { HueApiRateLimits } from './HueApiRateLimits.js';
type Light = model.Light

type ApiImplementationMap = {
Expand Down
2 changes: 1 addition & 1 deletion src/api/Cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { model } from '@peter-murray/hue-bridge-model';
import { LightIdPlaceholder } from './placeholders/LightIdPlaceholder';
import { LightIdPlaceholder } from './placeholders/LightIdPlaceholder.js';

const LIGHT_ID_PLACEHOLDER = new LightIdPlaceholder();

Expand Down
6 changes: 3 additions & 3 deletions src/api/Capabilities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiDefinition } from './http/ApiDefinition';
import { capabilitiesApi } from './http/endpoints/capabilities';
import { Api } from './Api';
import { ApiDefinition } from './http/ApiDefinition.js';
import { capabilitiesApi } from './http/endpoints/capabilities.js';
import { Api } from './Api.js';

export class Capabilities extends ApiDefinition {

Expand Down
6 changes: 3 additions & 3 deletions src/api/Configuration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { model } from '@peter-murray/hue-bridge-model';
import { configurationApi } from './http/endpoints/configuration';
import { ApiDefinition } from './http/ApiDefinition';
import { Api } from './Api';
import { configurationApi } from './http/endpoints/configuration.js';
import { ApiDefinition } from './http/ApiDefinition.js';
import { Api } from './Api.js';

export class Configuration extends ApiDefinition {

Expand Down
8 changes: 4 additions & 4 deletions src/api/Groups.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { model } from '@peter-murray/hue-bridge-model';
import { ApiDefinition } from './http/ApiDefinition';
import { groupsApi } from './http/endpoints/groups';
import { Api } from './Api';
import { HueRateLimiter } from './HueRateLimiter';
import { ApiDefinition } from './http/ApiDefinition.js';
import { groupsApi } from './http/endpoints/groups.js';
import { Api } from './Api.js';
import { HueRateLimiter } from './HueRateLimiter.js';

type GroupState = model.GroupState

Expand Down
Loading

0 comments on commit 30c4eb2

Please sign in to comment.