Skip to content

bug: ERR_PACKAGE_PATH_NOT_EXPORTED when upgrading from @stencil/sass 3.2 → 3.3 (CJS require() broken) #706

Description

@danyball

Prerequisites

Stencil Sass Version

3.3.0, 3.3.1

Stencil Version

4.43.5

Current Behavior

Upgrading @stencil/sass from 3.2.x to 3.3.x causes Stencil's build process to crash immediately with:
[ ERROR ] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in
/…/node_modules/@stencil/sass/package.json
at exportsNotFound (node:internal/modules/esm/resolve:313:10)
at packageExportsResolve (node:internal/modules/esm/resolve:603:13)
at resolveExports (node:internal/modules/cjs/loader:650:36)
at Function._findPath (node:internal/modules/cjs/loader:717:31)

Expected Behavior

No error and build finishes

Steps to Reproduce

npm install @stencil/sass@3.3.1
npx stencil build

Code Reproduction URL

notyet

Additional Information

AI gave me this analysis, so I am not pretty sure if this is really the root cause. But the error is real :)

Root cause
In 3.3.x, dist/index.js was converted to a pure ESM module (it starts with import { render } from 'sass-embedded'), but the package.json exports field only declares an "import" condition and no "require" condition:
@stencil/sass 3.3.1 package.json (broken):
{
"main": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js" // ← ESM only, no "require"
}
}
}
@stencil/sass 3.2.3 package.json (working):
{
"main": "./dist/index.js"
// no "exports" field → Node.js falls back to "main"
}

Node.js gives exports strict precedence over main when the field is present. Since there is no "require" condition in 3.3.x, any CJS require('@stencil/sass') call throws ERR_PACKAGE_PATH_NOT_EXPORTED.

@stencil/core compiles and loads stencil.config.ts via CJS require(). Because the Stencil config contains import { sass } from "@stencil/sass", this CJS resolution fails at startup.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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