From 8c059f208a3a183e45abd76c2296e5c74ed378c9 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 1 May 2026 00:11:00 -0600 Subject: [PATCH] fix: emit section scripts alongside styles --- src/file-rules.js | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/file-rules.js b/src/file-rules.js index 0095e2c..acbd852 100644 --- a/src/file-rules.js +++ b/src/file-rules.js @@ -124,27 +124,21 @@ export const collectEntries = (sourceDir, config) => { const relativeSpecPath = normalizePath(relative(sourceRoot, absolutePath)); const isComponentSpec = relativeSpecPath.startsWith(`${config.paths.components}/`); - for (const extension of ['.scss', '.css', '.js']) { - const isStyle = styleExtensions.includes(extension); - - if (isComponentSpec && isStyle) { - continue; + if (!isComponentSpec) { + const styleEntry = findFirstExistingStyle( + sourceRoot, + normalizePath(relative(sourceRoot, join(componentDir, `${stem}.css`))) + ); + if (styleEntry) { + entries[normalizePath(styleEntry.relativePath)] = styleEntry.absolutePath; } + } - const entryPath = join(componentDir, `${stem}${extension}`); - if (!existsSync(entryPath)) { - continue; - } - - if (isComponentSpec && extension === '.js' && !hasRuntimeSelfRegistration(entryPath)) { - continue; - } - - const relativePath = normalizePath(relative(sourceRoot, entryPath)); - entries[extension === '.js' ? relativePath.slice(0, -extension.length) : relativePath] = entryPath; - - if (isStyle) { - break; + const scriptPath = join(componentDir, `${stem}.js`); + if (existsSync(scriptPath)) { + if (!isComponentSpec || hasRuntimeSelfRegistration(scriptPath)) { + const relativePath = normalizePath(relative(sourceRoot, scriptPath)); + entries[relativePath.slice(0, -extname(relativePath).length)] = scriptPath; } } });