@@ -4,7 +4,8 @@ import { componentize } from '@bytecodealliance/componentize-js';
44import { version as componentizeVersion } from '@bytecodealliance/componentize-js' ;
55import { getPackagesWithWasiDeps , processWasiDeps } from './wasiDepsParser.js' ;
66import {
7- calculateChecksum ,
7+ calculateCheckSum ,
8+ calculateFileChecksum ,
89 saveBuildData ,
910} from './utils.js' ;
1011import { getCliArgs } from './cli.js' ;
@@ -23,15 +24,6 @@ async function main() {
2324 let outputPath = CliArgs . output ;
2425 let runtimeArgs = CliArgs . debug ? '--enable-script-debugging' : '' ;
2526
26- // Small optimization to skip componentization if the source file hasn't changed
27- if ( ! ( await ShouldComponentize ( src , outputPath , componentizeVersion , runtimeArgs ) ) ) {
28- console . log (
29- 'No changes detected in source file. Skipping componentization.' ,
30- ) ;
31- return ;
32- }
33- console . log ( 'Componentizing...' ) ;
34-
3527 // generate wit world string
3628 let wasiDeps = getPackagesWithWasiDeps ( process . cwd ( ) , new Set ( ) , true ) ;
3729 let { witPaths, targetWorlds } = processWasiDeps ( wasiDeps ) ;
@@ -63,6 +55,17 @@ async function main() {
63556456 ) ;
6557
58+ // Calcuilate the checksum of the inline wit
59+ let inlineWitChecksum = await calculateCheckSum ( inlineWit ) ;
60+ // Small optimization to skip componentization if the source file hasn't changed
61+ if ( ! ( await ShouldComponentize ( src , outputPath , componentizeVersion , runtimeArgs , inlineWitChecksum ) ) ) {
62+ console . log (
63+ 'No changes detected in source file and target World. Skipping componentization.' ,
64+ ) ;
65+ return ;
66+ }
67+ console . log ( 'Componentizing...' ) ;
68+
6669 const source = await readFile ( src , 'utf8' ) ;
6770 const precompiledSource = precompile ( source , src , true ) as string ;
6871
@@ -85,9 +88,10 @@ async function main() {
8588 // Save the checksum of the input file along with the componentize version
8689 await saveBuildData (
8790 getBuildDataPath ( src ) ,
88- await calculateChecksum ( src ) ,
91+ await calculateFileChecksum ( src ) ,
8992 componentizeVersion ,
9093 runtimeArgs ,
94+ inlineWitChecksum ,
9195 ) ;
9296
9397 console . log ( 'Component successfully written.' ) ;
0 commit comments