Description
The js/tokens.cjs file in @rhds/tokens@3.0.2 contains TypeScript type annotations (e.g., export type TokenName = ...) despite having a .cjs extension. This causes @jspm/generator to fail when trying to generate import maps for projects that depend on @rhds/tokens.
Error Message
JSPM encountered an error building @rhds/tokens@3.0.2: File 'js/tokens.cjs' contains TypeScript which is not supported for npm packages.
Steps to Reproduce
- Install
@rhds/tokens@3.0.2 and @jspm/generator
- Attempt to generate an import map that includes
@rhds/tokens/media.js or any other export
import { Generator } from '@jspm/generator';
const generator = new Generator({ env: ['production', 'browser', 'module'] });
await generator.install('@rhds/tokens/media.js');
Expected Behavior
The .cjs file should contain only CommonJS-compatible JavaScript without TypeScript syntax.
Actual Behavior
The file starts with:
export type TokenName = '--rh-animation-speed' | '--rh-animation-timing' | ...
This is valid TypeScript but not valid JavaScript/CommonJS.
Suggested Fix
Either:
- Rename the file to
.cts if TypeScript is intentional
- Generate a separate
.d.cts file for type declarations and keep .cjs as pure JavaScript
- Strip type annotations from the
.cjs output during build
Environment
@rhds/tokens: 3.0.2
@jspm/generator: 2.5.0
- Node.js: v24.6.0
Workaround
Currently working around this by using CDN URLs directly in import maps instead of letting JSPM resolve the package.
Description
The
js/tokens.cjsfile in@rhds/tokens@3.0.2contains TypeScript type annotations (e.g.,export type TokenName = ...) despite having a.cjsextension. This causes@jspm/generatorto fail when trying to generate import maps for projects that depend on@rhds/tokens.Error Message
Steps to Reproduce
@rhds/tokens@3.0.2and@jspm/generator@rhds/tokens/media.jsor any other exportExpected Behavior
The
.cjsfile should contain only CommonJS-compatible JavaScript without TypeScript syntax.Actual Behavior
The file starts with:
This is valid TypeScript but not valid JavaScript/CommonJS.
Suggested Fix
Either:
.ctsif TypeScript is intentional.d.ctsfile for type declarations and keep.cjsas pure JavaScript.cjsoutput during buildEnvironment
@rhds/tokens: 3.0.2@jspm/generator: 2.5.0Workaround
Currently working around this by using CDN URLs directly in import maps instead of letting JSPM resolve the package.