| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: nodejs#64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: #64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
PR-URL: #64112
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: #64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
PR-URL: #64112
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: #64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
PR-URL: #64112
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: #64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
PR-URL: #64112
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The import.meta example for new vm.SourceTextModule() in vm.md does not
run as written. It fails in two separate ways.
First, the constructor is missing the context: contextifiedObject
option, so the module evaluates in the top context where secret is not
defined, and the snippet throws ReferenceError: secret is not defined.
Second, the trailing note suggests replacing meta.prop = {} with
vm.runInContext('{}', contextifiedObject), but '{}' is parsed as an
empty block and evaluates to undefined. That makes the following
Object.getPrototypeOf(import.meta.prop) throw TypeError. Wrapping it as
'({})' returns an object, which is what the note intends.
This adds the context option and corrects the suggested replacement to
'({})' in both the mjs and cjs variants.
Fixes: #64076
Signed-off-by: Muhammad Zeeshan <61280174+zeeshan56656@users.noreply.github.com>
PR-URL: #64112
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
| Back | FazBrowse Home | New Git URL |
The import.meta example for new vm.SourceTextModule() in vm.md does not run as written. It fails in two separate ways:
This adds the context option and corrects the suggested replacement to '({})' in both the mjs and cjs variants, so the example and its note both behave as documented.
Fixes: #64076