Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ and the W&B community.
</Card>
<Card title="W&B Weave" href="/support/weave" arrow="true" icon="/icons/cropped-weave.svg">
{/* AUTO-GENERATED: counts */}
18 articles &middot; 11 tags
19 articles &middot; 12 tags
{/* END AUTO-GENERATED: counts */}
</Card>
<Card title="Serverless Inference" href="/support/inference" arrow="true" icon="/icons/cropped-inference.svg">
Expand Down
3 changes: 3 additions & 0 deletions support/weave.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ template: "docengine-site/templates/support_product_index.mdx.j2"
<Card title="Tracing" href="/support/weave/tags/tracing" arrow="true">
2 articles
</Card>
<Card title="TypeScript" href="/support/weave/tags/typescript" arrow="true">
1 article
</Card>
<Card title="UI Rendering" href="/support/weave/tags/ui-rendering" arrow="true">
2 articles
</Card>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 */}
<Badge stroke shape="pill" color="orange" size="md">[TypeScript](/support/weave/tags/typescript)</Badge>
{/* END AUTO-GENERATED: tab badges */}
10 changes: 10 additions & 0 deletions support/weave/tags/typescript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "TypeScript"
tag: "1"
generator: "knowledgebase-nav"
template: "docengine-site/templates/support_tag.mdx.j2"
---

<Card title="Why does my Weave TypeScript build fail for CommonJS format?" href="/support/weave/articles/typescript-build-fails-after-commonjs-setup" arrow="true" horizontal>
TS1295 and TS1287: ECMAScript imports and exports cannot be written in a CommonJS file If your tsconfig.json file sets " ...
</Card>
Loading