Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage of import causes odd side effects/timing #8

Open
bmeck opened this issue Dec 2, 2021 · 1 comment
Open

usage of import causes odd side effects/timing #8

bmeck opened this issue Dec 2, 2021 · 1 comment

Comments

@bmeck
Copy link
Member

bmeck commented Dec 2, 2021

Due to import() causing evaluation getting the namespaces of modules can cause double init since the loader module cache != the app module cache and can cause out of order evaluation.

A nasty intentional runtime error with a nested cycle could let you get a hold of a module namespace without executing it potentially / sadly.

// inspector
import 'will-explode';
import * as ns from 'to-inspect';
export function keys() {
  return Object.keys(ns);
}
// will-explode
import {keys} from 'inspector';
throw keys();
@bengl
Copy link
Member

bengl commented Jun 15, 2023

This is fixed on Node.js 20, where a parser is used instead to get exports.

That said, I'll leave this open, since we're not yet testing for it, and it will still explode on earlier versions of Node.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants