chyyran
chyyran
DDeno
Created by chyyran on 10/17/2023 in #help
How to resolve requires without `.js` extension in a very basic NPM resolver?
I have an NPM resolver that without caching that expects everything to be in a node_modules folder, mostly copied from deno cli https://gist.github.com/rust-play/fbd49c87332ee27b3d217bb1e0005462 I can successfully require lodash, but one of the npm libraries I'm trying to require imports a babel library like so
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
It seems like it's failing to resolve the module, cause it panics at thread 'main' panicked at 'called Result::unwrap() on an Err value: Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
3 replies
DDeno
Created by chyyran on 10/16/2023 in #help
Bootstrapping a minimal node-compatible runtime
I'm trying to bootstrap a minimal node-compatible runtime, so I've basically been copying and pasting MainWorker and removing things I don't need like napi or kv
let permissions = PermissionsContainer::allow_all();

let mut extensions = vec![
// Web APIs
deno_webidl::deno_webidl::init_ops_and_esm(),
deno_console::deno_console::init_ops_and_esm(),
deno_url::deno_url::init_ops_and_esm(),
deno_web::deno_web::init_ops_and_esm::<PermissionsContainer>(
options.blob_store.clone(),
options.bootstrap.location.clone(),
),
deno_fetch::deno_fetch::init_ops_and_esm::<PermissionsContainer>(
deno_fetch::Options {
user_agent: options.bootstrap.user_agent.clone(),
root_cert_store_provider: options.root_cert_store_provider.clone(),
unsafely_ignore_certificate_errors: options
.unsafely_ignore_certificate_errors
.clone(),
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
..Default::default()
},
),
deno_websocket::deno_websocket::init_ops_and_esm::<PermissionsContainer>(
options.bootstrap.user_agent.clone(),
options.root_cert_store_provider.clone(),
options.unsafely_ignore_certificate_errors.clone(),
),
deno_crypto::deno_crypto::init_ops_and_esm(options.seed),

deno_net::deno_net::init_ops_and_esm::<PermissionsContainer>(
options.root_cert_store_provider.clone(),
options.unsafely_ignore_certificate_errors.clone(),
),
deno_tls::deno_tls::init_ops_and_esm(),
deno_http::deno_http::init_ops_and_esm::<DefaultHttpPropertyExtractor>(),
deno_io::deno_io::init_ops_and_esm(Some(options.stdio)),
deno_fs::deno_fs::init_ops_and_esm::<PermissionsContainer>(
options.fs.clone(),
),
deno_node::deno_node::init_ops_and_esm::<PermissionsContainer>(
options.npm_resolver,
options.fs,
),
deno_permissions_worker::init_ops_and_esm(
permissions,
false,
),
];
let permissions = PermissionsContainer::allow_all();

let mut extensions = vec![
// Web APIs
deno_webidl::deno_webidl::init_ops_and_esm(),
deno_console::deno_console::init_ops_and_esm(),
deno_url::deno_url::init_ops_and_esm(),
deno_web::deno_web::init_ops_and_esm::<PermissionsContainer>(
options.blob_store.clone(),
options.bootstrap.location.clone(),
),
deno_fetch::deno_fetch::init_ops_and_esm::<PermissionsContainer>(
deno_fetch::Options {
user_agent: options.bootstrap.user_agent.clone(),
root_cert_store_provider: options.root_cert_store_provider.clone(),
unsafely_ignore_certificate_errors: options
.unsafely_ignore_certificate_errors
.clone(),
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
..Default::default()
},
),
deno_websocket::deno_websocket::init_ops_and_esm::<PermissionsContainer>(
options.bootstrap.user_agent.clone(),
options.root_cert_store_provider.clone(),
options.unsafely_ignore_certificate_errors.clone(),
),
deno_crypto::deno_crypto::init_ops_and_esm(options.seed),

deno_net::deno_net::init_ops_and_esm::<PermissionsContainer>(
options.root_cert_store_provider.clone(),
options.unsafely_ignore_certificate_errors.clone(),
),
deno_tls::deno_tls::init_ops_and_esm(),
deno_http::deno_http::init_ops_and_esm::<DefaultHttpPropertyExtractor>(),
deno_io::deno_io::init_ops_and_esm(Some(options.stdio)),
deno_fs::deno_fs::init_ops_and_esm::<PermissionsContainer>(
options.fs.clone(),
),
deno_node::deno_node::init_ops_and_esm::<PermissionsContainer>(
options.npm_resolver,
options.fs,
),
deno_permissions_worker::init_ops_and_esm(
permissions,
false,
),
];
However when it crashes on JsRuntime::new
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Evaluated`,
right: `Instantiated`: Module already evaluated. Perhaps you've re-provided a module or extension that was already included in the snapshot? ext:deno_node/02_init.js (43)', /Users/chyyran/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.222.0/runtime/jsrealm.rs:546:5
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Evaluated`,
right: `Instantiated`: Module already evaluated. Perhaps you've re-provided a module or extension that was already included in the snapshot? ext:deno_node/02_init.js (43)', /Users/chyyran/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.222.0/runtime/jsrealm.rs:546:5
Is there anything I seem to be missing that could cause this error?
7 replies