mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(core): consistent extension source resolution (#19615)
Currently the resolution for extension sources is different depending on whether `include_js_files_for_snapshotting` is enabled. If sources are embedded it uses `include_str!()` which is module-relative. If sources are read at runtime paths are joined to `CARGO_MANIFEST_DIR` and are package-relative. This makes them both package-relative. Fixes `cargo run -p deno_runtime --example extension_with_esm --features include_js_files_for_snapshotting`.
This commit is contained in:
parent
09af1a5fef
commit
55362452a8
4 changed files with 24 additions and 6 deletions
11
.github/workflows/ci.generate.ts
vendored
11
.github/workflows/ci.generate.ts
vendored
|
@ -708,6 +708,17 @@ const ci = {
|
|||
].join("\n"),
|
||||
env: { CARGO_PROFILE_DEV_DEBUG: 0 },
|
||||
},
|
||||
{
|
||||
name: "Test examples debug",
|
||||
if: "matrix.job == 'test' && matrix.profile == 'debug'",
|
||||
run: [
|
||||
// Only regression tests here for now.
|
||||
// Regression test for https://github.com/denoland/deno/pull/19615.
|
||||
"cargo run -p deno_runtime --example extension_with_esm",
|
||||
"cargo run -p deno_runtime --example extension_with_esm --features include_js_files_for_snapshotting",
|
||||
].join("\n"),
|
||||
env: { CARGO_PROFILE_DEV_DEBUG: 0 },
|
||||
},
|
||||
{
|
||||
name: "Test release",
|
||||
if: [
|
||||
|
|
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
@ -435,6 +435,13 @@ jobs:
|
|||
cargo test --locked --test '*'
|
||||
env:
|
||||
CARGO_PROFILE_DEV_DEBUG: 0
|
||||
- name: Test examples debug
|
||||
if: '!(github.event_name == ''pull_request'' && matrix.skip_pr) && (matrix.job == ''test'' && matrix.profile == ''debug'')'
|
||||
run: |-
|
||||
cargo run -p deno_runtime --example extension_with_esm
|
||||
cargo run -p deno_runtime --example extension_with_esm --features include_js_files_for_snapshotting
|
||||
env:
|
||||
CARGO_PROFILE_DEV_DEBUG: 0
|
||||
- name: Test release
|
||||
if: |-
|
||||
!(github.event_name == 'pull_request' && matrix.skip_pr) && (matrix.job == 'test' && matrix.profile == 'release' &&
|
||||
|
|
|
@ -622,8 +622,8 @@ macro_rules! include_js_files {
|
|||
$($crate::ExtensionFileSource {
|
||||
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||
code: $crate::ExtensionFileSourceCode::IncludedInBinary(
|
||||
include_str!(concat!($dir, "/", $file)
|
||||
)),
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $dir, "/", $file))
|
||||
),
|
||||
},)+
|
||||
]
|
||||
};
|
||||
|
@ -633,7 +633,7 @@ macro_rules! include_js_files {
|
|||
$($crate::ExtensionFileSource {
|
||||
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||
code: $crate::ExtensionFileSourceCode::IncludedInBinary(
|
||||
include_str!($file)
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $file))
|
||||
),
|
||||
},)+
|
||||
]
|
||||
|
|
|
@ -13,7 +13,7 @@ use deno_runtime::worker::WorkerOptions;
|
|||
deno_core::extension!(
|
||||
hello_runtime,
|
||||
esm_entry_point = "ext:hello_runtime/bootstrap.js",
|
||||
esm = ["bootstrap.js"]
|
||||
esm = [dir "examples/extension_with_esm", "bootstrap.js"]
|
||||
);
|
||||
|
||||
#[tokio::main]
|
||||
|
|
Loading…
Reference in a new issue