mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
995440b791
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>
18 lines
439 B
JavaScript
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!');
|