Skip to content

Commit

Permalink
Merge pull request #21 from ice-lab/feat/env
Browse files Browse the repository at this point in the history
feat: suport env replacement
  • Loading branch information
ClarkXia authored Dec 5, 2023
2 parents cf3e939 + b6147af commit 55f5441
Show file tree
Hide file tree
Showing 23 changed files with 585 additions and 43 deletions.
9 changes: 6 additions & 3 deletions crates/loader_compilation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(box_patterns)]
use std::{path::Path, collections::HashMap, sync::Mutex};
use lazy_static::lazy_static;
use rspack_ast::RspackAst;
Expand Down Expand Up @@ -163,8 +164,10 @@ impl Loader<LoaderRunnerContext> for CompilationLoader {
if routes_config.is_none() || file_accessed {
// Load routes config for transform.
let routes_config_path: std::path::PathBuf = Path::new(compiler_context).join(".ice/route-manifest.json");
*routes_config = Some(load_routes_config(&routes_config_path).unwrap());

let routes_content = load_routes_config(&routes_config_path);
if routes_content.is_ok() {
*routes_config = Some(routes_content?);
}
if file_accessed {
// If file accessed, then we need to clear the map for the current compilation.
file_access.clear();
Expand All @@ -175,7 +178,7 @@ impl Loader<LoaderRunnerContext> for CompilationLoader {
let built = compiler.parse(None, |_| {
transform(
&resource_path,
routes_config.as_ref().unwrap(),
routes_config.as_ref(),
transform_options
)
})?;
Expand Down
Loading

0 comments on commit 55f5441

Please sign in to comment.