Unverified Commit e3389112 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

Turbopack: chore: Remove `extern crate` and `macro_use` syntax (#85778)

This syntax isn't needed in modern rust.

https://doc.rust-lang.org/reference/names/preludes.html#extern-prelude

> Beginning in the 2018 edition, use declarations can reference crates in the extern prelude, so **it is considered unidiomatic to use extern crate**.
parent 13174c55
...@@ -2,8 +2,6 @@ use std::{env, fs, path::Path, process::Command, str}; ...@@ -2,8 +2,6 @@ use std::{env, fs, path::Path, process::Command, str};
use serde_json::Value; use serde_json::Value;
extern crate napi_build;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-env-changed=CI"); println!("cargo:rerun-if-env-changed=CI");
let is_ci = env::var("CI").is_ok_and(|value| !value.is_empty()); let is_ci = env::var("CI").is_ok_and(|value| !value.is_empty());
......
...@@ -32,9 +32,6 @@ DEALINGS IN THE SOFTWARE. ...@@ -32,9 +32,6 @@ DEALINGS IN THE SOFTWARE.
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#[macro_use]
extern crate napi_derive;
use std::sync::Arc; use std::sync::Arc;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
......
...@@ -6,6 +6,7 @@ use std::{ ...@@ -6,6 +6,7 @@ use std::{
use anyhow::Context; use anyhow::Context;
use napi::bindgen_prelude::External; use napi::bindgen_prelude::External;
use napi_derive::napi;
/// A wrapper around [`File`] that is passed to JS, and is set to `None` when [`lockfile_unlock`] is /// A wrapper around [`File`] that is passed to JS, and is set to `None` when [`lockfile_unlock`] is
/// called. /// called.
......
use mdxjs::{Options, compile}; use mdxjs::{Options, compile};
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
pub struct MdxCompileTask { pub struct MdxCompileTask {
pub input: String, pub input: String,
......
...@@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE. ...@@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE.
use anyhow::Context; use anyhow::Context;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use serde::Serialize; use serde::Serialize;
use swc_core::{ use swc_core::{
base::{config::JsMinifyOptions, try_with_handler}, base::{config::JsMinifyOptions, try_with_handler},
......
...@@ -3,6 +3,7 @@ use std::{ops::Deref, sync::Arc}; ...@@ -3,6 +3,7 @@ use std::{ops::Deref, sync::Arc};
use anyhow::Result; use anyhow::Result;
use futures_util::TryFutureExt; use futures_util::TryFutureExt;
use napi::{JsFunction, bindgen_prelude::External}; use napi::{JsFunction, bindgen_prelude::External};
use napi_derive::napi;
use next_api::{ use next_api::{
operation::OptionEndpoint, operation::OptionEndpoint,
paths::ServerPath, paths::ServerPath,
...@@ -15,7 +16,7 @@ use tracing::Instrument; ...@@ -15,7 +16,7 @@ use tracing::Instrument;
use turbo_tasks::{Completion, Effects, OperationVc, ReadRef, Vc}; use turbo_tasks::{Completion, Effects, OperationVc, ReadRef, Vc};
use turbopack_core::{diagnostics::PlainDiagnostic, issue::PlainIssue}; use turbopack_core::{diagnostics::PlainDiagnostic, issue::PlainIssue};
use super::utils::{ use crate::next_api::utils::{
DetachedVc, NapiDiagnostic, NapiIssue, RootTask, TurbopackResult, DetachedVc, NapiDiagnostic, NapiIssue, RootTask, TurbopackResult,
strongly_consistent_catch_collectables, subscribe, strongly_consistent_catch_collectables, subscribe,
}; };
......
...@@ -8,6 +8,7 @@ use napi::{ ...@@ -8,6 +8,7 @@ use napi::{
bindgen_prelude::{External, within_runtime_if_available}, bindgen_prelude::{External, within_runtime_if_available},
threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode}, threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode},
}; };
use napi_derive::napi;
use next_api::{ use next_api::{
entrypoints::Entrypoints, entrypoints::Entrypoints,
next_server_nft::next_server_nft_assets, next_server_nft::next_server_nft_assets,
......
...@@ -12,6 +12,7 @@ use std::{ ...@@ -12,6 +12,7 @@ use std::{
use anyhow::Result; use anyhow::Result;
use either::Either; use either::Either;
use napi::{JsFunction, threadsafe_function::ThreadsafeFunction}; use napi::{JsFunction, threadsafe_function::ThreadsafeFunction};
use napi_derive::napi;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use serde::Serialize; use serde::Serialize;
......
...@@ -7,6 +7,7 @@ use napi::{ ...@@ -7,6 +7,7 @@ use napi::{
bindgen_prelude::{Buffer, External, ToNapiValue}, bindgen_prelude::{Buffer, External, ToNapiValue},
threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction, ThreadsafeFunctionCallMode}, threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction, ThreadsafeFunctionCallMode},
}; };
use napi_derive::napi;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use serde::Serialize; use serde::Serialize;
use turbo_tasks::{ use turbo_tasks::{
......
...@@ -2,6 +2,7 @@ use std::sync::Arc; ...@@ -2,6 +2,7 @@ use std::sync::Arc;
use anyhow::Context as _; use anyhow::Context as _;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use swc_core::{ use swc_core::{
base::{config::ParseOptions, try_with_handler}, base::{config::ParseOptions, try_with_handler},
common::{ common::{
......
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use next_custom_transforms::react_compiler; use next_custom_transforms::react_compiler;
use swc_core::{ use swc_core::{
common::{GLOBALS, SourceMap}, common::{GLOBALS, SourceMap},
......
use std::{cell::RefCell, fs, path::PathBuf, sync::Arc}; use std::{cell::RefCell, fs, path::PathBuf, sync::Arc};
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use swc_core::{ use swc_core::{
base::{ base::{
config::{IsModule, ParseOptions}, config::{IsModule, ParseOptions},
......
...@@ -35,6 +35,7 @@ use std::{ ...@@ -35,6 +35,7 @@ use std::{
use anyhow::{Context as _, anyhow, bail}; use anyhow::{Context as _, anyhow, bail};
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use next_custom_transforms::chain_transforms::{TransformOptions, custom_before_pass}; use next_custom_transforms::chain_transforms::{TransformOptions, custom_before_pass};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
......
use std::path::PathBuf; use std::path::PathBuf;
use napi_derive::napi;
#[napi] #[napi]
pub fn start_turbopack_trace_server(path: String, port: Option<u16>) { pub fn start_turbopack_trace_server(path: String, port: Option<u16>) {
let path_buf = PathBuf::from(path); let path_buf = PathBuf::from(path);
......
...@@ -2,6 +2,7 @@ use std::path::PathBuf; ...@@ -2,6 +2,7 @@ use std::path::PathBuf;
use anyhow::Context; use anyhow::Context;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use next_build::{ use next_build::{
BuildOptions as NextBuildOptions, BuildOptions as NextBuildOptions,
build_options::{BuildContext, DefineEnv}, build_options::{BuildContext, DefineEnv},
......
...@@ -30,6 +30,7 @@ use std::{cell::RefCell, env, path::PathBuf}; ...@@ -30,6 +30,7 @@ use std::{cell::RefCell, env, path::PathBuf};
use anyhow::anyhow; use anyhow::anyhow;
use napi::bindgen_prelude::{External, Status}; use napi::bindgen_prelude::{External, Status};
use napi_derive::napi;
use tracing_chrome::{ChromeLayerBuilder, FlushGuard}; use tracing_chrome::{ChromeLayerBuilder, FlushGuard};
use tracing_subscriber::{Layer, filter, layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{Layer, filter, layer::SubscriberExt, util::SubscriberInitExt};
......
...@@ -5,6 +5,7 @@ mod handle_externals; ...@@ -5,6 +5,7 @@ mod handle_externals;
mod next_externals_plugin; mod next_externals_plugin;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use napi_derive::napi;
use rspack_binding_builder_macros::register_plugin; use rspack_binding_builder_macros::register_plugin;
use rspack_core::BoxPlugin; use rspack_core::BoxPlugin;
use rspack_regex::RspackRegex; use rspack_regex::RspackRegex;
...@@ -15,10 +16,6 @@ use crate::{ ...@@ -15,10 +16,6 @@ use crate::{
next_externals_plugin::{NextExternalsPlugin, NextExternalsPluginOptions}, next_externals_plugin::{NextExternalsPlugin, NextExternalsPluginOptions},
}; };
#[macro_use]
extern crate napi_derive;
extern crate rspack_binding_builder;
#[derive(Debug)] #[derive(Debug)]
#[napi(object, object_to_js = false)] #[napi(object, object_to_js = false)]
pub struct NapiExperimentalConfig { pub struct NapiExperimentalConfig {
......
...@@ -14,8 +14,6 @@ mod value_impl_macro; ...@@ -14,8 +14,6 @@ mod value_impl_macro;
mod value_macro; mod value_macro;
mod value_trait_macro; mod value_trait_macro;
extern crate proc_macro;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use proc_macro_error::proc_macro_error; use proc_macro_error::proc_macro_error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment