Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/keep-import-source.md
Original file line number Diff line number Diff line change
@@ -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`.
12 changes: 0 additions & 12 deletions worker-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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)?;
Expand Down
Loading