@@ -15,7 +15,7 @@ import path from "path";
1515import { hideBin } from "yargs/helpers" ;
1616import { PackageBuildError } from "./PackageBuildError" ;
1717import { queueMetaWrite } from "./writeMetaQueue" ;
18- import { writeDistBuildHash } from "./distBuildHash" ;
18+ import { writeDistBuildHash , isExperimentalBuildCacheEnabled } from "./distBuildHash" ;
1919
2020const argv = yargs ( hideBin ( process . argv ) ) . parse ( ) ;
2121
@@ -90,13 +90,16 @@ export const buildPackages = async () => {
9090 try {
9191 await buildPackage ( pkg , options . buildOverrides , "inherit" , options . safeReplace ) ;
9292
93- // Record the source hash (in dist as a marker and in build meta) so
94- // a later build treats this package as a cache hit and skips the copy.
95- const sourceHash = await getPackageSourceHash ( pkg ) ;
96- writeDistBuildHash ( pkg , sourceHash ) ;
97- const meta = getBuildMeta ( ) ;
98- meta . packages [ pkg . packageJson . name ] = { sourceHash } ;
99- writeJsonFileSync ( META_FILE_PATH , meta ) ;
93+ // EXPERIMENTAL (opt-in): record the source hash (in dist as a marker
94+ // and in build meta) so a later build treats this package as a cache
95+ // hit and skips the copy. Off by default — see distBuildHash.ts.
96+ if ( isExperimentalBuildCacheEnabled ( ) ) {
97+ const sourceHash = await getPackageSourceHash ( pkg ) ;
98+ writeDistBuildHash ( pkg , sourceHash ) ;
99+ const meta = getBuildMeta ( ) ;
100+ meta . packages [ pkg . packageJson . name ] = { sourceHash } ;
101+ writeJsonFileSync ( META_FILE_PATH , meta ) ;
102+ }
100103
101104 sendNotification ( `Webiny Build (${ projectFolder } )` , "Build completed successfully" ) ;
102105 } catch ( err ) {
@@ -140,9 +143,12 @@ export const buildPackages = async () => {
140143
141144 // Store package hash
142145 const sourceHash = await getPackageSourceHash ( pkg ) ;
143- // Stamp dist so a later no-op build can
144- // skip the cache→dist copy for this package.
145- writeDistBuildHash ( pkg , sourceHash ) ;
146+ // EXPERIMENTAL (opt-in): stamp dist so a
147+ // later no-op build can skip the
148+ // cache→dist copy for this package.
149+ if ( isExperimentalBuildCacheEnabled ( ) ) {
150+ writeDistBuildHash ( pkg , sourceHash ) ;
151+ }
146152 await queueMetaWrite ( async ( ) => {
147153 const currentMeta = getBuildMeta ( ) ;
148154 currentMeta . packages [ pkg . packageJson . name ] = {
0 commit comments