Commit 907777d8 authored by Luke Sandberg's avatar Luke Sandberg

Write an integration test to test `require.context`

This test that we do not include `foo_test.js` in the dependencies and we achieve that via a silly negative lookahead assertion.

This resolves PACK-3895.
parent 25e61229
(function() { throw window.good; })();
\ No newline at end of file
(function() { throw window.bad; })();
\ No newline at end of file
// PACK-3895: ensure that negative lookaround works.
let ctx = require.context("./deps", true, /foo(?!_test)/);
// import all the matches, should just get foo.js
ctx.keys().forEach(ctx);
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/4e721_crates_turbopack-tests_tests_snapshot_imports_require-context_input_b0375d60._.js", {
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/deps/foo.js [test] (ecmascript)": (function(__turbopack_context__) {
var { g: global, __dirname, m: module, e: exports } = __turbopack_context__;
{
(function() {
throw new Error();
})();
}}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/index.js (require.context ./deps/**)": ((__turbopack_context__) => {
var { g: global, __dirname } = __turbopack_context__;
{
__turbopack_context__.v({
"./foo.js": {
id: ()=>"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/deps/foo.js [test] (ecmascript)",
module: ()=>__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/deps/foo.js [test] (ecmascript)")
}
});
}}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/index.js [test] (ecmascript)": (function(__turbopack_context__) {
var { g: global, __dirname, m: module, e: exports } = __turbopack_context__;
{
// PACK-3895: ensure that negative lookaround works.
let ctx = __turbopack_context__.f(__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/index.js (require.context ./deps/**)"));
// import all the matches, should just get foo.js
ctx.keys().forEach(ctx);
}}),
}]);
//# sourceMappingURL=4e721_crates_turbopack-tests_tests_snapshot_imports_require-context_input_b0375d60._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 6, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/deps/foo.js"],"sourcesContent":["\n(function() { throw new Error(); })();"],"names":[],"mappings":"AACA,CAAC;IAAa,MAAM,IAAI;AAAS,CAAC"}},
{"offset": {"line": 25, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/index.js"],"sourcesContent":["\n// PACK-3895: ensure that negative lookaround works.\nlet ctx = require.context(\"./deps\", true, /foo(?!_test)/);\n// import all the matches, should just get foo.js\nctx.keys().forEach(ctx);\n\n"],"names":[],"mappings":"AACA,oDAAoD;AACpD,IAAI;AACJ,iDAAiD;AACjD,IAAI,IAAI,GAAG,OAAO,CAAC"}}]
}
\ No newline at end of file
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/b1abf_turbopack-tests_tests_snapshot_imports_require-context_input_index_f53f560e.js",
{},
{"otherChunks":["output/4e721_crates_turbopack-tests_tests_snapshot_imports_require-context_input_b0375d60._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/require-context/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment