-
Notifications
You must be signed in to change notification settings - Fork 41
Hamada/module system #25
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
Conversation
…ter managed python.load to give exports as dict
def helloWorld(): | ||
print('hello, world!') | ||
|
||
exports = {} |
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.
modules should not provide their own exports object; the module system should provide this. CommonJS modules are decorator-pattern, with the exports object memoized before the module is evaluated. That is key to, among other things, correct behaviour when loading (potentially transitive) circular dependencies.
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.
Yeah that makes sense. I'll modify the python load to prefill the module with the exports object so that when the loader loads the module the exports object should exist and be memorized before the module is evaluated.
… loading, and better fs.readfilesync impl
I've merged this into wes/module-system |
Adds some pythonic file handling and some pythonic type hinting, as well as modifies the python load function to use the importlib machinery so that python modules are loaded conforming to python spec.
open
doesn't automatically close the file handler, it's recommended to usewith open() as f:
to ensure the file handler closes.