From 1757250997c6eaf5c031346334e8d01dfea57f13 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Thu, 2 May 2019 18:57:06 -0400 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Rich Trott --- test/es-module/test-esm-loader-cache-clearing.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/es-module/test-esm-loader-cache-clearing.js diff --git a/test/es-module/test-esm-loader-cache-clearing.js b/test/es-module/test-esm-loader-cache-clearing.js new file mode 100644 index 00000000000000..ec22b6a6bb871e --- /dev/null +++ b/test/es-module/test-esm-loader-cache-clearing.js @@ -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');