From a03d3c2e31c686bec10c7c9dafaa8983237092ae Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Fri, 26 Sep 2025 23:15:54 +0000 Subject: [PATCH] Fix css asset resolution as part of package resolution. --- src/lib/build/esmPlugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/build/esmPlugin.ts b/src/lib/build/esmPlugin.ts index a7b8d5a2..78c77604 100644 --- a/src/lib/build/esmPlugin.ts +++ b/src/lib/build/esmPlugin.ts @@ -111,7 +111,11 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin { // Handle relative or absolute imports inside esm.sh modules build.onResolve({ filter: /.*/, namespace: "esm" }, async (args) => { // Check if this is a bare package import (not a relative path) - if (!args.path.startsWith("./") && !args.path.startsWith("../") && !args.path.startsWith("/")) { + // Note: CSS assets and some other relative imports don't use ./ prefix + const isLikelyAsset = /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|ico|webp|avif)$/i.test(args.path); + const isRelativePath = args.path.startsWith("./") || args.path.startsWith("../") || args.path.startsWith("/") || isLikelyAsset; + + if (!isRelativePath) { try { // This is a bare import like "@emotion/is-prop-valid" - treat it as a new package const packageName = args.path.startsWith("@")