Comments (6)
@littledivy Fair point: I've published the snippet as an npm package and updated the reproduction steps accordingly.
from deno.
The process
global isn't available either. We're likely not setting up the node context.
from deno.
I don't think that's the problem. Most likely it's related to https://github.com/denoland/deno/blob/main/ext/node/global.rs not recognizing that we're running inside node:vm
.
from deno.
runInThisContext
runs the code in the current context i.e Deno. By running it with Node globals we will change that definition.
This code should work when in a Node context i.e node_modules
from deno.
Also blocking the Docusaurus upgrade in denoland/deno-docs#412
from deno.
Took a look at this, and I can get it to work with this patch, but I'm not sure if this is the right fix.
diff --git a/ext/node/global.rs b/ext/node/global.rs
index 0aaa6ed8b..a3722641d 100644
--- a/ext/node/global.rs
+++ b/ext/node/global.rs
@@ -267,7 +267,9 @@ fn current_mode(scope: &mut v8::HandleScope) -> Mode {
let Some(v8_string) =
v8::StackTrace::current_script_name_or_source_url(scope)
else {
- return Mode::Deno;
+ // TODO: Add a flag to scope for inline scripts created
+ // via node:vm
+ return Mode::Node;
};
let op_state = deno_core::JsRuntime::op_state_from(scope);
let op_state = op_state.borrow();
@@ -276,7 +278,7 @@ fn current_mode(scope: &mut v8::HandleScope) -> Mode {
};
let mut buffer = [MaybeUninit::uninit(); 2048];
let str = v8_string.to_rust_cow_lossy(scope, &mut buffer);
- if node_resolver.in_npm_package_with_cache(str) {
+ if str.starts_with("node:") || node_resolver.in_npm_package_with_cache(str) {
Mode::Node
} else {
Mode::Deno
The first change isn't necessary for this particular reproduction case, but it is necessary to get vitest
to work. Will try next week to find a proper test case that covers that.
from deno.
Related Issues (20)
- Node:http localAddress not supported in compat
- parser-ts fails to work in deno HOT 1
- npm @gutenye/ocr-node doesn't work correctly
- Will the `curl -fsSL https://deno.land/install.sh | sh` URL install Deno 2.0 (i.e. breaking changes) once 2.0 is released? HOT 2
- [node] deasync package doesn't work in Deno CLI HOT 1
- workspaces: Always walk up to the root of the file system unless you encounter a deno.json(c) file with "workspace" key
- workspaces: Do not allow to use two different workspaces in subcommands that accept multiple entrypoints
- workspaces: Lockfile should be placed next to the workspace config file
- workspaces: Specify behavior of `deno install` when in a workspace context
- workspaces: Specify behavior of `package.json` in context of Deno workspace
- Doc tests don't play nice with blockquotes in markdown
- `mkdir()` incorrectly returns `undefined` and produces unexpected subsequent results
- Deprecate / Remove `--lock-write` HOT 1
- Way to resolve npm file imports like npm:lib/bin.wasm HOT 2
- `import.meta.resolve` does not resolve `npm:` specifiers that have not been loaded already but are in a package that is already loaded HOT 1
- `Deno.open` successfully opens folders on linux HOT 1
- devcontainer with denoland/deno:alpine not working HOT 2
- Expose `zstd` compress to js code HOT 1
- Broken debugger HOT 5
- Bad Content-Length when use octokit upload asset with webStream
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno.