test: clearing require cache crashes esm loader

This test shows the regression introduced in v11.4.0: clearing out the
require.cache crashes node when using the `--experimental-modules` flag.
Refs: https://github.com/nodejs/node/issues/25482

PR-URL: https://github.com/nodejs/node/pull/25491
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Antoine du HAMEL 2019-05-02 18:57:06 -04:00 committed by ZYSzys
parent 6fe369286a
commit ac3b98cd26
1 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,11 @@
// Flags: --experimental-modules
'use strict';
require('../common');
const { cache } = require;
Object.keys(cache).forEach((key) => {
delete cache[key];
});
// Require the same module again triggers the crash
require('../common');