Repository navigation
Scope by the path relative to the build's working directory - #56
Conversation
|
[Claude Code 🤖] The red Tests and Floating Dependencies checks both come from one test-app test, |
|
[Claude Code 🤖] Root cause of the red |
…bute everywhere The scope prefix was the md5 of the absolute file path, so builds of the same source at different paths gave different data-scopedcss attributes. HTML prerendered by one build then did not match the CSS of another. A file inside a package is now identified by its package name and its path inside the package. A filename that is not a file on disk is used as given, so callers that pass synthetic paths get the same prefix as before. Adds node:test unit tests for uniqueIdentifier, run by `pnpm test`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RhwZUafCP38ur35n87R7BW
fdba626 to
d3b8312
Compare
The first hash of the scope attribute is the md5 of the file's path relative to process.cwd(), with both paths resolved through symlinks, in place of the nearest named package and the path inside it. A filename that does not exist on disk is still used as given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RhwZUafCP38ur35n87R7BW
Background and Goal
The first hash in a
data-scopedcss-*attribute was the md5 of the component file's absolute path. Two builds of the same source at different paths, such as two CI runners or two developers' checkouts, therefore gave different attributes. In an app that prerenders HTML in one build and serves it with another build's CSS, the scoped rules then match nothing, and components render unstyled.This identifies a file on disk by its path relative to the build's working directory (
process.cwd()). Two checkouts that build from the same directory inside the checkout then give the same attribute. A filename that is not a file on disk (for example a synthetic module path a transpiler passes) is used as given, so those callers get the same prefix as before.Key decisions and non-obvious mechanics
process.cwd()is always a real path. A filename reached through a symlink would otherwise give a relative path up to the root and back down, which holds the absolute path again.enhancement.glimmer-scoped-css/tests/unique-identifier.test.cjsruns withnode:testagainst the builtdist, and the rootpnpm testruns it before the test-app. With the old behaviour restored, the two working-directory tests fail.pnpm patchin Scope glimmer-scoped-css styles by package-relative path boxel#6594. Its CI builds the host at two runner paths, and both builds give the same 259 CSS file names and the same 456 scope prefixes.🤖 Generated with Claude Code
https://claude.ai/code/session_01RhwZUafCP38ur35n87R7BW