feat: remove --unstable flag requirement for npm: specifiers (#16473)

This commit makes "npm:" specifiers not require "--unstable" flag.
At the moment some APIs used by Node polyfills still require
"--unstable" which will be addressed in follow up PRs.
This commit is contained in:
Bartek Iwańczuk 2022-11-10 17:57:10 +01:00 committed by GitHub
parent fd32f75da9
commit 53e974b276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 58 additions and 152 deletions

View file

@ -68,7 +68,6 @@ impl NpmProcessState {
#[derive(Clone)]
pub struct NpmPackageResolver {
unstable: bool,
no_npm: bool,
inner: Arc<dyn InnerNpmPackageResolver>,
local_node_modules_path: Option<PathBuf>,
@ -80,7 +79,6 @@ pub struct NpmPackageResolver {
impl std::fmt::Debug for NpmPackageResolver {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("NpmPackageResolver")
.field("unstable", &self.unstable)
.field("no_npm", &self.no_npm)
.field("inner", &"<omitted>")
.field("local_node_modules_path", &self.local_node_modules_path)
@ -92,14 +90,12 @@ impl NpmPackageResolver {
pub fn new(
cache: NpmCache,
api: RealNpmRegistryApi,
unstable: bool,
no_npm: bool,
local_node_modules_path: Option<PathBuf>,
) -> Self {
Self::new_with_maybe_snapshot(
cache,
api,
unstable,
no_npm,
local_node_modules_path,
None,
@ -142,7 +138,6 @@ impl NpmPackageResolver {
fn new_with_maybe_snapshot(
cache: NpmCache,
api: RealNpmRegistryApi,
unstable: bool,
no_npm: bool,
local_node_modules_path: Option<PathBuf>,
initial_snapshot: Option<NpmResolutionSnapshot>,
@ -170,7 +165,6 @@ impl NpmPackageResolver {
)),
};
Self {
unstable,
no_npm,
inner,
local_node_modules_path,
@ -250,12 +244,6 @@ impl NpmPackageResolver {
return Ok(());
}
if !self.unstable {
bail!(
"Unstable use of npm specifiers. The --unstable flag must be provided."
)
}
if self.no_npm {
let fmt_reqs = packages
.iter()
@ -315,7 +303,6 @@ impl NpmPackageResolver {
Self::new_with_maybe_snapshot(
self.cache.clone(),
self.api.clone(),
self.unstable,
self.no_npm,
self.local_node_modules_path.clone(),
Some(self.snapshot()),