From 95acf5622f6c759e1c1480d4c29beccb6b70f7b5 Mon Sep 17 00:00:00 2001 From: Justin Murray Date: Tue, 4 Aug 2026 15:35:24 -0400 Subject: [PATCH] fix: add .js to relative imports so the ESM build loads in node Verifying the published 0.4.0-pre.3 against a pristine monaco 0.56 turned up a bug that predates this branch. Importing the package as native ESM throws: Error [ERR_MODULE_NOT_FOUND]: Cannot find module .../lib/esm/pgsql/pgsql imported from .../lib/esm/timescale/timescale.js `src/timescale/timescale.ts` imported `../pgsql/pgsql` without an extension. TypeScript emits relative specifiers verbatim, so the ESM output carried an extensionless import, which Node cannot resolve -- and our exports map points the `import` condition straight at that output. Reproduced identically on 0.3.2, so every ESM consumer without a bundler to paper over it has been broken; the bundler-based consumers we happen to have are why nobody noticed. `index.ts` already used `.js` throughout, so this makes the rest of the package consistent with it. The `../types` imports in the contribution files get the same treatment: those are `import type` and erase at compile time, so they were never part of the bug, but leaving them inconsistent invites the next one. Tried enforcing this with the compiler instead of by hand. `module: node16` on the ESM build does flag extensionless relative imports, but only when the package is `"type": "module"` -- which this is not, so it silently emitted CommonJS into lib/esm instead. Reverted; the linter is a better home for this rule than a tsconfig that changes the output format as a side effect. Verified against a real registry install of the prerelease with the rebuilt lib dropped in: ESM now loads (pgsql 657 builtins, timescale 825, correctly layering), CJS is unchanged and still emits CommonJS, and a consumer typechecks under `moduleResolution: bundler`. --- src/bigquery/bigquery.contribution.ts | 2 +- src/clickhouse/clickhouse.contribution.ts | 2 +- src/pgsql/pgsql.contribution.ts | 2 +- src/presto/presto.contribution.ts | 2 +- src/snowflake/snowflake.contribution.ts | 2 +- src/timescale/timescale.contribution.ts | 2 +- src/timescale/timescale.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bigquery/bigquery.contribution.ts b/src/bigquery/bigquery.contribution.ts index 0a18983..122aa2c 100644 --- a/src/bigquery/bigquery.contribution.ts +++ b/src/bigquery/bigquery.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const bigqueryLanguageDefinition: LanguageDefinition = { aliases: ['BigQuery', 'bigquery'], diff --git a/src/clickhouse/clickhouse.contribution.ts b/src/clickhouse/clickhouse.contribution.ts index aefb5c2..371ac01 100644 --- a/src/clickhouse/clickhouse.contribution.ts +++ b/src/clickhouse/clickhouse.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const clickhouseLanguageDefinition: LanguageDefinition = { aliases: ['Clickhouse', 'ClickHouse'], diff --git a/src/pgsql/pgsql.contribution.ts b/src/pgsql/pgsql.contribution.ts index 8644bc5..116d0db 100644 --- a/src/pgsql/pgsql.contribution.ts +++ b/src/pgsql/pgsql.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const pgsqlLanguageDefinition: LanguageDefinition = { aliases: ['PostgreSQL', 'postgres', 'pg', 'postgre'], diff --git a/src/presto/presto.contribution.ts b/src/presto/presto.contribution.ts index f836009..ed5cc16 100644 --- a/src/presto/presto.contribution.ts +++ b/src/presto/presto.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const prestoLanguageDefinition: LanguageDefinition = { aliases: ['Presto'], diff --git a/src/snowflake/snowflake.contribution.ts b/src/snowflake/snowflake.contribution.ts index 62f774d..8a7be4b 100644 --- a/src/snowflake/snowflake.contribution.ts +++ b/src/snowflake/snowflake.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const snowflakeLanguageDefinition: LanguageDefinition = { aliases: ['Snowflake'], diff --git a/src/timescale/timescale.contribution.ts b/src/timescale/timescale.contribution.ts index 27a9c2e..b843599 100644 --- a/src/timescale/timescale.contribution.ts +++ b/src/timescale/timescale.contribution.ts @@ -1,4 +1,4 @@ -import type { LanguageDefinition } from '../types'; +import type { LanguageDefinition } from '../types.js'; export const timescaleLanguageDefinition: LanguageDefinition = { aliases: ['Timescale'], diff --git a/src/timescale/timescale.ts b/src/timescale/timescale.ts index 4ec236d..8ad3c17 100644 --- a/src/timescale/timescale.ts +++ b/src/timescale/timescale.ts @@ -2,7 +2,7 @@ import cloneDeep from 'lodash.clonedeep'; -import { conf as oldConf, language as oldLanguage } from '../pgsql/pgsql'; +import { conf as oldConf, language as oldLanguage } from '../pgsql/pgsql.js'; const conf = cloneDeep(oldConf); const language = cloneDeep(oldLanguage);