Skip to content

Commit

Permalink
chore: fix --mode cli args don't work for mako bin (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc authored Jan 18, 2024
1 parent 513828e commit cb8ce77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 9 additions & 1 deletion crates/mako/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ async fn main() -> Result<()> {
.map_err(|_| anyhow!("Root directory {:?} not found", root))?;

// config
let mut config = config::Config::new(&root, None, None)
let cli_args = format!(
r#"
{{
"mode": "{}"
}}
"#,
cli.mode
);
let mut config = config::Config::new(&root, None, Some(cli_args.as_str()))
.map_err(|e| anyhow!(format!("Load config failed: {}", e)))?;

config.mode = cli.mode;
Expand Down
3 changes: 1 addition & 2 deletions crates/mako/src/plugins/bundless_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use mako_core::tracing::warn;

use crate::ast::{js_ast_to_code, Ast};
use crate::compiler::{Args, Context};
use crate::config::{Config, Mode};
use crate::config::Config;
use crate::module::{ModuleAst, ModuleId};
use crate::plugin::{Plugin, PluginTransformJsParam};
use crate::transformers::transform_dep_replacer::{DepReplacer, DependenciesToReplace};
Expand Down Expand Up @@ -202,7 +202,6 @@ pub fn transform_js_generate(
dep_map: &DependenciesToReplace,
_is_entry: bool,
) {
let _is_dev = matches!(context.config.mode, Mode::Development);
GLOBALS
.set(&context.meta.script.globals, || {
try_with_handler(
Expand Down
3 changes: 1 addition & 2 deletions packages/bundler-okam/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ exports.build = async function (opts) {
checkConfig(opts);

const okamConfig = await getOkamConfig(opts);
const mode = process.argv.includes('--dev') ? 'development' : 'production';
okamConfig.mode = mode;
okamConfig.mode = 'production';
okamConfig.manifest = {};
okamConfig.hash = !!opts.config.hash;
if (okamConfig.hash) {
Expand Down

0 comments on commit cb8ce77

Please sign in to comment.