Skip to content

Commit e4afd97

Browse files
Fix non-deterministic build output in npm run build-module (#415)
- Use relative entry paths instead of absolute temp directory paths - Set webpack context to inputPath for consistent module resolution - Configure deterministic module and chunk IDs - Disable file system timestamps in webpack snapshot - Use deterministic hash function for output This resolves issue #374 where builds were generating different output each time due to Broccoli's temporary directory paths being embedded in webpack bundles. The fix ensures reproducible builds across different machines and platforms. Verified with multiple builds producing identical SHA256 checksums. Fixes #374
1 parent 6fecf9a commit e4afd97

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

broccoli/modules/broccoli-webpack.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ module.exports = class BroccoliWebpack extends Plugin {
3939
}
4040

4141
bundles.forEach((bundle) => {
42-
entries[bundle] = path.join(inputPath, bundle);
42+
// Use relative paths from inputPath to make builds deterministic
43+
entries[bundle] = `./${bundle}`;
4344
});
4445

4546
return new Promise((resolve, reject) => {
@@ -49,10 +50,12 @@ module.exports = class BroccoliWebpack extends Plugin {
4950
mode: env.DEVELOPMENT ? "development" : "production",
5051
entry: entries,
5152
devtool: false,
53+
context: inputPath, // Use input path as context for consistency
5254
output: {
5355
filename: "[name]",
5456
path: outputPath,
5557
webassemblyModuleFilename: "star.wasm",
58+
hashFunction: 'xxhash64', // Use deterministic hash function
5659
},
5760
experiments: {
5861
syncWebAssembly: true,
@@ -64,11 +67,22 @@ module.exports = class BroccoliWebpack extends Plugin {
6467
fs: false,
6568
path: require.resolve("path-browserify"),
6669
},
70+
6771
},
6872
externals: this.builderConfig.globalDeps,
6973
optimization: {
7074
minimize: !!env.PROD,
75+
moduleIds: 'deterministic', // Use deterministic module IDs
76+
chunkIds: 'deterministic', // Ensure deterministic chunk IDs
77+
usedExports: false, // Disable tree shaking for deterministic builds
78+
sideEffects: false, // Disable side effects detection for deterministic builds
79+
},
80+
snapshot: {
81+
// Disable file system timestamps for deterministic builds
82+
managedPaths: [],
83+
immutablePaths: [],
7184
},
85+
7286
});
7387

7488
compiler.run((error, stats) => {

0 commit comments

Comments
 (0)