1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -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:
Nayeem Rahman 2023-06-29 22:07:05 +01:00 committed by GitHub
parent 09af1a5fef
commit 55362452a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View file

@ -708,6 +708,17 @@ const ci = {
].join("\n"), ].join("\n"),
env: { CARGO_PROFILE_DEV_DEBUG: 0 }, 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", name: "Test release",
if: [ if: [

View file

@ -435,6 +435,13 @@ jobs:
cargo test --locked --test '*' cargo test --locked --test '*'
env: env:
CARGO_PROFILE_DEV_DEBUG: 0 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 - name: Test release
if: |- if: |-
!(github.event_name == 'pull_request' && matrix.skip_pr) && (matrix.job == 'test' && matrix.profile == 'release' && !(github.event_name == 'pull_request' && matrix.skip_pr) && (matrix.job == 'test' && matrix.profile == 'release' &&

View file

@ -622,8 +622,8 @@ macro_rules! include_js_files {
$($crate::ExtensionFileSource { $($crate::ExtensionFileSource {
specifier: concat!("ext:", stringify!($name), "/", $file), specifier: concat!("ext:", stringify!($name), "/", $file),
code: $crate::ExtensionFileSourceCode::IncludedInBinary( 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 { $($crate::ExtensionFileSource {
specifier: concat!("ext:", stringify!($name), "/", $file), specifier: concat!("ext:", stringify!($name), "/", $file),
code: $crate::ExtensionFileSourceCode::IncludedInBinary( code: $crate::ExtensionFileSourceCode::IncludedInBinary(
include_str!($file) include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $file))
), ),
},)+ },)+
] ]

View file

@ -13,7 +13,7 @@ use deno_runtime::worker::WorkerOptions;
deno_core::extension!( deno_core::extension!(
hello_runtime, hello_runtime,
esm_entry_point = "ext:hello_runtime/bootstrap.js", esm_entry_point = "ext:hello_runtime/bootstrap.js",
esm = ["bootstrap.js"] esm = [dir "examples/extension_with_esm", "bootstrap.js"]
); );
#[tokio::main] #[tokio::main]