turbopack_node/
embed_js.rs

1use anyhow::Result;
2use turbo_rcstr::RcStr;
3use turbo_tasks::Vc;
4use turbo_tasks_fs::{FileContent, FileSystem, FileSystemPath, embed_directory};
5
6#[turbo_tasks::function]
7pub fn embed_fs() -> Vc<Box<dyn FileSystem>> {
8    embed_directory!("turbopack-node", "$CARGO_MANIFEST_DIR/js/src")
9}
10
11#[turbo_tasks::function]
12pub(crate) async fn embed_file(path: RcStr) -> Result<Vc<FileContent>> {
13    Ok(embed_fs().root().await?.join(&path)?.read())
14}
15
16#[turbo_tasks::function]
17pub(crate) async fn embed_file_path(path: RcStr) -> Result<Vc<FileSystemPath>> {
18    Ok(embed_fs().root().await?.join(&path)?.cell())
19}