Skip to content

Commit

Permalink
Update SourceProvider and bundle() to be async (parcel-bundler#174
Browse files Browse the repository at this point in the history
)

The two `SourceProvider` methods are now `async` which will give a hook for JavaScript to implement them and be called from the main thread. Everything is `async` now where possible and `bundle()` executes the `Future` synchronously to maintain its contract. Since it won't support custom JavaScript resolvers, there should never be a case where `bundle()` can't execute synchronously.

Rayon doesn't seem to support `async` iterators, but also shouldn't be as necessary here. Removed it in order to call `async` APIs.
  • Loading branch information
dgp1130 committed Jun 25, 2022
1 parent 3dd150d commit 81e4fcb
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 226 deletions.
235 changes: 166 additions & 69 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ path = "src/lib.rs"
crate-type = ["rlib"]

[dependencies]
async-recursion = "1.0.0"
async-trait = "0.1.53"
futures = "0.3.21"
serde = { version = "1.0.123", features = ["derive"] }
cssparser = "0.29.1"
parcel_selectors = { version = "0.24.4", path = "./selectors" }
Expand All @@ -35,12 +38,12 @@ parcel_sourcemap = "2.0.2"
data-encoding = "2.3.2"
lazy_static = "1.4.0"
const-str = "0.3.1"
tokio = { version = "1.19.1", features = ["macros", "rt", "rt-multi-thread"] }
# CLI deps
clap = { version = "3.0.6", features = ["derive"], optional = true }
serde_json = { version = "1.0.78", optional = true }
pathdiff = { version = "0.2.1", optional = true }
browserslist-rs = { version = "0.7.0", optional = true }
rayon = "1.5.1"
dashmap = "5.0.0"

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jemallocator = { version = "0.3.2", features = ["disable_initial_exec_tls"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
napi = {version = "2.2.0", default-features = false, features = ["napi4", "compat-mode", "serde-json"]}
napi-derive = "2"
tokio = {version = "1.19.0", features = ["rt", "rt-multi-thread"]}

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3"
Expand Down
Loading

0 comments on commit 81e4fcb

Please sign in to comment.