2017-07-26 01:21:02 +08:00
|
|
|
it("should not bundle context requires with asyncMode === 'weak'", function() {
|
2022-03-01 23:11:31 +08:00
|
|
|
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() {
|
2022-02-27 04:16:21 +08:00
|
|
|
const contextRequire = import.meta.webpackContext(".", {
|
|
|
|
recursive: false,
|
|
|
|
regExp: /two/,
|
|
|
|
mode: "weak"
|
|
|
|
});
|
2018-01-27 06:59:38 +08:00
|
|
|
expect(function() {
|
2017-07-26 01:21:02 +08:00
|
|
|
contextRequire("./two")
|
2018-01-27 06:59:38 +08:00
|
|
|
}).toThrowError(/not available/);
|
2017-07-26 01:21:02 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should find module with asyncMode === 'weak' when required elsewhere", function() {
|
2022-03-01 23:11:31 +08:00
|
|
|
var contextRequire = require.context(".", false, /.+/, "weak");
|
2018-01-27 05:51:03 +08:00
|
|
|
expect(contextRequire("./three")).toBe(3);
|
2017-07-26 01:21:02 +08:00
|
|
|
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() {
|
2022-03-01 23:11:31 +08:00
|
|
|
var contextRequire = require.context(".", true, /.+/, "weak");
|
2018-01-27 05:51:03 +08:00
|
|
|
expect(contextRequire("./dir/four")).toBe(4);
|
2017-07-26 01:21:02 +08:00
|
|
|
require("./dir/four"); // in a real app would be served as a separate chunk
|
|
|
|
});
|