Skip to content

ESM barrel export broken in 0.4.0 - missing .js extensions in internal imports #195

@simonziegler

Description

@simonziegler

Description

The main barrel export (@material/material-color-utilities) fails to resolve in ESM environments due to missing .js extensions in internal import statements.

Error

error: [ERR_MODULE_NOT_FOUND] Cannot find module 
'.../node_modules/@material/material-color-utilities/dynamiccolor/dynamic_scheme' 
imported from '.../node_modules/@material/material-color-utilities/scheme/scheme_content.js'

Did you mean to import with the ".js" extension?

Reproduction

// Fails in 0.4.0, works in 0.3.0
import { DynamicScheme } from '@material/material-color-utilities';

Root Cause

Internal .js files use extensionless imports that don't resolve in strict ESM:

// scheme_content.js (0.4.0)
import { DynamicScheme } from '../dynamiccolor/dynamic_scheme';  // ❌ Missing .js

// Should be:
import { DynamicScheme } from '../dynamiccolor/dynamic_scheme.js';  // ✅

This pattern appears throughout the scheme/*.js files importing from dynamiccolor/.

Workaround

Direct file imports bypass the barrel and work:

import { Hct } from '@material/material-color-utilities/hct/hct.js';
import { Cam16 } from '@material/material-color-utilities/hct/cam16.js';

Environment

  • Version: 0.4.0 (regression from 0.3.0)
  • Build: TypeScript 5.9.3 (tsc) with moduleResolution: "bundler", bundled via Rollup 4.55.2
  • Runtime: Node.js 24.x with ESM ("type": "module")
  • Package manager: pnpm

AI Generation

I have been vibe coding updates to code I wrote a few months back using version 0.3.0. This issue has been identified by GitHub CoPilot using Clause 4.5 Opus, which I asked to open this issue for me. Aside from this section, Opus drafted the issue.

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