Uncaught ReferenceError: exports is not defined

Pulled Sage 10 from commit c6a21c4, only only added @roots/bud-typescript and created tsconfig.json with the following contents:

{
  "extends": "@roots/bud-typescript/tsconfig/tsconfig.json"
}

This results in the following error on front-end console:

Uncaught ReferenceError: exports is not defined
    at ./scripts/app.js (app.49df6a.js:1:227)
    at t (demo/:546:127)
    at e (app.49df6a.js:1:345)
    at app.49df6a.js:1:354
    at r (demo/:546:854)
    at app.49df6a.js:1:86
./scripts/app.js @ app.49df6a.js:1
t @ demo/:546
e @ app.49df6a.js:1
(anonymous) @ app.49df6a.js:1
r @ demo/:546
(anonymous) @ app.49df6a.js:1

…and the following in block editor console:

Uncaught ReferenceError: exports is not defined
    at ./scripts/editor.js (editor.ad595a.js:1:1150)
    at t (post.php?post=7&action=edit:2059:127)
    at r (editor.ad595a.js:1:1656)
    at editor.ad595a.js:1:1665
    at r (post.php?post=7&action=edit:2059:854)
    at editor.ad595a.js:1:73
./scripts/editor.js @ editor.ad595a.js:1
t @ post.php?post=7&action=edit:2059
r @ editor.ad595a.js:1
(anonymous) @ editor.ad595a.js:1
r @ post.php?post=7&action=edit:2059
(anonymous) @ editor.ad595a.js:1

I’ve used @roots/bud-typescript in many other projects so far. This started happening yesterday.

node v20.16.0
yarn v1.22.22

I’m out of ideas on how to troubleshoot this. Any suggestions? Anyone else having this problem?

1 Like

I had the same error. My workaround was to specify

    "module": "esnext",
    "moduleResolution": "node",

in my tsconfig.json.
These settings were supposed to already be imported from

"extends": "@roots/bud-typescript/tsconfig/tsconfig.json"

so i’m not sure why they wouldn’t work. They may be overridden by another roots package ?

1 Like