Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-pianos-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rspack/binding": patch
---

fix regex external not working
12 changes: 8 additions & 4 deletions crates/rspack_binding_options/src/options/raw_external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;

use napi_derive::napi;
use rspack_core::ExternalItem;
use rspack_regex::RspackRegex;
use serde::Deserialize;

#[derive(Deserialize, Debug, Clone)]
Expand All @@ -23,11 +24,14 @@ impl From<RawExternalItem> for ExternalItem {
.string_payload
.expect("should have a string_payload when RawExternalItem.type is \"string\""),
),
"regexp" => Self::from(
value
"regexp" => {
let payload = value
.regexp_payload
.expect("should have a regexp_payload when RawExternalItem.type is \"regexp\""),
),
.expect("should have a regexp_payload when RawExternalItem.type is \"regexp\"");
let reg =
RspackRegex::new(&payload).expect("regex_payload is not a legal regex in rust side");
Self::from(reg)
}
"object" => Self::from(
value
.object_payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "./inject";

import foo from "foo";
const bar = require("bar");
const react = require("react");

it("should work with array type of externals", function () {
expect(foo).toBe("foo");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global.foo = "foo";
global.bar = "bar";
global.react = "react";
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
externals: ["foo", "bar"]
externals: ["foo", "bar", /^re/]
};