#5214·lit

ResizeController cannot be imported when using pnpm and setting hoist = false in .npmrc

Author: MoreRustLessAccessCreated Jan 29, 2026Updated Aug 15, 2026

Which package(s) are affected?

Observers (@lit-labs/observers)

Description

I'm trying to use ResizeController in a project that has hoisting disabled, however this is currently not working due to import errors. Turning hoisting back on makes this work fine.

Error:

> [email protected] build C:\Users\<username here>\AppData\Roaming\projects\vite-hoist-repro
> vite build

vite v7.3.1 building client environment for production...
✓ 4 modules transformed.
✗ Build failed in 171ms
error during build:
[vite]: Rollup failed to resolve import "lit-html/async-directive.js" from "C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/@[email protected]/node_modules/@lit-labs/observers/resize-controller.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at viteLog (file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/config.js:33635:57)
    at onRollupLog (file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/config.js:33665:7)
    at onLog (file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/config.js:33467:4)
    at file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20955:32
    at Object.logger [as onLog] (file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22942:9)
    at ModuleLoader.handleInvalidResolvedId (file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21686:26)
    at file:///C:/Users/<username here>/AppData/Roaming/projects/vite-hoist-repro/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21644:26
 ELIFECYCLE  Command failed with exit code 1.

I assume (haven't checked) that this is caused by ResizeObserver importing from lit-html while only declaring it as a dev-dependency

Reproduction

git clone https://github.com/MoreRustLessAccess/lit-hoist-repro
cd lit-hoist-repro
pnpm i
pnpm run build

Note that pnpm is required, npm does not trigger the same bug

Workaround

I have not found a workaround

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

Broken in version observers v2.1.0

Browser/OS/Node environment

Node version: v22.14.0 Pnpm: v9.15.4 Npm: v10.9.0 OS: Windows 11