You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnpm run update-tokens (and every per-file variant: update-tokens:foundations, update-tokens:color-static, update-tokens:color-dynamic, update-tokens:spacing-primitives, update-tokens:spacing-modes, plus the update-figma:* counterparts) fails on import before doing any Figma work, with:
Error: Calling `require` for "fs" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.
at .../packages/eds-tokens-sync/dist/color-BXdZrUk8.js:11:8
The script entrypoints do import 'dotenv/config'. Rolldown bundles dotenv into the output chunk. dotenv's source calls require(\"fs\"), require(\"path\"), require(\"os\").
Rolldown emits a runtime helper that uses require() if it exists at runtime, otherwise throws. The package is \"type\": \"module\", so the bundle runs as pure ESM — require is not in scope. The helper throws on the first require(\"fs\") call.
Why this slipped through
update-tokens is rarely run — only when designers change Figma variables. No sync has been attempted on main since the Vite 8 bump on April 8.
Reproduction
cd packages/eds-tokens
pnpm run update-tokens:spacing-modes
(also fails for any other update-tokens:* / update-figma:* script)
Suggested fix
In packages/eds-tokens-sync/vite.config.ts, externalize Node built-ins and dotenv so they aren't bundled into the ESM output:
Alternatively, inject createRequire via a banner so the runtime helper resolves correctly. Externalizing is the cleaner option since the consumers are Node CLI scripts.
Impact
Cannot pull token changes from Figma into the repo.
Cannot push token changes from the repo back into Figma.
Description
pnpm run update-tokens(and every per-file variant:update-tokens:foundations,update-tokens:color-static,update-tokens:color-dynamic,update-tokens:spacing-primitives,update-tokens:spacing-modes, plus theupdate-figma:*counterparts) fails on import before doing any Figma work, with:Reproduces against a clean working tree on
main.Root cause
rollupOptions→rolldownOptionsinpackages/eds-tokens-sync/vite.config.ts. The config externalizes onlyfsandpath.import 'dotenv/config'. Rolldown bundles dotenv into the output chunk. dotenv's source callsrequire(\"fs\"),require(\"path\"),require(\"os\").require()if it exists at runtime, otherwise throws. The package is\"type\": \"module\", so the bundle runs as pure ESM —requireis not in scope. The helper throws on the firstrequire(\"fs\")call.Why this slipped through
update-tokensis rarely run — only when designers change Figma variables. No sync has been attempted onmainsince the Vite 8 bump on April 8.Reproduction
(also fails for any other
update-tokens:*/update-figma:*script)Suggested fix
In
packages/eds-tokens-sync/vite.config.ts, externalize Node built-ins anddotenvso they aren't bundled into the ESM output:Alternatively, inject
createRequirevia a banner so the runtime helper resolves correctly. Externalizing is the cleaner option since the consumers are Node CLI scripts.Impact