node/test/fixtures/inspector-global-function.mjs
Joyee Cheung 995440b791
bootstrap: make CJS loader snapshotable
This patch makes the top-level access to runtime states in the
CJS loader lazy, and move the side-effects into a
initializeCJS() function that gets called during pre-execution.
As a result the CJS loader can be included into the built-in
snapshot.

PR-URL: https://github.com/nodejs/node/pull/45849
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-12-16 12:44:14 +01:00

18 lines
439 B
JavaScript

'use strict';
let invocations = 0;
const interval = setInterval(() => {}, 1000);
global.sum = function() {
const a = 1;
const b = 2;
const c = a + b;
clearInterval(interval);
console.log(invocations++, c);
};
// NOTE(mmarchini): Calls console.log two times to ensure we loaded every
// internal module before pausing. See
// https://bugs.chromium.org/p/v8/issues/detail?id=10287.
console.log('Loading');
console.log('Ready!');