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

Code review notes #90

Closed
9 tasks done
jdalton opened this issue Mar 24, 2017 · 5 comments
Closed
9 tasks done

Code review notes #90

jdalton opened this issue Mar 24, 2017 · 5 comments

Comments

@jdalton
Copy link
Contributor

jdalton commented Mar 24, 2017

I wanted to capture the notes I took during our code review.

Moved

Completed

  • Check if namespace import is constant and if so the bind isn't needed and it can be const.
  • Use arrow functions for module.import and module.exports, module.import, and module.importSync.
  • The namespace object should be Object.create(null)
  • The cache hash - look into mtime + path + version.
  • If a module has import/export add 'use strict'
  • Align setEsModule __esModule property non-enumerable
  • - Make the uniqueKey a fast property by changing the : to a __ or something similar
  • Should addGetters throw? Yes.
  • forEachSetter (use UNDEFINED lookup)
@jdalton
Copy link
Contributor Author

jdalton commented Mar 24, 2017

Check if namespace import is constant and if so the bind isn't needed and it can be const.

The rules for namespace properties are here. The property descriptors should be:

{ [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }

Which means you can create the namespace object as an Object.create(null) and then pass it through Object.seal after you've assigned its properties. No need to have Object.defineProperty for all of them since Object.seal will take care of it.

@benjamn
Copy link
Owner

benjamn commented Mar 24, 2017

[[Writable]]: true though?

@benjamn
Copy link
Owner

benjamn commented Mar 24, 2017

I thought that to-do item was more to check if the namespace variable itself could be changed to a value different from the original object, which is what the <setter function>.bind(ns = Object.create(null)) protects against.

@jdalton
Copy link
Contributor Author

jdalton commented Mar 24, 2017

[[Writable]]: true though?

That's what the spec says. I've pinged Brian Terlson to see if it's a spec bug.
Update: Ok so, it's still writable in the draft spec too.

I thought that to-do item was more to check if the namespace variable itself could be changed to a value different from the original object,

Ah ya. Imported identifiers are all const, even namespace ones, so the bind can be dropped and const used for namespace imports.

benjamn added a commit that referenced this issue Mar 25, 2017
benjamn added a commit that referenced this issue Mar 28, 2017
The vm.* wrappers registered by repl/index.js still just hash the
contents, so those cache entries should not collide with the ones used by
Module.prototype._compile.

Part of #90.
Closes #98.
@jdalton
Copy link
Contributor Author

jdalton commented Mar 30, 2017

I looked up taking on

Make the uniqueKey a fast property by changing the : to a __ or something similar

It looks like most all keys are the slow kind because they use file paths. This was a nice to have but not a biggie so crossing it out.

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

No branches or pull requests

2 participants