Skip to content

js/tokens.cjs contains TypeScript type annotations, breaking @jspm/generator #176

Description

@bennypowers

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

  1. Install @rhds/tokens@3.0.2 and @jspm/generator
  2. 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:

  1. Rename the file to .cts if TypeScript is intentional
  2. Generate a separate .d.cts file for type declarations and keep .cjs as pure JavaScript
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions