mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
62383cd113
This implements an API for users to intentionally flush the accumulated compile cache instead of waiting until process shutdown. It may be useful for application that loads dependencies first and then either reload itself in other instances, or spawning other instances that load an overlapping set of its dependencies - in this case its useful to flush the cache early instead of waiting until the shutdown of itself. Currently flushing is triggered by either process shutdown or user requests. In the future we should simply start the writes right after module loading on a separate thread, and this method only blocks until all the pending writes (if any) on the other thread are finished. In that case, the off-thread writes should finish long before any attempt of flushing is made so the method would then only incur a negligible overhead from thread synchronization. PR-URL: https://github.com/nodejs/node/pull/54971 Fixes: https://github.com/nodejs/node/issues/54770 Fixes: https://github.com/nodejs/node/issues/54465 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
23 lines
697 B
JavaScript
23 lines
697 B
JavaScript
'use strict';
|
|
|
|
const { findSourceMap } = require('internal/source_map/source_map_cache');
|
|
const { Module } = require('internal/modules/cjs/loader');
|
|
const { register } = require('internal/modules/esm/loader');
|
|
const { SourceMap } = require('internal/source_map/source_map');
|
|
const {
|
|
constants,
|
|
enableCompileCache,
|
|
flushCompileCache,
|
|
getCompileCacheDir,
|
|
} = require('internal/modules/helpers');
|
|
|
|
Module.findSourceMap = findSourceMap;
|
|
Module.register = register;
|
|
Module.SourceMap = SourceMap;
|
|
Module.constants = constants;
|
|
Module.enableCompileCache = enableCompileCache;
|
|
Module.flushCompileCache = flushCompileCache;
|
|
|
|
Module.getCompileCacheDir = getCompileCacheDir;
|
|
module.exports = Module;
|