mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
chore: cleanup code for deprecation notices in JS code (#25368)
This code hasn't been used in some time, so I cleaned as much of it as possible.
This commit is contained in:
parent
5f08d634f7
commit
e49d80e500
7 changed files with 9 additions and 164 deletions
|
@ -780,8 +780,6 @@ pub struct CliOptions {
|
||||||
maybe_lockfile: Option<Arc<CliLockfile>>,
|
maybe_lockfile: Option<Arc<CliLockfile>>,
|
||||||
overrides: CliOptionOverrides,
|
overrides: CliOptionOverrides,
|
||||||
pub start_dir: Arc<WorkspaceDirectory>,
|
pub start_dir: Arc<WorkspaceDirectory>,
|
||||||
pub disable_deprecated_api_warning: bool,
|
|
||||||
pub verbose_deprecated_api_warning: bool,
|
|
||||||
pub deno_dir_provider: Arc<DenoDirProvider>,
|
pub deno_dir_provider: Arc<DenoDirProvider>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,13 +822,6 @@ impl CliOptions {
|
||||||
|
|
||||||
load_env_variables_from_env_file(flags.env_file.as_ref());
|
load_env_variables_from_env_file(flags.env_file.as_ref());
|
||||||
|
|
||||||
let disable_deprecated_api_warning = flags.log_level
|
|
||||||
== Some(log::Level::Error)
|
|
||||||
|| std::env::var("DENO_NO_DEPRECATION_WARNINGS").ok().is_some();
|
|
||||||
|
|
||||||
let verbose_deprecated_api_warning =
|
|
||||||
std::env::var("DENO_VERBOSE_WARNINGS").ok().is_some();
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
flags,
|
flags,
|
||||||
initial_cwd,
|
initial_cwd,
|
||||||
|
@ -839,8 +830,6 @@ impl CliOptions {
|
||||||
maybe_node_modules_folder,
|
maybe_node_modules_folder,
|
||||||
overrides: Default::default(),
|
overrides: Default::default(),
|
||||||
start_dir,
|
start_dir,
|
||||||
disable_deprecated_api_warning,
|
|
||||||
verbose_deprecated_api_warning,
|
|
||||||
deno_dir_provider,
|
deno_dir_provider,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -866,10 +866,6 @@ impl CliFactory {
|
||||||
node_ipc: cli_options.node_ipc_fd(),
|
node_ipc: cli_options.node_ipc_fd(),
|
||||||
serve_port: cli_options.serve_port(),
|
serve_port: cli_options.serve_port(),
|
||||||
serve_host: cli_options.serve_host(),
|
serve_host: cli_options.serve_host(),
|
||||||
// TODO(bartlomieju): temporarily disabled
|
|
||||||
disable_deprecated_api_warning: true,
|
|
||||||
verbose_deprecated_api_warning: cli_options
|
|
||||||
.verbose_deprecated_api_warning,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,6 @@ pub struct Metadata {
|
||||||
pub workspace_resolver: SerializedWorkspaceResolver,
|
pub workspace_resolver: SerializedWorkspaceResolver,
|
||||||
pub entrypoint_key: String,
|
pub entrypoint_key: String,
|
||||||
pub node_modules: Option<NodeModules>,
|
pub node_modules: Option<NodeModules>,
|
||||||
pub disable_deprecated_api_warning: bool,
|
|
||||||
pub unstable_config: UnstableConfig,
|
pub unstable_config: UnstableConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,8 +623,6 @@ impl<'a> DenoCompileBinaryWriter<'a> {
|
||||||
pkg_json_resolution: self.workspace_resolver.pkg_json_dep_resolution(),
|
pkg_json_resolution: self.workspace_resolver.pkg_json_dep_resolution(),
|
||||||
},
|
},
|
||||||
node_modules,
|
node_modules,
|
||||||
disable_deprecated_api_warning: cli_options
|
|
||||||
.disable_deprecated_api_warning,
|
|
||||||
unstable_config: UnstableConfig {
|
unstable_config: UnstableConfig {
|
||||||
legacy_flag_enabled: cli_options.legacy_unstable_flag(),
|
legacy_flag_enabled: cli_options.legacy_unstable_flag(),
|
||||||
bare_node_builtins: cli_options.unstable_bare_node_builtins(),
|
bare_node_builtins: cli_options.unstable_bare_node_builtins(),
|
||||||
|
|
|
@ -737,9 +737,6 @@ pub async fn run(
|
||||||
node_ipc: None,
|
node_ipc: None,
|
||||||
serve_port: None,
|
serve_port: None,
|
||||||
serve_host: None,
|
serve_host: None,
|
||||||
// TODO(bartlomieju): temporarily disabled
|
|
||||||
disable_deprecated_api_warning: true,
|
|
||||||
verbose_deprecated_api_warning: false,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,6 @@ pub struct CliMainWorkerOptions {
|
||||||
pub node_ipc: Option<i64>,
|
pub node_ipc: Option<i64>,
|
||||||
pub serve_port: Option<u16>,
|
pub serve_port: Option<u16>,
|
||||||
pub serve_host: Option<String>,
|
pub serve_host: Option<String>,
|
||||||
pub disable_deprecated_api_warning: bool,
|
|
||||||
pub verbose_deprecated_api_warning: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SharedWorkerState {
|
struct SharedWorkerState {
|
||||||
|
@ -593,12 +591,6 @@ impl CliMainWorkerFactory {
|
||||||
argv0: shared.options.argv0.clone(),
|
argv0: shared.options.argv0.clone(),
|
||||||
node_debug: shared.options.node_debug.clone(),
|
node_debug: shared.options.node_debug.clone(),
|
||||||
node_ipc_fd: shared.options.node_ipc,
|
node_ipc_fd: shared.options.node_ipc,
|
||||||
disable_deprecated_api_warning: shared
|
|
||||||
.options
|
|
||||||
.disable_deprecated_api_warning,
|
|
||||||
verbose_deprecated_api_warning: shared
|
|
||||||
.options
|
|
||||||
.verbose_deprecated_api_warning,
|
|
||||||
future: shared.enable_future_features,
|
future: shared.enable_future_features,
|
||||||
mode,
|
mode,
|
||||||
serve_port: shared.options.serve_port,
|
serve_port: shared.options.serve_port,
|
||||||
|
@ -795,12 +787,6 @@ fn create_web_worker_callback(
|
||||||
argv0: shared.options.argv0.clone(),
|
argv0: shared.options.argv0.clone(),
|
||||||
node_debug: shared.options.node_debug.clone(),
|
node_debug: shared.options.node_debug.clone(),
|
||||||
node_ipc_fd: None,
|
node_ipc_fd: None,
|
||||||
disable_deprecated_api_warning: shared
|
|
||||||
.options
|
|
||||||
.disable_deprecated_api_warning,
|
|
||||||
verbose_deprecated_api_warning: shared
|
|
||||||
.options
|
|
||||||
.verbose_deprecated_api_warning,
|
|
||||||
future: shared.enable_future_features,
|
future: shared.enable_future_features,
|
||||||
mode: WorkerExecutionMode::Worker,
|
mode: WorkerExecutionMode::Worker,
|
||||||
serve_port: shared.options.serve_port,
|
serve_port: shared.options.serve_port,
|
||||||
|
|
|
@ -26,8 +26,6 @@ const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypePop,
|
|
||||||
ArrayPrototypeShift,
|
|
||||||
DateNow,
|
DateNow,
|
||||||
Error,
|
Error,
|
||||||
ErrorPrototype,
|
ErrorPrototype,
|
||||||
|
@ -43,11 +41,7 @@ const {
|
||||||
ObjectValues,
|
ObjectValues,
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
SafeSet,
|
|
||||||
StringPrototypeIncludes,
|
|
||||||
StringPrototypePadEnd,
|
StringPrototypePadEnd,
|
||||||
StringPrototypeSplit,
|
|
||||||
StringPrototypeTrim,
|
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
TypeError,
|
TypeError,
|
||||||
|
@ -116,104 +110,8 @@ ObjectDefineProperties(Symbol, {
|
||||||
let windowIsClosing = false;
|
let windowIsClosing = false;
|
||||||
let globalThis_;
|
let globalThis_;
|
||||||
|
|
||||||
let verboseDeprecatedApiWarning = false;
|
// TODO(2.0): remove once all deprecated APIs are removed.
|
||||||
let deprecatedApiWarningDisabled = false;
|
function warnOnDeprecatedApi() {}
|
||||||
const ALREADY_WARNED_DEPRECATED = new SafeSet();
|
|
||||||
|
|
||||||
function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
|
|
||||||
if (deprecatedApiWarningDisabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deno-lint-ignore no-console
|
|
||||||
const logError = console.error;
|
|
||||||
|
|
||||||
if (!verboseDeprecatedApiWarning) {
|
|
||||||
if (ALREADY_WARNED_DEPRECATED.has(apiName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ALREADY_WARNED_DEPRECATED.add(apiName);
|
|
||||||
logError(
|
|
||||||
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2. Run again with DENO_VERBOSE_WARNINGS=1 to get more details.`,
|
|
||||||
"color: yellow;",
|
|
||||||
"font-weight: bold;",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ALREADY_WARNED_DEPRECATED.has(apiName + stack)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we haven't warned yet, let's do some processing of the stack trace
|
|
||||||
// to make it more useful.
|
|
||||||
const stackLines = StringPrototypeSplit(stack, "\n");
|
|
||||||
ArrayPrototypeShift(stackLines);
|
|
||||||
while (stackLines.length > 0) {
|
|
||||||
// Filter out internal frames at the top of the stack - they are not useful
|
|
||||||
// to the user.
|
|
||||||
if (
|
|
||||||
StringPrototypeIncludes(stackLines[0], "(ext:") ||
|
|
||||||
StringPrototypeIncludes(stackLines[0], "(node:") ||
|
|
||||||
StringPrototypeIncludes(stackLines[0], "<anonymous>")
|
|
||||||
) {
|
|
||||||
ArrayPrototypeShift(stackLines);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now remove the last frame if it's coming from "ext:core" - this is most likely
|
|
||||||
// event loop tick or promise handler calling a user function - again not
|
|
||||||
// useful to the user.
|
|
||||||
if (
|
|
||||||
stackLines.length > 0 &&
|
|
||||||
StringPrototypeIncludes(stackLines[stackLines.length - 1], "(ext:core/")
|
|
||||||
) {
|
|
||||||
ArrayPrototypePop(stackLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
let isFromRemoteDependency = false;
|
|
||||||
const firstStackLine = stackLines[0];
|
|
||||||
if (firstStackLine && !StringPrototypeIncludes(firstStackLine, "file:")) {
|
|
||||||
isFromRemoteDependency = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALREADY_WARNED_DEPRECATED.add(apiName + stack);
|
|
||||||
logError(
|
|
||||||
`%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2.`,
|
|
||||||
"color: yellow;",
|
|
||||||
"font-weight: bold;",
|
|
||||||
);
|
|
||||||
|
|
||||||
logError();
|
|
||||||
logError(
|
|
||||||
"See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations",
|
|
||||||
);
|
|
||||||
logError();
|
|
||||||
if (stackLines.length > 0) {
|
|
||||||
logError("Stack trace:");
|
|
||||||
for (let i = 0; i < stackLines.length; i++) {
|
|
||||||
logError(` ${StringPrototypeTrim(stackLines[i])}`);
|
|
||||||
}
|
|
||||||
logError();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < suggestions.length; i++) {
|
|
||||||
const suggestion = suggestions[i];
|
|
||||||
logError(
|
|
||||||
`%chint: ${suggestion}`,
|
|
||||||
"font-weight: bold;",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFromRemoteDependency) {
|
|
||||||
logError(
|
|
||||||
`%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`,
|
|
||||||
"font-weight: bold;",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
logError();
|
|
||||||
}
|
|
||||||
|
|
||||||
function windowClose() {
|
function windowClose() {
|
||||||
if (!windowIsClosing) {
|
if (!windowIsClosing) {
|
||||||
|
@ -699,14 +597,12 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
||||||
6: hasNodeModulesDir,
|
6: hasNodeModulesDir,
|
||||||
7: argv0,
|
7: argv0,
|
||||||
8: nodeDebug,
|
8: nodeDebug,
|
||||||
9: shouldDisableDeprecatedApiWarning,
|
9: future,
|
||||||
10: shouldUseVerboseDeprecatedApiWarning,
|
10: mode,
|
||||||
11: future,
|
11: servePort,
|
||||||
12: mode,
|
12: serveHost,
|
||||||
13: servePort,
|
13: serveIsMain,
|
||||||
14: serveHost,
|
14: serveWorkerCount,
|
||||||
15: serveIsMain,
|
|
||||||
16: serveWorkerCount,
|
|
||||||
} = runtimeOptions;
|
} = runtimeOptions;
|
||||||
|
|
||||||
if (mode === executionModes.serve) {
|
if (mode === executionModes.serve) {
|
||||||
|
@ -797,8 +693,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
||||||
|
|
||||||
removeImportedOps();
|
removeImportedOps();
|
||||||
|
|
||||||
deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
|
|
||||||
verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
|
|
||||||
performance.setTimeOrigin(DateNow());
|
performance.setTimeOrigin(DateNow());
|
||||||
globalThis_ = globalThis;
|
globalThis_ = globalThis;
|
||||||
|
|
||||||
|
@ -980,9 +874,7 @@ function bootstrapWorkerRuntime(
|
||||||
6: hasNodeModulesDir,
|
6: hasNodeModulesDir,
|
||||||
7: argv0,
|
7: argv0,
|
||||||
8: nodeDebug,
|
8: nodeDebug,
|
||||||
9: shouldDisableDeprecatedApiWarning,
|
9: future,
|
||||||
10: shouldUseVerboseDeprecatedApiWarning,
|
|
||||||
11: future,
|
|
||||||
} = runtimeOptions;
|
} = runtimeOptions;
|
||||||
|
|
||||||
// TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete
|
// TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete
|
||||||
|
@ -990,8 +882,6 @@ function bootstrapWorkerRuntime(
|
||||||
// within the Deno namespace.
|
// within the Deno namespace.
|
||||||
internals.future = future;
|
internals.future = future;
|
||||||
|
|
||||||
deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
|
|
||||||
verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
|
|
||||||
performance.setTimeOrigin(DateNow());
|
performance.setTimeOrigin(DateNow());
|
||||||
globalThis_ = globalThis;
|
globalThis_ = globalThis;
|
||||||
|
|
||||||
|
|
|
@ -116,8 +116,6 @@ pub struct BootstrapOptions {
|
||||||
pub argv0: Option<String>,
|
pub argv0: Option<String>,
|
||||||
pub node_debug: Option<String>,
|
pub node_debug: Option<String>,
|
||||||
pub node_ipc_fd: Option<i64>,
|
pub node_ipc_fd: Option<i64>,
|
||||||
pub disable_deprecated_api_warning: bool,
|
|
||||||
pub verbose_deprecated_api_warning: bool,
|
|
||||||
pub future: bool,
|
pub future: bool,
|
||||||
pub mode: WorkerExecutionMode,
|
pub mode: WorkerExecutionMode,
|
||||||
// Used by `deno serve`
|
// Used by `deno serve`
|
||||||
|
@ -155,8 +153,6 @@ impl Default for BootstrapOptions {
|
||||||
argv0: None,
|
argv0: None,
|
||||||
node_debug: None,
|
node_debug: None,
|
||||||
node_ipc_fd: None,
|
node_ipc_fd: None,
|
||||||
disable_deprecated_api_warning: false,
|
|
||||||
verbose_deprecated_api_warning: false,
|
|
||||||
future: false,
|
future: false,
|
||||||
mode: WorkerExecutionMode::None,
|
mode: WorkerExecutionMode::None,
|
||||||
serve_port: Default::default(),
|
serve_port: Default::default(),
|
||||||
|
@ -194,10 +190,6 @@ struct BootstrapV8<'a>(
|
||||||
Option<&'a str>,
|
Option<&'a str>,
|
||||||
// node_debug
|
// node_debug
|
||||||
Option<&'a str>,
|
Option<&'a str>,
|
||||||
// disable_deprecated_api_warning,
|
|
||||||
bool,
|
|
||||||
// verbose_deprecated_api_warning
|
|
||||||
bool,
|
|
||||||
// future
|
// future
|
||||||
bool,
|
bool,
|
||||||
// mode
|
// mode
|
||||||
|
@ -232,8 +224,6 @@ impl BootstrapOptions {
|
||||||
self.has_node_modules_dir,
|
self.has_node_modules_dir,
|
||||||
self.argv0.as_deref(),
|
self.argv0.as_deref(),
|
||||||
self.node_debug.as_deref(),
|
self.node_debug.as_deref(),
|
||||||
self.disable_deprecated_api_warning,
|
|
||||||
self.verbose_deprecated_api_warning,
|
|
||||||
self.future,
|
self.future,
|
||||||
self.mode.discriminant() as _,
|
self.mode.discriminant() as _,
|
||||||
self.serve_port.unwrap_or_default(),
|
self.serve_port.unwrap_or_default(),
|
||||||
|
|
Loading…
Reference in a new issue