diff --git a/packages/jsapi-nodejs/README.md b/packages/jsapi-nodejs/README.md index 5a3b6b4429..c45e23f996 100644 --- a/packages/jsapi-nodejs/README.md +++ b/packages/jsapi-nodejs/README.md @@ -1,4 +1,4 @@ -# @deephaven/jsapi-components +# @deephaven/jsapi-nodejs Deephaven utils for consuming Jsapi from a server from a nodejs app. It can optionally convert the server module format from `ESM` -> `CJS` or `CJS` -> `ESM` diff --git a/packages/jsapi-nodejs/src/index.ts b/packages/jsapi-nodejs/src/index.ts index 951e56337b..a3ec855315 100644 --- a/packages/jsapi-nodejs/src/index.ts +++ b/packages/jsapi-nodejs/src/index.ts @@ -1,5 +1,5 @@ -export * from './errorUtils'; -export * from './fsUtils'; -export * from './loaderUtils'; -export * from './polyfillWs'; -export * from './serverUtils'; +export * from './errorUtils.js'; +export * from './fsUtils.js'; +export * from './loaderUtils.js'; +export * from './polyfillWs.js'; +export * from './serverUtils.js'; diff --git a/packages/jsapi-nodejs/src/loaderUtils.ts b/packages/jsapi-nodejs/src/loaderUtils.ts index 6de081c326..f3964f0b23 100644 --- a/packages/jsapi-nodejs/src/loaderUtils.ts +++ b/packages/jsapi-nodejs/src/loaderUtils.ts @@ -2,9 +2,9 @@ import fs from 'node:fs'; import path from 'node:path'; import esbuild from 'esbuild'; -import { downloadFromURL, urlToDirectoryName } from './serverUtils'; -import { polyfillWs } from './polyfillWs'; -import { ensureDirectoriesExist, getDownloadPaths } from './fsUtils'; +import { downloadFromURL, urlToDirectoryName } from './serverUtils.js'; +import { polyfillWs } from './polyfillWs.js'; +import { ensureDirectoriesExist, getDownloadPaths } from './fsUtils.js'; type NonEmptyArray = [T, ...T[]]; diff --git a/packages/jsapi-nodejs/src/serverUtils.ts b/packages/jsapi-nodejs/src/serverUtils.ts index e40310dd69..8aae9c2bc3 100644 --- a/packages/jsapi-nodejs/src/serverUtils.ts +++ b/packages/jsapi-nodejs/src/serverUtils.ts @@ -1,6 +1,6 @@ import * as http from 'node:http'; import * as https from 'node:https'; -import { hasErrorCode, isAggregateError } from './errorUtils'; +import { hasErrorCode, isAggregateError } from './errorUtils.js'; export const SERVER_STATUS_CHECK_TIMEOUT = 3000; diff --git a/packages/jsapi-nodejs/tsconfig.json b/packages/jsapi-nodejs/tsconfig.json index 8c183dff36..e064ffa6b2 100644 --- a/packages/jsapi-nodejs/tsconfig.json +++ b/packages/jsapi-nodejs/tsconfig.json @@ -1,6 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + // NodeNext is the recommended module setting for Node.js v12 or later. This + // allows CommonJS and ESM consumers to use this package. + "module": "NodeNext", + // This is the required setting when `module` is set to `NodeNext`. One side + // effect of this setting is that relative imports require explicit `.js` + // extensions. + "moduleResolution": "NodeNext", "rootDir": "src/", "outDir": "dist/" }, diff --git a/tsconfig.json b/tsconfig.json index b20df71bd2..81f179fe39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,12 @@ "excludeDirectories": ["**/node_modules", "**/dist"] }, "references": [ + // `npm run types` relies on project references to build types. All packages + // must be included in the reference tree somewhere. Top-level packages need + // to be included here, and their respective `tsconfig.json` files should + // reference their dependencies. { "path": "./packages/code-studio" }, - { "path": "./packages/embed-widget" } + { "path": "./packages/embed-widget" }, + { "path": "./packages/jsapi-nodejs" } ] }