rspack_plugin_externals 0.100.2

rspack externals plugin
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rspack_core::{BoxPlugin, ExternalItem, PluginExt};
use rspack_regex::RspackRegex;

use crate::{ExternalsPlugin, node_builtins::NODE_BUILTINS};

pub fn node_target_plugin() -> BoxPlugin {
  let mut externals: Vec<ExternalItem> = NODE_BUILTINS
    .iter()
    .map(|s| ExternalItem::from(s.to_string()))
    .collect();
  externals.push(ExternalItem::from(
    RspackRegex::new("^node:").expect("Invalid regexp"),
  ));
  // Yarn PnP adds pnpapi as "builtin"
  externals.push(ExternalItem::from("pnpapi".to_string()));

  ExternalsPlugin::new("node-commonjs".to_string(), externals, false).boxed()
}