Skip to content

Commit

Permalink
BREAKING: remove deno bundle (#25339)
Browse files Browse the repository at this point in the history
`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
```
  • Loading branch information
iuioiua authored Sep 2, 2024
1 parent 503f95a commit bc51eca
Show file tree
Hide file tree
Showing 99 changed files with 35 additions and 1,769 deletions.
258 changes: 5 additions & 253 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ pub struct BenchFlags {
pub watch: Option<WatchFlags>,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BundleFlags {
pub source_file: String,
pub out_file: Option<String>,
pub watch: Option<WatchFlags>,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CacheFlags {
pub files: Vec<String>,
Expand Down Expand Up @@ -445,7 +438,7 @@ pub enum DenoSubcommand {
Add(AddFlags),
Remove(RemoveFlags),
Bench(BenchFlags),
Bundle(BundleFlags),
Bundle,
Cache(CacheFlags),
Check(CheckFlags),
Clean,
Expand Down Expand Up @@ -1053,14 +1046,6 @@ impl Flags {
}),
..
})
| DenoSubcommand::Bundle(BundleFlags {
watch:
Some(WatchFlags {
exclude: excluded_paths,
..
}),
..
})
| DenoSubcommand::Bench(BenchFlags {
watch:
Some(WatchFlags {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<String>("source_file").unwrap();

let out_file =
if let Some(out_file) = matches.remove_one::<String>("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) {
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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"]);
Expand Down
21 changes: 1 addition & 20 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@ impl CliOptions {

pub fn resolve_main_module(&self) -> Result<ModuleSpecifier, AnyError> {
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())?
}
Expand Down Expand Up @@ -1265,23 +1262,7 @@ impl CliOptions {
&self,
config_type: TsConfigType,
) -> Result<TsConfigForEmit, AnyError> {
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(
Expand Down
Loading

0 comments on commit bc51eca

Please sign in to comment.