From bc51eca70000e809ef3b64f66e9482316768e02a Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Tue, 3 Sep 2024 01:27:37 +1000 Subject: BREAKING: remove `deno bundle` (#25339) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `deno bundle` now produces: ``` error: ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations ``` `deno bundle --help` now produces: ``` ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations Usage: deno bundle [OPTIONS] Options: -q, --quiet Suppress diagnostic output --unstable Enable all unstable features and APIs. Instead of using this flag, consider enabling individual unstable features To view the list of individual unstable feature flags, run this command again with --help=unstable ``` --- cli/args/flags.rs | 258 ++---------------------------------------------------- cli/args/mod.rs | 21 +---- 2 files changed, 6 insertions(+), 273 deletions(-) (limited to 'cli/args') diff --git a/cli/args/flags.rs b/cli/args/flags.rs index f20252352..991e71b06 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -98,13 +98,6 @@ pub struct BenchFlags { pub watch: Option, } -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct BundleFlags { - pub source_file: String, - pub out_file: Option, - pub watch: Option, -} - #[derive(Clone, Debug, Eq, PartialEq)] pub struct CacheFlags { pub files: Vec, @@ -445,7 +438,7 @@ pub enum DenoSubcommand { Add(AddFlags), Remove(RemoveFlags), Bench(BenchFlags), - Bundle(BundleFlags), + Bundle, Cache(CacheFlags), Check(CheckFlags), Clean, @@ -1053,14 +1046,6 @@ impl Flags { }), .. }) - | DenoSubcommand::Bundle(BundleFlags { - watch: - Some(WatchFlags { - exclude: excluded_paths, - .. - }), - .. - }) | DenoSubcommand::Bench(BenchFlags { watch: Some(WatchFlags { @@ -1656,30 +1641,10 @@ glob {*_,*.,}bench.{js,mjs,ts,mts,jsx,tsx}: } fn bundle_subcommand() -> Command { - command("bundle", "⚠️ Warning: `deno bundle` is deprecated and will be removed in Deno 2.0. -Use an alternative bundler like \"deno_emit\", \"esbuild\" or \"rollup\" instead. - -Output a single JavaScript file with all dependencies. - deno bundle jsr:@std/http/file-server file_server.bundle.js + command("bundle", "⚠️ `deno bundle` was removed in Deno 2. -If no output file is given, the output is written to standard output: - deno bundle jsr:@std/http/file-server", UnstableArgsConfig::ResolutionOnly) +See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations", UnstableArgsConfig::ResolutionOnly) .hide(true) - .defer(|cmd| { - compile_args(cmd) - .hide(true) - .arg(check_arg(true)) - .arg( - Arg::new("source_file") - .required_unless_present("help") - .value_hint(ValueHint::FilePath), - ) - .arg(Arg::new("out_file").value_hint(ValueHint::FilePath)) - .arg(watch_arg(false)) - .arg(watch_exclude_arg()) - .arg(no_clear_screen_arg()) - .arg(executable_ext_arg()) - }) } fn cache_subcommand() -> Command { @@ -4077,29 +4042,8 @@ fn bench_parse(flags: &mut Flags, matches: &mut ArgMatches) { }); } -fn bundle_parse(flags: &mut Flags, matches: &mut ArgMatches) { - flags.type_check_mode = TypeCheckMode::Local; - - compile_args_parse(flags, matches); - unstable_args_parse(flags, matches, UnstableArgsConfig::ResolutionOnly); - - let source_file = matches.remove_one::("source_file").unwrap(); - - let out_file = - if let Some(out_file) = matches.remove_one::("out_file") { - flags.permissions.allow_write = Some(vec![]); - Some(out_file) - } else { - None - }; - - ext_arg_parse(flags, matches); - - flags.subcommand = DenoSubcommand::Bundle(BundleFlags { - source_file, - out_file, - watch: watch_arg_parse(matches), - }); +fn bundle_parse(flags: &mut Flags, _matches: &mut ArgMatches) { + flags.subcommand = DenoSubcommand::Bundle; } fn cache_parse(flags: &mut Flags, matches: &mut ArgMatches) { @@ -7721,174 +7665,6 @@ mod tests { assert!(r.is_err(), "Should reject adjacent commas"); } - #[test] - fn bundle() { - let r = flags_from_vec(svec!["deno", "bundle", "source.ts"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::Local, - ..Flags::default() - } - ); - } - - #[test] - fn bundle_with_config() { - let r = flags_from_vec(svec![ - "deno", - "bundle", - "--no-remote", - "--config", - "tsconfig.json", - "source.ts", - "bundle.js" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: Some("bundle.js".to_string()), - watch: Default::default(), - }), - permissions: PermissionFlags { - allow_write: Some(vec![]), - ..Default::default() - }, - no_remote: true, - type_check_mode: TypeCheckMode::Local, - config_flag: ConfigFlag::Path("tsconfig.json".to_owned()), - ..Flags::default() - } - ); - } - - #[test] - fn bundle_with_output() { - let r = flags_from_vec(svec!["deno", "bundle", "source.ts", "bundle.js"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: Some("bundle.js".to_string()), - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::Local, - permissions: PermissionFlags { - allow_write: Some(vec![]), - ..Default::default() - }, - ..Flags::default() - } - ); - } - - #[test] - fn bundle_with_lock() { - let r = - flags_from_vec(svec!["deno", "bundle", "--lock=lock.json", "source.ts"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::Local, - lock: Some(String::from("lock.json")), - ..Flags::default() - } - ); - } - - #[test] - fn bundle_with_reload() { - let r = flags_from_vec(svec!["deno", "bundle", "--reload", "source.ts"]); - assert_eq!( - r.unwrap(), - Flags { - reload: true, - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::Local, - ..Flags::default() - } - ); - } - - #[test] - fn bundle_nocheck() { - let r = flags_from_vec(svec!["deno", "bundle", "--no-check", "script.ts"]) - .unwrap(); - assert_eq!( - r, - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "script.ts".to_string(), - out_file: None, - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::None, - ..Flags::default() - } - ); - } - - #[test] - fn bundle_watch() { - let r = flags_from_vec(svec!["deno", "bundle", "--watch", "source.ts"]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Some(Default::default()), - }), - type_check_mode: TypeCheckMode::Local, - ..Flags::default() - } - ) - } - - #[test] - fn bundle_watch_with_no_clear_screen() { - let r = flags_from_vec(svec![ - "deno", - "bundle", - "--watch", - "--no-clear-screen", - "source.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Some(WatchFlags { - hmr: false, - no_clear_screen: true, - exclude: vec![], - }), - }), - type_check_mode: TypeCheckMode::Local, - ..Flags::default() - } - ) - } - #[test] fn run_import_map() { let r = flags_from_vec(svec![ @@ -9388,30 +9164,6 @@ mod tests { ); } - #[test] - fn bundle_with_cafile() { - let r = flags_from_vec(svec![ - "deno", - "bundle", - "--cert", - "example.crt", - "source.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Bundle(BundleFlags { - source_file: "source.ts".to_string(), - out_file: None, - watch: Default::default(), - }), - type_check_mode: TypeCheckMode::Local, - ca_data: Some(CaData::File("example.crt".to_owned())), - ..Flags::default() - } - ); - } - #[test] fn upgrade_with_ca_file() { let r = flags_from_vec(svec!["deno", "upgrade", "--cert", "example.crt"]); diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 030b19d80..aed5bc1b2 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1136,9 +1136,6 @@ impl CliOptions { pub fn resolve_main_module(&self) -> Result { let main_module = match &self.flags.subcommand { - DenoSubcommand::Bundle(bundle_flags) => { - resolve_url_or_path(&bundle_flags.source_file, self.initial_cwd())? - } DenoSubcommand::Compile(compile_flags) => { resolve_url_or_path(&compile_flags.source_file, self.initial_cwd())? } @@ -1265,23 +1262,7 @@ impl CliOptions { &self, config_type: TsConfigType, ) -> Result { - let result = self.workspace().resolve_ts_config_for_emit(config_type); - - match result { - Ok(mut ts_config_for_emit) => { - if matches!(self.flags.subcommand, DenoSubcommand::Bundle(..)) { - // For backwards compatibility, force `experimentalDecorators` setting - // to true. - *ts_config_for_emit - .ts_config - .0 - .get_mut("experimentalDecorators") - .unwrap() = serde_json::Value::Bool(true); - } - Ok(ts_config_for_emit) - } - Err(err) => Err(err), - } + self.workspace().resolve_ts_config_for_emit(config_type) } pub fn resolve_inspector_server( -- cgit v1.2.3