Skip to content

Commit

Permalink
fix(require): ensure no infinite require loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Oct 9, 2021
1 parent 98dab33 commit e5eb473
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/require.ts
Expand Up @@ -17,11 +17,11 @@ let uconf = env.file && require(env.file);
let config: Config = (tsm as TSM).$finalize(env, uconf);

declare const $$req: NodeJS.Require;
const tsrequire = 'var $$req=require;require=(' + function () {
const tsrequire = 'var $$req=require("module").createRequire(__filename);require=(' + function () {
let { existsSync } = $$req('fs');
let { URL, pathToFileURL } = $$req('url');

return new Proxy($$req, {
return new Proxy(require, {
// NOTE: only here if source is TS
apply(req, ctx, args: [id: string]) {
let [ident] = args;
Expand Down

0 comments on commit e5eb473

Please sign in to comment.