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)
- Static Libraries HOT 1
- BadResource: Bad resource ID after piping stdout to Deno HOT 2
- LSP: Autocomplete in `deno.json` not working when offline
- deno_vscode feature request: copy inferred type
- V8 code cache: node_modules cache doesn't work on Lambda HOT 3
- V8 code cache: make cache update async HOT 1
- FUTURE: stabilize some `Deno` APIs behind the flag
- FUTURE: `deno install` should not download/copy packages if `node_modules/` dir is up to date HOT 1
- FUTURE: `deno install` should interop with other package managers HOT 1
- fails to import a module because of invalid utf8 sequence HOT 3
- Bug: Express errors when sending big file
- Memory leak in `node:vm` HOT 2
- Error running task when `nodeModulesDir` is set to `true` but the `node_modules` directory is absent
- LSP: accepting quick fix inserts import from https://jsr.io URL
- Bug: Panic in Jest
- Perf - Do not do node permission checks when all permissions are allowed
- Cannot execute: required file not found when trying to run in termux HOT 2
- LSP: Regression in resolving Typescript Dependencies of included Typing files HOT 3
- thread 'main' panicked at inspector.rs:367 internal error: entered unreachable code HOT 2
- Using JSR package in Vite running in Deno HOT 1
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.