Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions patches/glimmer-scoped-css@0.8.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git a/dist/ast-transform-8c8ef165.js b/dist/ast-transform-8c8ef165.js
index 066d5bc5f9e350d855d7d48ae56f47b4e33907bc..3483e529a009cbe4b6019ada0c332411b660595a 100644
--- a/dist/ast-transform-8c8ef165.js
+++ b/dist/ast-transform-8c8ef165.js
@@ -164,8 +164,41 @@ function decodeCSS(encodedCSSString) {
return new TextDecoder().decode(Uint8Array.from(binString, m => m.codePointAt(0)));
}

+// The scope prefix must be the same for the same source on every machine:
+// prerendered HTML carries the prefixes of the build that rendered it, and a
+// build at another path must still style it. A file on disk is identified by
+// its path relative to the working directory of the build. Anything else keeps
+// its filename, including the synthetic paths a realm transpiles under
+// (`/spec.gts`), which do not exist on disk and are already stable. Both
+// paths are resolved through symlinks first: `process.cwd()` is always
+// resolved, and a filename reached through a symlink would otherwise give a
+// path up to the root and back down, which holds the absolute path again.
+function cwdRelativeId(filename) {
+ let fs;
+ try {
+ fs = require('fs');
+ } catch {
+ return undefined;
+ }
+ if (
+ !fs ||
+ typeof fs.existsSync !== 'function' ||
+ typeof fs.realpathSync !== 'function' ||
+ typeof process === 'undefined' ||
+ typeof process.cwd !== 'function' ||
+ typeof filename !== 'string' ||
+ !path.isAbsolute(filename) ||
+ !fs.existsSync(filename)
+ ) {
+ return undefined;
+ }
+ return path
+ .relative(fs.realpathSync(process.cwd()), fs.realpathSync(filename))
+ .split(path.sep)
+ .join('/');
+}
function uniqueIdentifier(filename) {
- return superFastMd5.md5(filename).slice(0, 10);
+ return superFastMd5.md5(cwdRelativeId(filename) ?? filename).slice(0, 10);
}
function generateScopedCSSPlugin(options) {
return env => {
13 changes: 7 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ patchedDependencies:
matrix-js-sdk@38.3.0: patches/matrix-js-sdk@38.3.0.patch
ember-source: patches/ember-source.patch
object-inspect: patches/object-inspect.patch
glimmer-scoped-css@0.8.1: patches/glimmer-scoped-css@0.8.1.patch
allowBuilds:
"@percy/core": true
"@vscode/vsce-sign": true
Expand Down
Loading