diff --git a/support.mdx b/support.mdx index 46b219037f..811d6e9419 100644 --- a/support.mdx +++ b/support.mdx @@ -52,7 +52,7 @@ and the W&B community. {/* AUTO-GENERATED: counts */} - 18 articles · 11 tags + 19 articles · 12 tags {/* END AUTO-GENERATED: counts */} diff --git a/support/weave.mdx b/support/weave.mdx index 8a0a17c5af..da0991fb47 100644 --- a/support/weave.mdx +++ b/support/weave.mdx @@ -33,6 +33,9 @@ template: "docengine-site/templates/support_product_index.mdx.j2" 2 articles + + 1 article + 2 articles diff --git a/support/weave/articles/typescript-build-fails-after-commonjs-setup.mdx b/support/weave/articles/typescript-build-fails-after-commonjs-setup.mdx new file mode 100644 index 0000000000..ecc07035bb --- /dev/null +++ b/support/weave/articles/typescript-build-fails-after-commonjs-setup.mdx @@ -0,0 +1,32 @@ +--- +title: "Why does my Weave TypeScript build fail for CommonJS format?" +keywords: ["TypeScript"] +--- + +## `TS1295` and `TS1287`: ECMAScript imports and exports cannot be written in a CommonJS file + +If your `tsconfig.json` file sets `"verbatimModuleSyntax": true`, compiling a W&B Weave CommonJS project (per the [TypeScript SDK integration guide](/weave/guides/integrations/js)) fails with: + +```text +error TS1295: ECMAScript imports and exports cannot be written in a CommonJS file under 'verbatimModuleSyntax'. +error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. +``` + +The setting defaults to `false`, which the TypeScript SDK integration guide assumes. + +Set the `verbatimModuleSyntax` field to `false` alongside your CommonJS `module` setting: + +```json lines +{ + "compilerOptions": { + "module": "CommonJS", + "verbatimModuleSyntax": false + } +} +``` + +`"verbatimModuleSyntax": false` allows ESM-style `import`/`export` syntax in your source files while TypeScript still emits CommonJS output. For details, see [TypeScript - Verbatim Module Syntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax). + +{/* AUTO-GENERATED: tab badges */} +[TypeScript](/support/weave/tags/typescript) +{/* END AUTO-GENERATED: tab badges */} \ No newline at end of file diff --git a/support/weave/tags/typescript.mdx b/support/weave/tags/typescript.mdx new file mode 100644 index 0000000000..46adfe5540 --- /dev/null +++ b/support/weave/tags/typescript.mdx @@ -0,0 +1,10 @@ +--- +title: "TypeScript" +tag: "1" +generator: "knowledgebase-nav" +template: "docengine-site/templates/support_tag.mdx.j2" +--- + + + TS1295 and TS1287: ECMAScript imports and exports cannot be written in a CommonJS file If your tsconfig.json file sets " ... +