-
Notifications
You must be signed in to change notification settings - Fork 28
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
add Node.js v20 support #28
Conversation
Since Node.js v20 moves loaders to a separate thread, we can no longer depend on loading the modules in the loader to get the exports. This is needed to add our mutable proxy. For Node.js 20, exports are now retrieved via parsing. To reduce startup overhead on older versions of Node.js, the previous method of getting exports is used, avoiding loading and using parsers.
@@ -37,6 +36,9 @@ | |||
"typescript": "^4.7.4" | |||
}, | |||
"dependencies": { | |||
"acorn": "^8.8.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any output on the PR about the module sizes...
For a naked project, installing these two packages results in 528K of disk space. Doesn't look like any of that would be deduped with existing dependencies since acorn itself has no deps:
λ /tmp/acorn/ npm ls --depth=10
[email protected] /private/tmp/acorn
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compressed, the files take up 133KB, which would be the approx change to a Lambda bundle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions for you, but otherwise LGTM.
} | ||
|
||
// At this point our `format` is either undefined or not known by us. Fall | ||
// back to parsing as ESM/CJS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it not be wasm? What happens in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK that's not in Node.js 20, so we'll cross that bridge when we come to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's behind a flag, but it is there. There's also json modules.
If I understand right, if we don't return anything from the loader then it will skip it and use the default/built-in logic, correct? So just not handling formats we don't specifically support here is fine?
Since Node.js v20 moves loaders to a separate thread, we can no longer depend on loading the modules in the loader to get the exports. This is needed to add our mutable proxy. For Node.js 20, exports are now retrieved via parsing.
To reduce startup overhead on older versions of Node.js, the previous method of getting exports is used, avoiding loading and using parsers.