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)
- Cannot use jsr.json as workspace member outside deno publish HOT 7
- 'main' panicked HOT 1
- Support bare specifiers for npm package members in a workspace
- bug(net): http2 protocol error since deno 1.45
- Bug: Command `deno add` logs error for JSR package without default export
- Bug: LSP errors in VSCode opening built-in Typescript/Deno `d.ts` files HOT 1
- Publishing JSR pkg that resolves to npm workspace member that's a JSR dep should error?
- deno compile: node addons gets error `missing symbol called`
- Compilation error during cargo install HOT 4
- `node:tty` -> N.WriteStream.prototype.hasColors is not a function
- File with just `+` does not report syntax error HOT 3
- Websocket behaviour change since 1.44.3 HOT 4
- No way to specify specific abstract socket name with `--allow-read/write`.
- Import error on startup when a Fresh project is a workspace member HOT 3
- Non-zero exit code in a test case causes the test to fail since 1.44.0
- `deno test --watch` should always print the full test output HOT 2
- proposal: add `Deno.ConfigFile` HOT 4
- βclient error (SendRequest)β when fetching certain https URLs over proxy
- deno publish failed with error: error[excluded-module] when export casing differs from file casing HOT 5
- For loop does not works as expected HOT 2
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.