1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-27 16:10:57 -05:00

BREAKING: remove deno bundle (#25339)

`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
```
This commit is contained in:
Asher Gomez 2024-09-03 01:27:37 +10:00 committed by GitHub
parent 503f95a54f
commit bc51eca700
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
99 changed files with 35 additions and 1769 deletions

View file

@ -98,13 +98,6 @@ pub struct BenchFlags {
pub watch: Option<WatchFlags>, 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)] #[derive(Clone, Debug, Eq, PartialEq)]
pub struct CacheFlags { pub struct CacheFlags {
pub files: Vec<String>, pub files: Vec<String>,
@ -445,7 +438,7 @@ pub enum DenoSubcommand {
Add(AddFlags), Add(AddFlags),
Remove(RemoveFlags), Remove(RemoveFlags),
Bench(BenchFlags), Bench(BenchFlags),
Bundle(BundleFlags), Bundle,
Cache(CacheFlags), Cache(CacheFlags),
Check(CheckFlags), Check(CheckFlags),
Clean, Clean,
@ -1053,14 +1046,6 @@ impl Flags {
}), }),
.. ..
}) })
| DenoSubcommand::Bundle(BundleFlags {
watch:
Some(WatchFlags {
exclude: excluded_paths,
..
}),
..
})
| DenoSubcommand::Bench(BenchFlags { | DenoSubcommand::Bench(BenchFlags {
watch: watch:
Some(WatchFlags { Some(WatchFlags {
@ -1656,30 +1641,10 @@ glob {*_,*.,}bench.{js,mjs,ts,mts,jsx,tsx}:
} }
fn bundle_subcommand() -> Command { fn bundle_subcommand() -> Command {
command("bundle", "⚠️ Warning: `deno bundle` is deprecated and will be removed in Deno 2.0. command("bundle", "⚠️ `deno bundle` was removed in Deno 2.
Use an alternative bundler like \"deno_emit\", \"esbuild\" or \"rollup\" instead.
Output a single JavaScript file with all dependencies. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations", UnstableArgsConfig::ResolutionOnly)
deno bundle jsr:@std/http/file-server file_server.bundle.js
If no output file is given, the output is written to standard output:
deno bundle jsr:@std/http/file-server", UnstableArgsConfig::ResolutionOnly)
.hide(true) .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 { 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) { fn bundle_parse(flags: &mut Flags, _matches: &mut ArgMatches) {
flags.type_check_mode = TypeCheckMode::Local; flags.subcommand = DenoSubcommand::Bundle;
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 cache_parse(flags: &mut Flags, matches: &mut ArgMatches) { fn cache_parse(flags: &mut Flags, matches: &mut ArgMatches) {
@ -7721,174 +7665,6 @@ mod tests {
assert!(r.is_err(), "Should reject adjacent commas"); 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] #[test]
fn run_import_map() { fn run_import_map() {
let r = flags_from_vec(svec![ 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] #[test]
fn upgrade_with_ca_file() { fn upgrade_with_ca_file() {
let r = flags_from_vec(svec!["deno", "upgrade", "--cert", "example.crt"]); let r = flags_from_vec(svec!["deno", "upgrade", "--cert", "example.crt"]);

View file

@ -1136,9 +1136,6 @@ impl CliOptions {
pub fn resolve_main_module(&self) -> Result<ModuleSpecifier, AnyError> { pub fn resolve_main_module(&self) -> Result<ModuleSpecifier, AnyError> {
let main_module = match &self.flags.subcommand { 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) => { DenoSubcommand::Compile(compile_flags) => {
resolve_url_or_path(&compile_flags.source_file, self.initial_cwd())? resolve_url_or_path(&compile_flags.source_file, self.initial_cwd())?
} }
@ -1265,23 +1262,7 @@ impl CliOptions {
&self, &self,
config_type: TsConfigType, config_type: TsConfigType,
) -> Result<TsConfigForEmit, AnyError> { ) -> Result<TsConfigForEmit, AnyError> {
let result = self.workspace().resolve_ts_config_for_emit(config_type); 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),
}
} }
pub fn resolve_inspector_server( pub fn resolve_inspector_server(

View file

@ -143,29 +143,6 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
], ],
None, None,
), ),
(
"bundle",
&[
"bundle",
"--unstable",
"--config",
"tests/config/deno.json",
"tests/util/std/http/file_server_test.ts",
],
None,
),
(
"bundle_no_check",
&[
"bundle",
"--no-check",
"--unstable",
"--config",
"tests/config/deno.json",
"tests/util/std/http/file_server_test.ts",
],
None,
),
]; ];
const RESULT_KEYS: &[&str] = const RESULT_KEYS: &[&str] =
@ -314,40 +291,6 @@ fn get_binary_sizes(target_dir: &Path) -> Result<HashMap<String, i64>> {
Ok(sizes) Ok(sizes)
} }
const BUNDLES: &[(&str, &str)] = &[
("file_server", "./tests/util/std/http/file_server.ts"),
("welcome", "./tests/testdata/welcome.ts"),
];
fn bundle_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> {
let mut sizes = HashMap::<String, i64>::new();
for (name, url) in BUNDLES {
let path = format!("{name}.bundle.js");
test_util::run(
&[
deno_exe.to_str().unwrap(),
"bundle",
"--unstable",
"--config",
"tests/config/deno.json",
url,
&path,
],
None,
None,
None,
true,
);
let file = PathBuf::from(path);
assert!(file.is_file());
sizes.insert(name.to_string(), file.metadata()?.len() as i64);
let _ = fs::remove_file(file);
}
Ok(sizes)
}
fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> { fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> {
let mut results = HashMap::<String, i64>::new(); let mut results = HashMap::<String, i64>::new();
@ -415,7 +358,6 @@ async fn main() -> Result<()> {
let mut args = env::args(); let mut args = env::args();
let mut benchmarks = vec![ let mut benchmarks = vec![
"bundle",
"exec_time", "exec_time",
"binary_size", "binary_size",
"cargo_deps", "cargo_deps",
@ -465,11 +407,6 @@ async fn main() -> Result<()> {
..Default::default() ..Default::default()
}; };
if benchmarks.contains(&"bundle") {
let bundle_size = bundle_benchmark(&deno_exe)?;
new_data.bundle_size = bundle_size;
}
if benchmarks.contains(&"exec_time") { if benchmarks.contains(&"exec_time") {
let exec_times = run_exec_time(&deno_exe, &target_dir)?; let exec_times = run_exec_time(&deno_exe, &target_dir)?;
new_data.benchmark = exec_times; new_data.benchmark = exec_times;

View file

@ -26,7 +26,6 @@ use deno_graph::ModuleLoadError;
use deno_graph::WorkspaceFastCheckOption; use deno_graph::WorkspaceFastCheckOption;
use deno_runtime::fs_util::specifier_to_file_path; use deno_runtime::fs_util::specifier_to_file_path;
use deno_core::anyhow::bail;
use deno_core::error::custom_error; use deno_core::error::custom_error;
use deno_core::error::AnyError; use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex; use deno_core::parking_lot::Mutex;
@ -35,7 +34,6 @@ use deno_graph::source::Loader;
use deno_graph::source::ResolutionMode; use deno_graph::source::ResolutionMode;
use deno_graph::source::ResolveError; use deno_graph::source::ResolveError;
use deno_graph::GraphKind; use deno_graph::GraphKind;
use deno_graph::Module;
use deno_graph::ModuleError; use deno_graph::ModuleError;
use deno_graph::ModuleGraph; use deno_graph::ModuleGraph;
use deno_graph::ModuleGraphError; use deno_graph::ModuleGraphError;
@ -722,23 +720,6 @@ impl ModuleGraphBuilder {
} }
} }
pub fn error_for_any_npm_specifier(
graph: &ModuleGraph,
) -> Result<(), AnyError> {
for module in graph.modules() {
match module {
Module::Npm(module) => {
bail!("npm specifiers have not yet been implemented for this subcommand (https://github.com/denoland/deno/issues/15960). Found: {}", module.specifier)
}
Module::Node(module) => {
bail!("Node specifiers have not yet been implemented for this subcommand (https://github.com/denoland/deno/issues/15960). Found: node:{}", module.module_name)
}
Module::Js(_) | Module::Json(_) | Module::External(_) => {}
}
}
Ok(())
}
/// Adds more explanatory information to a resolution error. /// Adds more explanatory information to a resolution error.
pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String { pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String {
let mut message = format_deno_graph_error(error); let mut message = format_deno_graph_error(error);

View file

@ -110,9 +110,7 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
tools::bench::run_benchmarks(flags, bench_flags).await tools::bench::run_benchmarks(flags, bench_flags).await
} }
}), }),
DenoSubcommand::Bundle(bundle_flags) => spawn_subcommand(async { DenoSubcommand::Bundle => exit_with_message("⚠️ `deno bundle` was removed in Deno 2.\n\nSee the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations", 1),
tools::bundle::bundle(flags, bundle_flags).await
}),
DenoSubcommand::Doc(doc_flags) => { DenoSubcommand::Doc(doc_flags) => {
spawn_subcommand(async { tools::doc::doc(flags, doc_flags).await }) spawn_subcommand(async { tools::doc::doc(flags, doc_flags).await })
} }

View file

@ -1,164 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use std::path::PathBuf;
use std::sync::Arc;
use deno_core::error::AnyError;
use deno_graph::Module;
use deno_terminal::colors;
use crate::args::BundleFlags;
use crate::args::CliOptions;
use crate::args::Flags;
use crate::args::TsConfigType;
use crate::factory::CliFactory;
use crate::graph_util::error_for_any_npm_specifier;
use crate::util;
use crate::util::display;
pub async fn bundle(
flags: Arc<Flags>,
bundle_flags: BundleFlags,
) -> Result<(), AnyError> {
log::info!(
"{}",
colors::yellow("⚠️ Warning: `deno bundle` is deprecated and will be removed in Deno 2.0.\nUse an alternative bundler like \"deno_emit\", \"esbuild\" or \"rollup\" instead."),
);
if let Some(watch_flags) = &bundle_flags.watch {
util::file_watcher::watch_func(
flags,
util::file_watcher::PrintConfig::new(
"Bundle",
!watch_flags.no_clear_screen,
),
move |flags, watcher_communicator, _changed_paths| {
let bundle_flags = bundle_flags.clone();
Ok(async move {
let factory = CliFactory::from_flags_for_watcher(
flags,
watcher_communicator.clone(),
);
let cli_options = factory.cli_options()?;
let _ = watcher_communicator.watch_paths(cli_options.watch_paths());
bundle_action(factory, &bundle_flags).await?;
Ok(())
})
},
)
.await?;
} else {
let factory = CliFactory::from_flags(flags);
bundle_action(factory, &bundle_flags).await?;
}
Ok(())
}
async fn bundle_action(
factory: CliFactory,
bundle_flags: &BundleFlags,
) -> Result<(), AnyError> {
let cli_options = factory.cli_options()?;
let module_specifier = cli_options.resolve_main_module()?;
log::debug!(">>>>> bundle START");
let module_graph_creator = factory.module_graph_creator().await?;
let cli_options = factory.cli_options()?;
let graph = module_graph_creator
.create_graph_and_maybe_check(vec![module_specifier.clone()])
.await?;
let mut paths_to_watch: Vec<PathBuf> = graph
.specifiers()
.filter_map(|(_, r)| {
r.ok().and_then(|module| match module {
Module::Js(m) => m.specifier.to_file_path().ok(),
Module::Json(m) => m.specifier.to_file_path().ok(),
// nothing to watch
Module::Node(_) | Module::Npm(_) | Module::External(_) => None,
})
})
.collect();
if let Ok(Some(import_map_path)) = cli_options
.resolve_specified_import_map_specifier()
.map(|ms| ms.and_then(|ref s| s.to_file_path().ok()))
{
paths_to_watch.push(import_map_path);
}
// at the moment, we don't support npm specifiers in deno bundle, so show an error
error_for_any_npm_specifier(&graph)?;
let bundle_output = bundle_module_graph(graph.as_ref(), cli_options)?;
log::debug!(">>>>> bundle END");
let out_file = &bundle_flags.out_file;
if let Some(out_file) = out_file {
let out_file = cli_options.initial_cwd().join(out_file);
let output_bytes = bundle_output.code.as_bytes();
let output_len = output_bytes.len();
util::fs::write_file(&out_file, output_bytes, 0o644)?;
log::info!(
"{} {:?} ({})",
colors::green("Emit"),
out_file,
colors::gray(display::human_size(output_len as f64))
);
if let Some(bundle_map) = bundle_output.maybe_map {
let map_bytes = bundle_map.as_bytes();
let map_len = map_bytes.len();
let ext = if let Some(curr_ext) = out_file.extension() {
format!("{}.map", curr_ext.to_string_lossy())
} else {
"map".to_string()
};
let map_out_file = out_file.with_extension(ext);
util::fs::write_file(&map_out_file, map_bytes, 0o644)?;
log::info!(
"{} {:?} ({})",
colors::green("Emit"),
map_out_file,
colors::gray(display::human_size(map_len as f64))
);
}
} else {
#[allow(clippy::print_stdout)]
{
println!("{}", bundle_output.code);
}
}
Ok(())
}
fn bundle_module_graph(
graph: &deno_graph::ModuleGraph,
cli_options: &CliOptions,
) -> Result<deno_emit::BundleEmit, AnyError> {
log::info!("{} {}", colors::green("Bundle"), graph.roots[0]);
let ts_config_result =
cli_options.resolve_ts_config_for_emit(TsConfigType::Bundle)?;
if !cli_options.type_check_mode().is_true() {
if let Some(ignored_options) = ts_config_result.maybe_ignored_options {
log::warn!("{}", ignored_options);
}
}
let (transpile_options, emit_options) =
crate::args::ts_config_to_transpile_and_emit_options(
ts_config_result.ts_config,
)?;
deno_emit::bundle_graph(
graph,
deno_emit::BundleOptions {
minify: false,
bundle_type: deno_emit::BundleType::Module,
emit_options,
emit_ignore_directives: true,
transpile_options,
},
)
}

View file

@ -1,7 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
pub mod bench; pub mod bench;
pub mod bundle;
pub mod check; pub mod check;
pub mod clean; pub mod clean;
pub mod compile; pub mod compile;

View file

@ -1099,7 +1099,6 @@ const kNodeFlagsMap = new Map([
const kDenoSubcommands = new Set([ const kDenoSubcommands = new Set([
"add", "add",
"bench", "bench",
"bundle",
"cache", "cache",
"check", "check",
"compile", "compile",

View file

@ -1,476 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util;
use test_util::assert_contains;
use test_util::assert_ends_with;
use test_util::itest;
use test_util::TempDir;
#[test]
fn bundle_exports() {
// First we have to generate a bundle of some module that has exports.
let mod1 = util::testdata_path().join("subdir/mod1.ts");
assert!(mod1.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod1.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(mod1)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
std::fs::write(
&test,
"
import { printHello3 } from \"./mod1.bundle.js\";
printHello3(); ",
)
.unwrap();
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_exports_no_check() {
// First we have to generate a bundle of some module that has exports.
let mod1 = util::testdata_path().join("subdir/mod1.ts");
assert!(mod1.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod1.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(mod1)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
std::fs::write(
&test,
"
import { printHello3 } from \"./mod1.bundle.js\";
printHello3(); ",
)
.unwrap();
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_circular() {
// First we have to generate a bundle of some module that has exports.
let circular1_path = util::testdata_path().join("subdir/circular1.ts");
assert!(circular1_path.is_file());
let t = TempDir::new();
let bundle_path = t.path().join("circular1.bundle.js");
// run this twice to ensure it works even when cached
for _ in 0..2 {
let mut deno = util::deno_cmd_with_deno_dir(&t)
.current_dir(util::testdata_path())
.arg("bundle")
.arg(&circular1_path)
.arg(&bundle_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle_path.is_file());
}
let output = util::deno_cmd_with_deno_dir(&t)
.current_dir(util::testdata_path())
.arg("run")
.arg(&bundle_path)
.output()
.unwrap();
// check the output of the bundle program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"f2\nf1",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_single_module() {
// First we have to generate a bundle of some module that has exports.
let single_module = util::testdata_path().join("subdir/single_module.ts");
assert!(single_module.is_file());
let t = TempDir::new();
let bundle = t.path().join("single_module.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(single_module)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
.unwrap();
// check the output of the bundle program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello world!",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_tla() {
// First we have to generate a bundle of some module that has exports.
let tla_import = util::testdata_path().join("subdir/tla.ts");
assert!(tla_import.is_file());
let t = TempDir::new();
let bundle = t.path().join("tla.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(tla_import)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
std::fs::write(
&test,
"
import { foo } from \"./tla.bundle.js\";
console.log(foo); ",
)
.unwrap();
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_js() {
// First we have to generate a bundle of some module that has exports.
let mod6 = util::testdata_path().join("subdir/mod6.js");
assert!(mod6.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod6.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(mod6)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
.unwrap();
// check that nothing went to stderr
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_dynamic_import() {
let _g = util::http_server();
let dynamic_import = util::testdata_path().join("bundle/dynamic_import.ts");
assert!(dynamic_import.is_file());
let t = TempDir::new();
let output_path = t.path().join("bundle_dynamic_import.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(dynamic_import)
.arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(output_path.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg("--allow-net")
.arg("--quiet")
.arg(&output_path)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_import_map() {
let import = util::testdata_path().join("bundle/import_map/main.ts");
let import_map_path =
util::testdata_path().join("bundle/import_map/import_map.json");
assert!(import.is_file());
let t = TempDir::new();
let output_path = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg("--import-map")
.arg(import_map_path)
.arg(import)
.arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(output_path.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
std::fs::write(
&test,
"
import { printHello3 } from \"./import_map.bundle.js\";
printHello3(); ",
)
.unwrap();
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg("--check")
.arg(&test)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_import_map_no_check() {
let import = util::testdata_path().join("bundle/import_map/main.ts");
let import_map_path =
util::testdata_path().join("bundle/import_map/import_map.json");
assert!(import.is_file());
let t = TempDir::new();
let output_path = t.path().join("import_map.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg("--import-map")
.arg(import_map_path)
.arg(import)
.arg(&output_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(output_path.is_file());
// Now we try to use that bundle from another module.
let test = t.path().join("test.js");
std::fs::write(
&test,
"
import { printHello3 } from \"./import_map.bundle.js\";
printHello3(); ",
)
.unwrap();
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&test)
.output()
.unwrap();
// check the output of the test.ts program.
assert_ends_with!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
"Hello",
);
assert_eq!(output.stderr, b"");
}
#[test]
fn bundle_json_module() {
// First we have to generate a bundle of some module that has exports.
let mod7 = util::testdata_path().join("subdir/mod7.js");
assert!(mod7.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod7.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(mod7)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
.unwrap();
// check that nothing went to stderr
assert_eq!(output.stderr, b"");
// ensure the output looks right
assert_contains!(String::from_utf8(output.stdout).unwrap(), "with space",);
}
#[test]
fn bundle_json_module_escape_sub() {
// First we have to generate a bundle of some module that has exports.
let mod8 = util::testdata_path().join("subdir/mod8.js");
assert!(mod8.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod8.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("bundle")
.arg(mod8)
.arg(&bundle)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
assert!(status.success());
assert!(bundle.is_file());
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg(&bundle)
.output()
.unwrap();
// check that nothing went to stderr
assert_eq!(output.stderr, b"");
// make sure the output looks right and the escapes were effective
assert_contains!(
String::from_utf8(output.stdout).unwrap(),
"${globalThis}`and string literal`",
);
}
itest!(bundle {
args: "bundle subdir/mod1.ts",
output: "bundle/bundle.test.out",
});
itest!(bundle_jsx {
args: "bundle run/jsx_import_from_ts.ts",
output: "bundle/jsx.out",
});
itest!(error_bundle_with_bare_import {
args: "bundle bundle/bare_imports/error_with_bare_import.ts",
output: "bundle/bare_imports/error_with_bare_import.ts.out",
exit_code: 1,
});
itest!(ts_decorators_bundle {
args: "bundle bundle/decorators/ts_decorators.ts",
output: "bundle/decorators/ts_decorators.out",
});
itest!(bundle_export_specifier_with_alias {
args: "bundle bundle/file_tests-fixture16.ts",
output: "bundle/fixture16.out",
});
itest!(bundle_ignore_directives {
args: "bundle subdir/mod1.ts",
output: "bundle/ignore_directives.test.out",
});
itest!(check_local_by_default_no_errors {
args: "bundle --quiet bundle/check_local_by_default/no_errors.ts",
output: "bundle/check_local_by_default/no_errors.out",
http_server: true,
});
itest!(check_local_by_default_type_error {
args: "bundle --quiet bundle/check_local_by_default/type_error.ts",
output: "bundle/check_local_by_default/type_error.out",
http_server: true,
exit_code: 1,
});
itest!(ts_without_extension {
args: "bundle --ext ts file_extensions/ts_without_extension",
output: "bundle/file_extensions/ts_without_extension.out",
});
itest!(js_without_extension {
args: "bundle --ext js file_extensions/js_without_extension",
output: "bundle/file_extensions/js_without_extension.out",
});
itest!(bundle_shebang_file {
args: "bundle subdir/shebang_file.js",
output: "bundle/shebang_file.bundle.out",
});

View file

@ -37,11 +37,6 @@ itest!(check_jsximportsource_importmap_config {
output_str: Some(""), output_str: Some(""),
}); });
itest!(bundle_jsximportsource_importmap_config {
args: "bundle --quiet --config check/jsximportsource_importmap_config/deno.json check/jsximportsource_importmap_config/main.tsx",
output: "check/jsximportsource_importmap_config/main.bundle.js",
});
itest!(jsx_not_checked { itest!(jsx_not_checked {
args: "check check/jsx_not_checked/main.jsx", args: "check check/jsx_not_checked/main.jsx",
output: "check/jsx_not_checked/main.out", output: "check/jsx_not_checked/main.out",

View file

@ -1184,8 +1184,7 @@ fn lsp_deno_task() {
"deno.jsonc", "deno.jsonc",
r#"{ r#"{
"tasks": { "tasks": {
"build": "deno test", "build": "deno test"
"some:test": "deno bundle mod.ts"
} }
}"#, }"#,
); );
@ -1204,10 +1203,6 @@ fn lsp_deno_task() {
"name": "build", "name": "build",
"detail": "deno test", "detail": "deno test",
"sourceUri": temp_dir.url().join("deno.jsonc").unwrap(), "sourceUri": temp_dir.url().join("deno.jsonc").unwrap(),
}, {
"name": "some:test",
"detail": "deno bundle mod.ts",
"sourceUri": temp_dir.url().join("deno.jsonc").unwrap(),
} }
]) ])
); );

View file

@ -9,8 +9,6 @@
#[path = "bench_tests.rs"] #[path = "bench_tests.rs"]
mod bench; mod bench;
#[path = "bundle_tests.rs"]
mod bundle;
#[path = "cache_tests.rs"] #[path = "cache_tests.rs"]
mod cache; mod cache;
#[path = "check_tests.rs"] #[path = "check_tests.rs"]

View file

@ -10,8 +10,6 @@ use util::DenoChild;
use util::assert_not_contains; use util::assert_not_contains;
const CLEAR_SCREEN: &str = r#"[2J"#;
/// Logs to stderr every time next_line() is called /// Logs to stderr every time next_line() is called
struct LoggingLines<R> struct LoggingLines<R>
where where
@ -491,143 +489,6 @@ async fn fmt_check_all_files_on_each_change_test() {
check_alive_then_kill(child); check_alive_then_kill(child);
} }
#[flaky_test(tokio)]
async fn bundle_js_watch() {
use std::path::PathBuf;
// Test strategy extends this of test bundle_js by adding watcher
let t = TempDir::new();
let file_to_watch = t.path().join("file_to_watch.ts");
file_to_watch.write("console.log('Hello world');");
assert!(file_to_watch.is_file());
let t = TempDir::new();
let bundle = t.path().join("mod6.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(t.path())
.arg("bundle")
.arg(&file_to_watch)
.arg(&bundle)
.arg("--watch")
.env("NO_COLOR", "1")
.piped_output()
.spawn()
.unwrap();
let (_stdout_lines, mut stderr_lines) = child_lines(&mut deno);
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Warning");
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "deno_emit");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"Bundle started"
);
let line = next_line(&mut stderr_lines).await.unwrap();
assert_contains!(line, "file_to_watch.ts");
assert_contains!(line, "Check");
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Bundle");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"mod6.bundle.js"
);
let file = PathBuf::from(&bundle);
assert!(file.is_file());
wait_contains("Bundle finished", &mut stderr_lines).await;
file_to_watch.write("console.log('Hello world2');");
let line = next_line(&mut stderr_lines).await.unwrap();
// Should not clear screen, as we are in non-TTY environment
assert_not_contains!(&line, CLEAR_SCREEN);
assert_contains!(&line, "File change detected!");
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Check");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"file_to_watch.ts"
);
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"mod6.bundle.js"
);
let file = PathBuf::from(&bundle);
assert!(file.is_file());
wait_contains("Bundle finished", &mut stderr_lines).await;
// Confirm that the watcher keeps on working even if the file is updated and has invalid syntax
file_to_watch.write("syntax error ^^");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"File change detected!"
);
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "error: ");
wait_contains("Bundle failed", &mut stderr_lines).await;
check_alive_then_kill(deno);
}
/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
#[flaky_test(tokio)]
async fn bundle_watch_not_exit() {
let t = TempDir::new();
let file_to_watch = t.path().join("file_to_watch.ts");
file_to_watch.write("syntax error ^^");
let target_file = t.path().join("target.js");
let mut deno = util::deno_cmd()
.current_dir(t.path())
.arg("bundle")
.arg(&file_to_watch)
.arg(&target_file)
.arg("--watch")
.env("NO_COLOR", "1")
.piped_output()
.spawn()
.unwrap();
let (_stdout_lines, mut stderr_lines) = child_lines(&mut deno);
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Warning");
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "deno_emit");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"Bundle started"
);
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "error:");
assert_eq!(next_line(&mut stderr_lines).await.unwrap(), "");
assert_eq!(
next_line(&mut stderr_lines).await.unwrap(),
" syntax error ^^"
);
assert_eq!(
next_line(&mut stderr_lines).await.unwrap(),
" ~~~~~"
);
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"Bundle failed"
);
// the target file hasn't been created yet
assert!(!target_file.is_file());
// Make sure the watcher actually restarts and works fine with the proper syntax
file_to_watch.write("console.log(42);");
assert_contains!(
next_line(&mut stderr_lines).await.unwrap(),
"File change detected"
);
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Check");
let line = next_line(&mut stderr_lines).await.unwrap();
// Should not clear screen, as we are in non-TTY environment
assert_not_contains!(&line, CLEAR_SCREEN);
assert_contains!(line, "file_to_watch.ts");
assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "target.js");
wait_contains("Bundle finished", &mut stderr_lines).await;
// bundled file is created
assert!(target_file.is_file());
check_alive_then_kill(deno);
}
#[flaky_test(tokio)] #[flaky_test(tokio)]
async fn run_watch_no_dynamic() { async fn run_watch_no_dynamic() {
let t = TempDir::new(); let t = TempDir::new();

View file

@ -1,5 +0,0 @@
{
"args": "bundle --lock=check_error.json http://127.0.0.1:4545/subdir/mod1.ts",
"output": "check_error.out",
"exitCode": 10
}

View file

@ -1,5 +0,0 @@
{
"http://127.0.0.1:4545/subdir/mod1.ts": "bfc1037b02c99abc20367f739bca7455813a5950066abd77965bff33b6eece0f",
"http://127.0.0.1:4545/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
"http://127.0.0.1:4545/subdir/subdir2/mod2.ts": "bad"
}

View file

@ -1,12 +0,0 @@
[WILDCARD]
error: Integrity check failed for remote specifier. The source code is invalid, as it does not match the expected hash in the lock file.
Specifier: http://127.0.0.1:4545/subdir/subdir2/mod2.ts
Actual: 8b3b670d25d238dfa72df119140406b96766a00fee635f3606429fe065b18fd1
Expected: bad
This could be caused by:
* the lock file may be corrupt
* the source itself may be corrupt
Investigate the lockfile; delete it to regenerate the lockfile or --reload to reload the source code from the server.

View file

@ -0,0 +1,13 @@
{
"steps": [
{
"args": "bundle",
"output": "bundle.out",
"exitCode": 1
},
{
"args": "bundle --help",
"output": "bundle_help.out"
}
]
}

View file

@ -0,0 +1,3 @@
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

View file

@ -0,0 +1,10 @@
⚠️ `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

View file

@ -1,19 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDIzCCAgugAwIBAgIJAMKPPW4tsOymMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV
BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODIy
WhgPMjExODA5MjcxNjI4MjJaMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9FeGFt
cGxlLVJvb3QtQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMH/IO
2qtHfyBKwANNPB4K0q5JVSg8XxZdRpTTlz0CwU0oRO3uHrI52raCCfVeiQutyZop
eFZTDWeXGudGAFA2B5m3orWt0s+touPi8MzjsG2TQ+WSI66QgbXTNDitDDBtTVcV
5G3Ic+3SppQAYiHSekLISnYWgXLl+k5CnEfTowg6cjqjVr0KjL03cTN3H7b+6+0S
ws4rYbW1j4ExR7K6BFNH6572yq5qR20E6GqlY+EcOZpw4CbCk9lS8/CWuXze/vMs
OfDcc6K+B625d27wyEGZHedBomT2vAD7sBjvO8hn/DP1Qb46a8uCHR6NSfnJ7bXO
G1igaIbgY1zXirNdAgMBAAGjUDBOMB0GA1UdDgQWBBTzut+pwwDfqmMYcI9KNWRD
hxcIpTAfBgNVHSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAMBgNVHRMEBTAD
AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB9AqSbZ+hEglAgSHxAMCqRFdhVu7MvaQM0
P090mhGlOCt3yB7kdGfsIrUW6nQcTz7PPQFRaJMrFHPvFvPootkBUpTYR4hTkdce
H6RCRu2Jxl4Y9bY/uezd9YhGCYfUtfjA6/TH9FcuZfttmOOlxOt01XfNvVMIR6RM
z/AYhd+DeOXjr35F/VHeVpnk+55L0PYJsm1CdEbOs5Hy1ecR7ACuDkXnbM4fpz9I
kyIWJwk2zJReKcJMgi1aIinDM9ao/dca1G99PHOw8dnr4oyoTiv8ao6PWiSRHHMi
MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi
-----END CERTIFICATE-----

View file

@ -1,11 +0,0 @@
{
"tempDir": true,
"steps": [{
"args": "bundle --cert RootCA.pem https://localhost:5545/subdir/mod1.ts mod1.bundle.js",
"flaky": true,
"output": "[WILDCARD]"
}, {
"args": "run --quiet --check test.js",
"output": "[WILDCARD]Hello\n"
}]
}

View file

@ -1,2 +0,0 @@
import { printHello3 } from "./mod1.bundle.js";
printHello3();

View file

@ -14,11 +14,6 @@
"import chalk from 'npm:chalk@5'; console.log(chalk.green('chalk esm loads'));" "import chalk from 'npm:chalk@5'; console.log(chalk.green('chalk esm loads'));"
], ],
"output": "main.out" "output": "main.out"
},
"bundle": {
"args": "bundle --quiet main.js",
"output": "bundle.out",
"exitCode": 1
} }
} }
} }

View file

@ -1 +0,0 @@
error: npm specifiers have not yet been implemented for this subcommand (https://github.com/denoland/deno/issues/15960). Found: npm:/chalk@5.0.1

View file

@ -1 +0,0 @@
import "foo";

View file

@ -1,2 +0,0 @@
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
at file:///[WILDCARD]/error_with_bare_import.ts:[WILDCARD]

View file

@ -1,27 +0,0 @@
[WILDCARD]
function printHello() {
console.log("Hello");
}
function returnsFoo() {
return "Foo";
}
function printHello2() {
printHello();
}
function returnsHi() {
return "Hi";
}
function returnsFoo2() {
return returnsFoo();
}
function printHello3() {
printHello2();
}
function throwsError() {
throw Error("exception from mod1");
}
export { returnsHi as returnsHi };
export { returnsFoo2 as returnsFoo2 };
export { printHello3 as printHello3 };
export { throwsError as throwsError };

View file

@ -1,6 +0,0 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
console.log(12);

View file

@ -1,3 +0,0 @@
import * as a from "http://localhost:4545/subdir/type_error.ts";
console.log(a.a);

View file

@ -1,4 +0,0 @@
error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'.
const b: "b" = 12;
^
at [WILDCARD]bundle/check_local_by_default/type_error.ts:3:7

View file

@ -1,6 +0,0 @@
import * as a from "http://localhost:4545/subdir/type_error.ts";
const b: "b" = 12;
console.log(a.a);
console.log(b);

View file

@ -1,49 +0,0 @@
[WILDCARD]
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function a() {
console.log("a(): evaluated");
return (_target, _propertyKey, _descriptor)=>{
console.log("a(): called");
};
}
class B {
method() {
console.log("method");
}
}
_ts_decorate([
a()
], B.prototype, "method", null);
function _ts_decorate1(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function Decorator() {
return function(target, propertyKey, descriptor) {
const originalFn = descriptor.value;
descriptor.value = async function(...args) {
return await originalFn.apply(this, args);
};
return descriptor;
};
}
class SomeClass {
async test() {}
}
_ts_decorate1([
Decorator()
], SomeClass.prototype, "test", null);
new SomeClass().test();
new B().method();
[WILDCARD]

View file

@ -1,25 +0,0 @@
// deno-lint-ignore-file
import { B } from "../../subdir/more_decorators.ts";
function Decorator() {
return function (
target: Record<string, any>,
propertyKey: string,
descriptor: TypedPropertyDescriptor<any>,
) {
const originalFn: Function = descriptor.value as Function;
descriptor.value = async function (...args: any[]) {
return await originalFn.apply(this, args);
};
return descriptor;
};
}
class SomeClass {
@Decorator()
async test() {}
}
new SomeClass().test();
new B().method();

View file

@ -1,3 +0,0 @@
const mod1 = await import("http://localhost:4545/subdir/mod1.ts");
mod1.printHello3();

View file

@ -1,8 +0,0 @@
[WILDCARD]
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
"hello";
console.log("executing javascript with no extension");

View file

@ -1,7 +0,0 @@
[WILDCARD]
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
console.log("executing typescript with no extension");

View file

@ -1,3 +0,0 @@
import * as a from "./subdir/a.ts";
console.log(a);

View file

@ -1,4 +0,0 @@
import * as b from "./subdir/b.ts";
console.log(b.b); // "b"
console.log(b.c); // { c: "c", default: class C }

View file

@ -1,3 +0,0 @@
import { d } from "./subdir/d.ts";
console.log(d);

View file

@ -1,3 +0,0 @@
const a = await import("./subdir/a.ts");
console.log(a);

View file

@ -1,3 +0,0 @@
import { a } from "./subdir/e.ts";
console.log(a);

View file

@ -1,4 +0,0 @@
import { isMain, modUrl } from "./subdir/f.ts";
console.log(isMain, modUrl);
console.log(import.meta.main, import.meta.url);

View file

@ -1,4 +0,0 @@
import { G } from "./subdir/g.ts";
import { H } from "./subdir/h.ts";
console.log(new G(true), new H(true));

View file

@ -1 +0,0 @@
export * as a from "./subdir/a.ts";

View file

@ -1 +0,0 @@
export { a } from "./subdir/k.ts";

View file

@ -1,7 +0,0 @@
import { a as defaultA } from "./subdir/l.ts";
const o: { a?: string } = {};
const { a = defaultA } = o;
console.log(a);

View file

@ -1,32 +0,0 @@
import { a as defaultA, O } from "./subdir/m.ts";
export { O } from "./subdir/m.ts";
interface AOptions {
a?();
c?: O;
}
class A {
#a: () => void;
#c?: O;
constructor(o: AOptions = {}) {
const {
a = defaultA,
c,
} = o;
this.#a = a;
this.#c = c;
}
a() {
this.#a();
}
c() {
console.log(this.#c);
}
}
const a = new A();
a.a();
a.c();

View file

@ -1,7 +0,0 @@
import { a } from "./subdir/p.ts";
function b() {
a();
}
b();

View file

@ -1,11 +0,0 @@
import { D, d } from "./subdir/q.ts";
class A {
private s: D = d();
a() {
this.s.resolve();
}
}
new A();

View file

@ -1,4 +0,0 @@
// @deno-types="https://deno.land/x/lib/mod.d.ts"
import * as lib from "https://deno.land/x/lib/mod.js";
console.log(lib);

View file

@ -1,3 +0,0 @@
export function getIndex(c: string): number {
return "\x00\r\n\x85\u2028\u2029".indexOf(c);
}

View file

@ -1,6 +0,0 @@
// todo(dsherret): use ./subdir/a.ts once fixtures are restored
export { a as test1 } from "./file_tests-fixture16_2.ts";
export { a as test2 } from "./file_tests-fixture16_2.ts";
import { a } from "./file_tests-fixture16_2.ts";
console.log(a);

View file

@ -1,2 +0,0 @@
// todo(dsherret): delete this and use ./subdir/a.ts in the file once fixtures are restored
export const a = "a";

View file

@ -1 +0,0 @@
export const a = "a";

View file

@ -1,3 +0,0 @@
export * as c from "./c.ts";
export const b = "b";

View file

@ -1,2 +0,0 @@
export const c = "c";
export default class C {}

View file

@ -1,3 +0,0 @@
import { a } from "./a.ts";
export const d = { a };

View file

@ -1 +0,0 @@
export * from "./a.ts";

View file

@ -1,2 +0,0 @@
export const isMain = import.meta.main;
export const modUrl = import.meta.url;

View file

@ -1,12 +0,0 @@
const g: number[] = [];
export class G {
#g!: number[];
constructor(shared: boolean) {
if (shared) {
this.#g = g;
} else {
this.#g = [];
}
}
}

View file

@ -1,12 +0,0 @@
const g: number[] = [];
export class H {
#g!: number[];
constructor(shared: boolean) {
if (shared) {
this.#g = g;
} else {
this.#g = [];
}
}
}

View file

@ -1,3 +0,0 @@
export function a(...d: string[]): string {
return d.join(" ");
}

View file

@ -1,3 +0,0 @@
export function a(...d: string[]): string {
return d.join("/");
}

View file

@ -1,11 +0,0 @@
import * as _i from "./i.ts";
import * as _j from "./j.ts";
const k = globalThis.value ? _i : _j;
export const i = _i;
export const j = _j;
export const {
a,
} = k;

View file

@ -1 +0,0 @@
export { a } from "./a.ts";

View file

@ -1,2 +0,0 @@
export { a } from "./n.ts";
export { O } from "./o.ts";

View file

@ -1,3 +0,0 @@
export function a() {
console.log("a");
}

View file

@ -1,5 +0,0 @@
export enum O {
A,
B,
C,
}

View file

@ -1 +0,0 @@
export * from "./i.ts";

View file

@ -1,13 +0,0 @@
// deno-lint-ignore-file
export interface D {
resolve: any;
reject: any;
}
export function d(): D {
let methods;
const promise = new Promise((resolve, reject) => {
methods = { resolve, reject };
});
return Object.assign(promise, methods);
}

View file

@ -1,7 +0,0 @@
const a = "a";
const mod = function() {
return {
a: a
};
}();
console.log(mod);

View file

@ -1,12 +0,0 @@
const c = "c";
class C {
}
const mod = function() {
return {
default: C,
c: c
};
}();
const b = "b";
console.log(b);
console.log(mod);

View file

@ -1,5 +0,0 @@
const a = "a";
const d = {
a
};
console.log(d);

View file

@ -1,2 +0,0 @@
const a = await import("./subdir/a.ts");
console.log(a);

View file

@ -1,2 +0,0 @@
const a = "a";
console.log(a);

View file

@ -1,12 +0,0 @@
const importMeta = {
url: "file:///tests/subdir/f.ts",
main: false
};
const isMain = importMeta.main;
const modUrl = importMeta.url;
const importMeta1 = {
url: "file:///tests/fixture06.ts",
main: import.meta.main
};
console.log(isMain, modUrl);
console.log(importMeta1.main, importMeta1.url);

View file

@ -1,23 +0,0 @@
const g = [];
class G {
#g;
constructor(shared){
if (shared) {
this.#g = g;
} else {
this.#g = [];
}
}
}
const g1 = [];
class H {
#g;
constructor(shared1){
if (shared1) {
this.#g = g1;
} else {
this.#g = [];
}
}
}
console.log(new G(true), new H(true));

View file

@ -1,7 +0,0 @@
const a1 = "a";
const mod = function() {
return {
a: a1
};
}();
export { mod as a };

View file

@ -1,19 +0,0 @@
function a3(...d) {
return d.join(" ");
}
const mod = function() {
return {
a: a3
};
}();
function a1(...d) {
return d.join("/");
}
const mod1 = function() {
return {
a: a1
};
}();
const k = globalThis.value ? mod : mod1;
const { a: a2 , } = k;
export { a2 as a };

View file

@ -1,5 +0,0 @@
const a = "a";
const o = {
};
const { a: a1 = a } = o;
console.log(a1);

View file

@ -1,30 +0,0 @@
function a() {
console.log("a");
}
var O1;
(function(O) {
O[O["A"] = 0] = "A";
O[O["B"] = 1] = "B";
O[O["C"] = 2] = "C";
})(O1 || (O1 = {
}));
export { O1 as O };
class A {
#a;
#c;
constructor(o = {
}){
const { a: a1 = a , c , } = o;
this.#a = a1;
this.#c = c;
}
a() {
this.#a();
}
c() {
console.log(this.#c);
}
}
const a2 = new A();
a2.a();
a2.c();

View file

@ -1,7 +0,0 @@
function a(...d) {
return d.join(" ");
}
function b() {
a();
}
b();

View file

@ -1,17 +0,0 @@
function d() {
let methods;
const promise = new Promise((resolve, reject)=>{
methods = {
resolve,
reject
};
});
return Object.assign(promise, methods);
}
class A {
s = d();
a() {
this.s.resolve();
}
}
new A();

View file

@ -1,2 +0,0 @@
const mod = [];
console.log(mod);

View file

@ -1,4 +0,0 @@
function getIndex1(c) {
return "\x00\r\n\x85\u2028\u2029".indexOf(c);
}
export { getIndex1 as getIndex };

View file

@ -1,6 +0,0 @@
[WILDCARD]
const a = "a";
export { a as test1 };
export { a as test2 };
console.log(a);

View file

@ -1 +0,0 @@
export const a: string[] = [];

View file

@ -1 +0,0 @@
export const b = [];

View file

@ -1 +0,0 @@
export const c: string[];

View file

@ -1,3 +0,0 @@
/// <reference types="./c.d.ts" />
export const c = [];

View file

@ -1,9 +0,0 @@
export * as a from "./a.ts";
export * as b from "./b.js";
export * as c from "./c.js";
export interface A {
a: string;
}
export const mod: A[];

View file

@ -1,5 +0,0 @@
export * as a from "./a.ts";
export * as b from "./b.js";
export * as c from "./c.js";
export const mod = [];

View file

@ -1,6 +0,0 @@
[WILDCARD]
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
[WILDCARD]

View file

@ -1,5 +0,0 @@
{
"imports": {
"mod2": "../../subdir/subdir2/mod2.ts"
}
}

View file

@ -1,17 +0,0 @@
import { printHello2, returnsFoo } from "mod2";
export function returnsHi(): string {
return "Hi";
}
export function returnsFoo2(): string {
return returnsFoo();
}
export function printHello3() {
printHello2();
}
export function throwsError() {
throw Error("exception from mod1");
}

View file

@ -1,9 +0,0 @@
[WILDCARD]
const React = {
createElement () {}
};
function app() {
return React.createElement("div", null, React.createElement("h2", null, "asdf"));
}
console.log(app);

View file

@ -1,12 +0,0 @@
⚠️ Warning: `deno bundle` is deprecated and will be removed in Deno 2.0.
Use an alternative bundler like "deno_emit", "esbuild" or "rollup" instead.
Bundle file:///[WILDCARD]/subdir/shebang_file.js
#!/usr/bin/env -S deno run --allow-read
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
for (const item of Deno.readDirSync(".")){
console.log(item.name);
}

View file

@ -1,9 +0,0 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
const makeParagraph = ()=>jsx("p", {
children: "A paragraph!"
});
export { makeParagraph as makeParagraph };

View file

@ -196,10 +196,9 @@ async function ensureNoNewITests() {
// replace them with spec tests. // replace them with spec tests.
const iTestCounts = { const iTestCounts = {
"bench_tests.rs": 0, "bench_tests.rs": 0,
"bundle_tests.rs": 11,
"cache_tests.rs": 0, "cache_tests.rs": 0,
"cert_tests.rs": 0, "cert_tests.rs": 0,
"check_tests.rs": 23, "check_tests.rs": 22,
"compile_tests.rs": 0, "compile_tests.rs": 0,
"coverage_tests.rs": 0, "coverage_tests.rs": 0,
"doc_tests.rs": 15, "doc_tests.rs": 15,