-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
/
index.js
29 lines (26 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
it("should not bundle context requires with asyncMode === 'weak'", function() {
var contextRequire = require.context(".", false, /two/, "weak");
expect(function() {
contextRequire("./two")
}).toThrowError(/not available/);
});
it("should not bundle context requires with asyncMode === 'weak' using import.meta.webpackContext", function() {
const contextRequire = import.meta.webpackContext(".", {
recursive: false,
regExp: /two/,
mode: "weak"
});
expect(function() {
contextRequire("./two")
}).toThrowError(/not available/);
});
it("should find module with asyncMode === 'weak' when required elsewhere", function() {
var contextRequire = require.context(".", false, /.+/, "weak");
expect(contextRequire("./three")).toBe(3);
require("./three"); // in a real app would be served as a separate chunk
});
it("should find module with asyncMode === 'weak' when required elsewhere (recursive)", function() {
var contextRequire = require.context(".", true, /.+/, "weak");
expect(contextRequire("./dir/four")).toBe(4);
require("./dir/four"); // in a real app would be served as a separate chunk
});