diff --git a/.changeset/keep-import-source.md b/.changeset/keep-import-source.md new file mode 100644 index 000000000..79aa447bd --- /dev/null +++ b/.changeset/keep-import-source.md @@ -0,0 +1,5 @@ +--- +"workers-rs": minor +--- + +`worker-build` no longer rewrites the Wasm `import source` in `build/index.js` to a plain `import`, now that workerd and Wrangler support source phase imports. Needs a Wrangler version whose esbuild parses `import source`. diff --git a/worker-build/src/main.rs b/worker-build/src/main.rs index 7b7c9d29b..85296e1dd 100644 --- a/worker-build/src/main.rs +++ b/worker-build/src/main.rs @@ -35,16 +35,6 @@ use crate::{ const VERSION: &str = env!("CARGO_PKG_VERSION"); -fn fix_wasm_import(out_dir: &Path) -> Result<()> { - let index_path = output_path(out_dir, "index.js"); - let content = fs::read_to_string(&index_path) - .with_context(|| format!("Failed to read {}", index_path.display()))?; - let updated_content = content.replace("import source ", "import "); - fs::write(&index_path, updated_content) - .with_context(|| format!("Failed to write {}", index_path.display()))?; - Ok(()) -} - fn update_package_json(out_dir: &Path) -> Result<()> { let package_json_path = output_path(out_dir, "package.json"); @@ -132,8 +122,6 @@ pub fn main() -> Result<()> { let esbuild_path = Esbuild.get_binary(None)?.0; bundle(&staging_dir, &esbuild_path, emscripten)?; - fix_wasm_import(&staging_dir)?; - remove_unused_files(&staging_dir)?; create_wrapper_alias(&staging_dir, false)?;