Builds are non-deterministic if multiple files share the same #1770
-
An edge case to be sure, but one I just encountered: if you have two files like More realistically, it's possible to imagine that someone might mount two directories to the same path... {
mount: {
a: '/x',
b: '/x'
}
} ...in which case collisions are handled deterministically (as far as I can tell), but it might be helpful to be notified of the collision. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I think this is indeed a bug. One idea to fix this was check whether // 0. Find all source files.
for (const [mountedDir, mountEntry] of Object.entries(config.mount)) {
+ const finalDestLocSet = new Set();
const allFiles = glob.sync(`**/*`, {
ignore: [...config.exclude, ...config.testOptions.files],
cwd: mountedDir,
@@ -424,6 +425,13 @@ export async function command(commandOptions: CommandOptions) {
const fileLoc = path.resolve(rawLocOnDisk); // this is necessary since glob.sync() returns paths with / on windows. path.resolve() will switch them to the native path separator.
const finalUrl = getUrlForFileMount({fileLoc, mountKey: mountedDir, mountEntry, config})!;
const finalDestLoc = path.join(buildDirectoryLoc, finalUrl);
+
+ if (finalDestLocSet.has(finalDestLoc)) {
+ logger.error(`there are multiple file build to the same ${finalDestLoc}`);
+ process.exit(1);
+ }
+ finalDestLocSet.add(finalDestLoc);
+ |
Beta Was this translation helpful? Give feedback.
-
We just ran into this problem again — a single directory had an It occurred to me that there's no reason these files need to clash. Instead of replacing all non-js extensions with js, why not just append the extension? So |
Beta Was this translation helpful? Give feedback.
I think this is indeed a bug.
One idea to fix this was check whether
finalDestLoc
already used in0. Find all source files.
phase before building them.