-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: channal error when using sync externals function (#8884)
- Loading branch information
1 parent
92e5e4f
commit 3074092
Showing
7 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/rspack-test-tools/tests/configCases/externals/function-sync/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import "./inject"; | ||
|
||
import foo from "foo"; | ||
import raz from "raz"; | ||
const myos = require("myos"); | ||
const bar = require("bar"); | ||
const baz = require("baz"); | ||
const fn = require("fn"); | ||
const asyncFn = require("asyncFn"); | ||
const external = require("external"); | ||
const external2 = require("external2"); | ||
const external3 = require("external3"); | ||
const external4 = require("external4"); | ||
const external5 = require("external5"); | ||
|
||
it("should work with array type of externals", function () { | ||
expect(foo).toBe("foo"); | ||
expect(bar).toBe("bar"); | ||
expect(baz).toBe("baz"); | ||
expect(raz).toBe("raz"); | ||
expect(fn).toBe("fn"); | ||
expect(asyncFn).toBe("asyncFn"); | ||
expect(typeof myos.constants.errno.EBUSY).toBe("number"); | ||
|
||
expect(external).toBe(Array.isArray); | ||
expect(external2).toBe(process.version); | ||
expect(external3).toBe(globalThis); | ||
expect(external4).toBe(global.process.version); | ||
expect(external5).toBe("yj"); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/rspack-test-tools/tests/configCases/externals/function-sync/inject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
global.foo = "foo"; | ||
global.raz = "raz"; | ||
global.obj = { name: "yj" }; |
31 changes: 31 additions & 0 deletions
31
packages/rspack-test-tools/tests/configCases/externals/function-sync/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
externals: [ | ||
"path", | ||
"foo", | ||
/^raz$/, | ||
{ | ||
bar: "'bar'", | ||
baz: "var 'baz'", | ||
myos: "commonjs os", | ||
external: ["Array", "isArray"], | ||
external2: ["commonjs process", "version"], | ||
external3: ["var globalThis"], | ||
external4: ["global process", "version"], | ||
external5: ["this obj", "name"] | ||
}, | ||
function ({ request }) { | ||
if (request === "fn") { | ||
return "'fn'"; | ||
} | ||
}, | ||
function ({ request }) { | ||
if (request === "asyncFn") { | ||
return "'asyncFn'"; | ||
} | ||
} | ||
], | ||
externalsPresets: { | ||
node: false | ||
} | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3074092
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open