Skip to content

tiagojufr/opentelemetry-babel-require-in-the-middle-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opentelemetry-babel-require-in-the-middle-repro

Reproduction repo for elastic/require-in-the-middle#72

Run dev script. Note that the very first run does not fail as @babel/register is creating its cache file. If you run it a 2nd time you should see the following error:

<path_to_repo>\node_modules\@babel\core\lib\parser\index.js:74
    throw err;
    ^

AssertionError [ERR_ASSERTION]: unexpected that there is no Module entry for "<path_to_repo>\node_modules\@babel\parser\lib\index.js" in require.cache
    at ExportsCache.set (<path_to_repo>\node_modules\require-in-the-middle\index.js:89:7)
    at Module.Hook._require.Module.require (<path_to_repo>\node_modules\require-in-the-middle\index.js:249:17)
    at require (node:internal/modules/cjs/helpers:103:18)
    at parse (<path_to_repo>\node_modules\@babel\core\src\parser\index.ts:2:1)
    at parser (<path_to_repo>\node_modules\@babel\core\src\parser\index.ts:28:14)
    at parser.next (<anonymous>)
    ...

There's a workaround for this issue as suggested by this comment by defining BABEL_DISABLE_CACHE=1. This fix can be tested with the dev:fix script in this repo.

Tested with Node.js v18.13.0.