MCPcopy
hub / github.com/react/react / subscribeTsc

Function subscribeTsc

compiler/packages/snap/src/runner-watch.ts:165–196  ·  view source on GitHub ↗
(
  state: RunnerState,
  onChange: (state: RunnerState) => void,
)

Source from the content-addressed store, hash-verified

163}
164
165function subscribeTsc(
166 state: RunnerState,
167 onChange: (state: RunnerState) => void,
168) {
169 // Run TS in incremental watch mode
170 watchSrc(
171 function onStart() {
172 // Notify the user when compilation starts but don't clear the screen yet
173 console.log('\nCompiling...');
174 },
175 isTypecheckSuccess => {
176 let isCompilerBuildValid = false;
177 if (isTypecheckSuccess) {
178 try {
179 execSync('yarn build', {cwd: PROJECT_ROOT});
180 console.log('Built compiler successfully with tsup');
181 isCompilerBuildValid = true;
182 } catch (e) {
183 console.warn('Failed to build compiler with tsup:', e);
184 }
185 }
186 // Bump the compiler version after a build finishes
187 // and re-run tests
188 if (isCompilerBuildValid) {
189 state.compilerVersion++;
190 }
191 state.isCompilerBuildValid = isCompilerBuildValid;
192 state.mode.action = RunnerAction.Test;
193 onChange(state);
194 },
195 );
196}
197
198function subscribeKeyEvents(
199 state: RunnerState,

Callers 1

makeWatchRunnerFunction · 0.85

Calls 2

watchSrcFunction · 0.85
onChangeFunction · 0.70

Tested by

no test coverage detected