prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
mport { used } from './json.js'
import { used as used2 } from './js.js'
import { used as used3 } from './cjs.js'
it('should tree shake all unused modules', () => {
expect(used).toEqual({ used: true })
expect(used2).toBe(true)
expect(used3).toBe(true)
const modules = Array.from(__turbopack_modules__.keys())
... | qual(expect.stringMatching(/input\/unused\.js/))
expect(modules).toContainEqual(expect.stringMatching(/input\/cjs\.js/))
expect(modules).toContainEqual(expect.stringMatching(/input\/used\.cjs/))
expect(modules).not.toContainEqual(
expect.stringMa | expect.stringMatching(/input\/unused\.json/)
)
expect(modules).toContainEqual(expect.stringMatching(/input\/js\.js/))
expect(modules).toContainEqual(expect.stringMatching(/input\/used\.js/))
expect(modules).not.toContainE | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/ignore-side-effect-free-module/input/index.js",
"language": "javascript",
"file_size": 1034,
"cut_index": 513,
"middle_length": 229
} |
e('node:worker_threads')
const path = require('path')
if (isMainThread) {
it('should run a worker thread with separate file', async () => {
const worker = new Worker(path.join(__dirname, 'worker.js'))
const message = await new Promise((resolve, reject) => {
worker.on('message', resolve)
worker.o... | new Promise((resolve, reject) => {
worker.on('message', resolve)
worker.on('error', reject)
worker.on('exit', (code) => {
if (code !== 0) {
reject(new Error(`Worker stopped with exit code ${code}`))
}
})
| ge('ping')
})
expect(message).toBe('pong')
await worker.terminate()
})
it('should handle self-referencing worker (__filename)', async () => {
const worker = new Worker(__filename)
const message = await | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/worker-threads/input/index.js",
"language": "javascript",
"file_size": 2304,
"cut_index": 563,
"middle_length": 229
} |
Cjs, loadInvalidEsm } from 'esm-package'
import { auto, autoPlain } from 'auto-package'
it('should have the commonjs module as default export in specified ESM', () => {
expect(esm).toMatchObject({
__esModule: true,
named: 'named',
})
expect(esmPlain).toMatchObject({
named: 'named',
})
})
it('shoul... | lid esm exports', async () => {
let value = await loadInvalidEsm()
expect(value).toMatchObject({
__esModule: true,
})
})
it('should error for invalid cjs exports', async () => {
let value = await loadInvalidCjs()
expect(value).toMatchObject( | named: 'named',
})
})
it('should error for inva | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/index.js",
"language": "javascript",
"file_size": 907,
"cut_index": 547,
"middle_length": 52
} |
work correctly
// This ensures conditional guards are preserved and don't get optimized away incorrectly
let initPromise = null
let callCount = 0
async function doInit() {
callCount++
}
function initAsync() {
if (!initPromise) {
initPromise = doInit()
}
return initPromise
}
it('should only initialize o... | the same promise instance
expect(promise1).toBe(promise2)
expect(promise2).toBe(promise3)
// Wait for all to resolve
await Promise.all([promise1, promise2, promise3])
// Should have only called the expensive init once
expect(callCount).toBe(1 | onst promise3 = initAsync()
// All should return | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/async-lazy-init/input/index.js",
"language": "javascript",
"file_size": 872,
"cut_index": 559,
"middle_length": 52
} |
andle right shift assignment in conditional for number', () => {
let value = 16
let entered = false
if ((value >>= 2)) {
entered = true
}
expect(value).toBe(4)
expect(entered).toBe(true)
})
it('should handle right shift assignment in conditional for bigint', () => {
let value = 16n
let entered = fa... | lue = 16
let entered = false
if ((value >>>= 2)) {
entered = true
}
expect(value).toBe(4)
expect(entered).toBe(true)
})
it('should handle bitwise OR assignment in conditional', () => {
let value = 0
let entered = false
if ((value |= 5) | alue = 3
let entered = false
if ((value <<= 2)) {
entered = true
}
expect(value).toBe(12)
expect(entered).toBe(true)
})
it('should handle unsigned right shift assignment in conditional for number', () => {
let va | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/compound-assign-in-conditional/input/index.js",
"language": "javascript",
"file_size": 1504,
"cut_index": 524,
"middle_length": 229
} |
lThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_esm_input_0m4yc4r._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm/input/mod.mjs [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack... | ck_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$import$2d$meta$2f$esm$2f$input$2f$mod$2e$mjs__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/ | ;
}
};
console.log(__TURBOPACK__import$2e$meta__.url);
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopa | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm/output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_esm_input_0m4yc4r._.js",
"language": "javascript",
"file_size": 1222,
"cut_index": 518,
"middle_length": 229
} |
"TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_0__oir9._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/input/mod.mjs [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__tu... | s/tests/snapshot/import-meta/esm-multiple/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$ | /input/mod.mjs");
}
};
function foo() {
console.log(__TURBOPACK__import$2e$meta__.url);
}
function bar() {
console.log(__TURBOPACK__import$2e$meta__.url);
}
foo();
bar();
}),
"[project]/turbopack/crates/turbopack-test | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_0__oir9._.js",
"language": "javascript",
"file_size": 1386,
"cut_index": 524,
"middle_length": 229
} |
|| (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_url_input_0jbqiqv._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/input/asset.txt (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/asset.... | opack_context__.U(__turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/input/asset.txt (static in ecmascript)"));
console.log(assetUrl);
fetch(assetUrl).then((res)=>res.text()).then(console.log);
}),
"[project] | context__.s([]);
var __TURBOPACK__import$2e$meta__ = {
get url () {
return __turbopack_context__.F("turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/input/mod.mjs");
}
};
const assetUrl = new __turb | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_url_input_0jbqiqv._.js",
"language": "javascript",
"file_size": 1653,
"cut_index": 537,
"middle_length": 229
} |
r hmr support
module = createModuleWithDirection(id);
} else {
module = createModuleObject(id);
}
moduleCache[id] = module;
}
return module;
}
/**
* Creates the module object. Only done here to ensure all module objects have the same shape.
*/ function createMod... | sm(exports, bindings) {
defineProp(exports, '__esModule', {
value: true
});
if (toStringTag) defineProp(exports, toStringTag, {
value: 'Module'
});
let i = 0;
while(i < bindings.length){
const propName = bind | exports: {},
error: undefined,
id,
namespaceObject: undefined,
parents: [],
children: []
};
}
const BindingTag_Value = 0;
/**
* Adds the getters to the exports object.
*/ function e | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_index_09-gc7x.js",
"language": "javascript",
"file_size": 93133,
"cut_index": 3790,
"middle_length": 229
} |
|| (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_basic_input_0z18is9._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/worker.js (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/worker.2-q... | ut_worker_11ygioo.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_0yr5fg0.js"], opts);
});
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js [test] (ecmascript)", ((__turbopack_con | text__.v(function(Ctor, opts) {
return __turbopack_context__.b(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_basic_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_basic_inp | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/output/turbopack_crates_turbopack-tests_tests_snapshot_workers_basic_input_0z18is9._.js",
"language": "javascript",
"file_size": 1715,
"cut_index": 537,
"middle_length": 229
} |
{
function abort(message) {
console.error(message);
throw new Error(message);
}
if (
typeof self["WorkerGlobalScope"] === "undefined" ||
!(self instanceof self["WorkerGlobalScope"])
) {
abort("Worker entrypoint must be loaded in a worker context");
}
// Try querystring first (SharedWorker), then ha... | Array.isArray(params[0]) ? params[0] : [];
Object.assign(self, {
TURBOPACK_NEXT_CHUNK_URLS: chunkUrls,
TURBOPACK_ASSET_SUFFIX: param(1)
});
if (chunkUrls.length > 0) {
var scriptsToLoad = [];
for (var i = 0; i < chunkUrls.length; i++) {
| ponent(url.hash.slice("#params=".length));
}
if (!paramsString) abort("Missing worker bootstrap config");
var params = JSON.parse(paramsString);
var param = (n) => typeof params[n] === 'string' ? params[n] : '';
var chunkUrls = | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/output/0uxq_crates_turbopack-tests_tests_snapshot_workers_shared_output_0uy0mni._.js",
"language": "javascript",
"file_size": 1489,
"cut_index": 524,
"middle_length": 229
} |
|| (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_shared_input_0g-vw3t._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/worker.js (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/worker.1... | d_input_worker_1u1i0a1.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1xw116u.js"], opts);
});
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js [test] (ecmascript)", ((__turbop | context__.v(function(Ctor, opts) {
return __turbopack_context__.b(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_shared_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_share | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/output/turbopack_crates_turbopack-tests_tests_snapshot_workers_shared_input_0g-vw3t._.js",
"language": "javascript",
"file_size": 1707,
"cut_index": 537,
"middle_length": 229
} |
aaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | aaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaa | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/shared-chunks/input/c.js",
"language": "javascript",
"file_size": 5000,
"cut_index": 614,
"middle_length": 229
} |
aaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | aaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaa | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/shared-chunks/input/e.js",
"language": "javascript",
"file_size": 5000,
"cut_index": 614,
"middle_length": 229
} |
ction toFixed(value, maxDecimals, roundingFunction, optionals) {
var splitValue = value.toString().split('.'),
minDecimals = maxDecimals - (optionals || 0),
optionalsRegExp,
power,
output
var boundedPrecisions
// var unused = 'xxxx';
// Use the smallest precision value possible to avoid errors f... | power).toFixed(
boundedPrecisions
)
if (optionals > maxDecimals - boundedPrecisions) {
optionalsRegExp = new RegExp(
'\\.?0{1,' + (optionals - (maxDecimals - boundedPrecisions)) + '}$'
)
output = output.replace(optionalsRegExp, '' | oundedPrecisions = minDecimals
}
power = Math.pow(10, boundedPrecisions)
// Multiply up by precision, round accurately, then divide and use native toFixed():
output = (roundingFunction(value + 'e+' + boundedPrecisions) / | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/minification/paren-remover/input/index.js",
"language": "javascript",
"file_size": 1111,
"cut_index": 515,
"middle_length": 229
} |
llowing tests would fail if they require("fail")
expect(() => {
require('./not-existing-file')
}).toThrow()
})
function maybeReturn(x) {
if (x) {
return true
}
}
function func() {
if (false) {
require('fail')
import('fail')
}
if (true) {
require('./ok')
}
if (true) {
require(... | quire('./ok') : require('fail')
true ? require('./ok') : (require('fail'), import('fail'))
true
? require('./ok')
: (() => {
require('fail')
import('fail')
})()
const value = false
? (() => {
require('fail')
| rences', () => {
func()
expect(func.toString()).not.toContain('import(')
})
function funcTenary() {
false ? require('fail') : undefined
false ? import('fail') : undefined
true ? require('./ok') : undefined
true ? re | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js",
"language": "javascript",
"file_size": 3859,
"cut_index": 614,
"middle_length": 229
} |
] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_212xd9j._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
// commonjs.js
exports.hello = 'World';
}),
"... | _.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js [test] (ecmascript)"); // This would be handled by existing logic
__turbopack_context__.j(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates | ar __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$export$2d$alls$2f$cjs$2d$2$2f$input$2f$commonjs$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context_ | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/output/turbopack_crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_212xd9j._.js",
"language": "javascript",
"file_size": 2957,
"cut_index": 563,
"middle_length": 229
} |
"TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_0akuaiy._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/input/mod.mjs [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbop... | ";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$import$2d$meta$2f$esm$2d$object$2f$input$2f$mod$2e$mjs__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_ | /mod.mjs");
}
};
console.log(__TURBOPACK__import$2e$meta__);
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_0akuaiy._.js",
"language": "javascript",
"file_size": 1260,
"cut_index": 524,
"middle_length": 229
} |
{
function abort(message) {
console.error(message);
throw new Error(message);
}
if (
typeof self["WorkerGlobalScope"] === "undefined" ||
!(self instanceof self["WorkerGlobalScope"])
) {
abort("Worker entrypoint must be loaded in a worker context");
}
// Try querystring first (SharedWorker), then ha... | Array.isArray(params[0]) ? params[0] : [];
Object.assign(self, {
TURBOPACK_NEXT_CHUNK_URLS: chunkUrls,
TURBOPACK_ASSET_SUFFIX: param(1)
});
if (chunkUrls.length > 0) {
var scriptsToLoad = [];
for (var i = 0; i < chunkUrls.length; i++) {
| ponent(url.hash.slice("#params=".length));
}
if (!paramsString) abort("Missing worker bootstrap config");
var params = JSON.parse(paramsString);
var param = (n) => typeof params[n] === 'string' ? params[n] : '';
var chunkUrls = | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/output/0uxq_crates_turbopack-tests_tests_snapshot_workers_basic_output_0uy0mni._.js",
"language": "javascript",
"file_size": 1489,
"cut_index": 524,
"middle_length": 229
} |
for hmr support
module = createModuleWithDirection(id);
} else {
module = createModuleObject(id);
}
moduleCache[id] = module;
}
return module;
}
/**
* Creates the module object. Only done here to ensure all module objects have the same shape.
*/ function create... | n esm(exports, bindings) {
defineProp(exports, '__esModule', {
value: true
});
if (toStringTag) defineProp(exports, toStringTag, {
value: 'Module'
});
let i = 0;
while(i < bindings.length){
const propName = b | exports: {},
error: undefined,
id,
namespaceObject: undefined,
parents: [],
children: []
};
}
const BindingTag_Value = 0;
/**
* Adds the getters to the exports object.
*/ functio | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_index_0arnewp.js",
"language": "javascript",
"file_size": 93137,
"cut_index": 3790,
"middle_length": 229
} |
aaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | aaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaa | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/shared-chunks/input/a.js",
"language": "javascript",
"file_size": 5000,
"cut_index": 614,
"middle_length": 229
} |
aaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | aaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'aaaaaaaaa | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/shared-chunks/input/g.js",
"language": "javascript",
"file_size": 5000,
"cut_index": 614,
"middle_length": 229
} |
await import('./modules/all')
expect(lib.cat).toBe('cat')
expect(lib.exportsInfo.cat.used).toBe(true)
expect(lib.exportsInfo.dog.used).toBe(true)
})
it('should tree-shake unused exports with const destructured dynamic import', async () => {
const { cat, exportsInfo } = await import('./modules/const')
expect... | ructured dynamic import', async () => {
var { cat, exportsInfo } = await import('./modules/var')
expect(cat).toBe('cat')
expect(exportsInfo.cat.used).toBe(true)
expect(exportsInfo.dog.used).toBe(false)
})
it('should tree-shake all exports with emp | => {
let { cat, exportsInfo } = await import('./modules/let')
expect(cat).toBe('cat')
expect(exportsInfo.cat.used).toBe(true)
expect(exportsInfo.dog.used).toBe(false)
})
it('should tree-shake unused exports with var dest | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/tree-shaking/dynamic-import/input/index.js",
"language": "javascript",
"file_size": 4142,
"cut_index": 614,
"middle_length": 229
} |
"TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_20u-wgb._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/input/mod.mjs [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turb... | ;
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$import$2d$meta$2f$esm$2d$mutable$2f$input$2f$mod$2e$mjs__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_ | put/mod.mjs");
}
};
__TURBOPACK__import$2e$meta__.foo = 1;
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict" | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/output/1do3_crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_20u-wgb._.js",
"language": "javascript",
"file_size": 1262,
"cut_index": 524,
"middle_length": 229
} |
es for hmr support
module = createModuleWithDirection(id);
} else {
module = createModuleObject(id);
}
moduleCache[id] = module;
}
return module;
}
/**
* Creates the module object. Only done here to ensure all module objects have the same shape.
*/ function crea... | ion esm(exports, bindings) {
defineProp(exports, '__esModule', {
value: true
});
if (toStringTag) defineProp(exports, toStringTag, {
value: 'Module'
});
let i = 0;
while(i < bindings.length){
const propName = | exports: {},
error: undefined,
id,
namespaceObject: undefined,
parents: [],
children: []
};
}
const BindingTag_Value = 0;
/**
* Adds the getters to the exports object.
*/ funct | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1xw116u.js",
"language": "javascript",
"file_size": 93140,
"cut_index": 3790,
"middle_length": 229
} |
r function declaration', () => {
function withDefault(value = this.prop) {
return value
}
const obj = { prop: 42 }
expect(withDefault.call(obj)).toBe(42)
})
it('should handle this in default parameters for function expression', () => {
const funcExpr = function (value = this.prop) {
return value
}... | eturn arrow()
},
}
expect(obj.test()).toBe(77)
})
it('should handle this in default parameters for object method', () => {
const obj = {
prop: 100,
method(value = this.prop) {
return value
},
}
expect(obj.method()).toBe(100 | const arrow = (value = this.prop) => value
r | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/turbopack/basic/this-in-default-params/input/index.js",
"language": "javascript",
"file_size": 872,
"cut_index": 559,
"middle_length": 52
} |
lThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_1uw7l3k._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/cjs/input/mod.cjs [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
var __TU... | TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$import$2d$meta$2f$cjs$2f$input$2f$mod$2e$cjs__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack | URBOPACK__import$2e$meta__.url);
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/cjs/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __ | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/import-meta/cjs/output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_1uw7l3k._.js",
"language": "javascript",
"file_size": 1196,
"cut_index": 518,
"middle_length": 229
} |
for hmr support
module = createModuleWithDirection(id);
} else {
module = createModuleObject(id);
}
moduleCache[id] = module;
}
return module;
}
/**
* Creates the module object. Only done here to ensure all module objects have the same shape.
*/ function createM... | esm(exports, bindings) {
defineProp(exports, '__esModule', {
value: true
});
if (toStringTag) defineProp(exports, toStringTag, {
value: 'Module'
});
let i = 0;
while(i < bindings.length){
const propName = bi | exports: {},
error: undefined,
id,
namespaceObject: undefined,
parents: [],
children: []
};
}
const BindingTag_Value = 0;
/**
* Adds the getters to the exports object.
*/ function | {
"filepath": "turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_0yr5fg0.js",
"language": "javascript",
"file_size": 93136,
"cut_index": 3790,
"middle_length": 229
} |
lob/canary/packages/next/src/client/dev/error-overlay/websocket.ts
import type { HmrMessage } from '@vercel/turbopack-ecmascript-runtime/browser/dev/hmr-client/hmr-client'
let source: WebSocket
const messageCallbacks: ((message: HmrMessage) => void)[] = []
// TODO: add timeout again
// let lastActivity = Date.now()
... | !== source.OPEN) return
return source.send(data)
}
export type HMROptions = {
path: string
assetPrefix: string
timeout?: number
log?: boolean
}
// This is not used by Next.js, but it is used by the standalone turbopack-cli
export function conne |
return protocol === 'http:' ? 'ws' : 'wss'
}
export function addMessageListener(cb: (message: HmrMessage) => void) {
messageCallbacks.push(cb)
}
export function sendMessage(data: any) {
if (!source || source.readyState | {
"filepath": "turbopack/crates/turbopack-cli/js/src/entry/websocket.ts",
"language": "typescript",
"file_size": 2444,
"cut_index": 563,
"middle_length": 229
} |
)
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const WORKING_PATH = '/root/actions-runner/_work/next.js/next.js/'
const INITIALIZING_TEST_CASES = [
'compile successfully',
'should build successfully',
]
// please make sure this is sorted alphabetically when making changes.
co... | .default('branch', 'canary')
.boolean('override')
.describe(
'override',
"Don't merge with existing test results, allowing tests to transition to " +
'a failed state'
)
const manifestJsonPath = `${__dirname}/${argv.bundler}-${argv.te | inst')
.choices('test-suite', ['dev', 'build'])
.describe('test-suite', 'Test group to update')
.demandOption(['bundler', 'test-suite'])
.string('branch')
.describe('branch', 'the git branch to filter CI artifacts to')
| {
"filepath": "test/update-bundler-manifest.js",
"language": "javascript",
"file_size": 8604,
"cut_index": 716,
"middle_length": 229
} |
rs'
interface TestResponse {
appDir: string
type: 'e2e' | 'production' | 'development' | 'unit'
name: string
}
interface ErrorResponse {
name: string
title: string
why: string
fix: string
}
function validateNonEmptyString(field: string) {
return function (value: string) {
if (/.+/.test(value)) {
... | y?',
default: true,
},
{
type: 'input',
name: 'name',
message: 'Test name',
validate: validateNonEmptyString('test name'),
},
{
type: 'list',
name: 'type',
message: 'Te | dlebars helpers
helpers.init(plop)
plop.setGenerator('test', {
description: 'Create a new test',
prompts: [
{
type: 'confirm',
name: 'appDir',
message: 'Is this test for the app director | {
"filepath": "turbo/generators/config.ts",
"language": "typescript",
"file_size": 4210,
"cut_index": 614,
"middle_length": 229
} |
{}
export class B {}
export class C {}
export class Y {}
export class Z {}
export function mixin1(_class) {
return _class
}
export function mixin2(_class) {
return _class
}
export function mixin3(_class) {
return _class
}
export function mixin4(_class) {
return _class
}
export function mixin5(_class) {
return... | bpack_exports_info__.B.used
export const exportsInfoForC = __webpack_exports_info__.C.used
export const exportsInfoForY = __webpack_exports_info__.Y.used
export const exportsInfoForZ = __webpack_exports_info__.Z.used
export const exportsInfoForW = __webpac | BaseError3 extends Error {}
export class W {}
export class J {}
export class K {}
var SuperClass = class {}
export { SuperClass }
export const exportsInfoForA = __webpack_exports_info__.A.used
export const exportsInfoForB = __we | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/inner-graph/__skipped__/extend-class/input/dep2.js",
"language": "javascript",
"file_size": 2017,
"cut_index": 537,
"middle_length": 229
} |
A,
exportsInfoForB,
exportsInfoForC,
exportsInfoForY,
exportsInfoForZ,
exportsInfoForW,
exportsInfoForJ,
exportsInfoForK,
exportsInfoForMixin1,
exportsInfoForMixin2,
exportsInfoForMixin3,
exportsInfoForMixin4,
exportsInfoForMixin5,
exportsInfoForBaseError,
exportsInfoForBaseError1,
exports... | sed', () => {
expect(exportsInfoForJ).toBe(false)
expect(exportsInfoForW).toBe(false)
})
it('Keep extends with constructor', () => {
expect(exportsInfoForBaseError).toBe(true)
expect(exportsInfoForBaseError1).toBe(true)
expect(expo | './module3')
require('./module4')
require('./module5')
require('./module6')
require('./module7')
require('./module8')
require('./module9')
})
if (process.env.NODE_ENV === 'production') {
it('W and J should not be u | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/inner-graph/__skipped__/extend-class/input/index.js",
"language": "javascript",
"file_size": 1936,
"cut_index": 537,
"middle_length": 229
} |
import { Block, Inline, Document } from './some-module'
function getType(obj) {
return obj.type
}
// Local functions
function doSomethingWithBlock(obj) {
return Block.doSomething(obj)
}
function doSomethingWithInline(obj) {
return Inline.doSomething(obj)
}
function doSomethingWithDocument(obj) {
return Docu... | return doSomethingWithBlock(obj)
case 'inline':
return doSomethingWithInline(obj)
default:
throw new Error()
}
}
function useDocument(obj) {
return doSomethingWithDocument(obj)
}
export { useDocument }
export default doSomethin | e 'block':
| {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/inner-graph/switch/input/module.js",
"language": "javascript",
"file_size": 784,
"cut_index": 512,
"middle_length": 14
} |
*
* Production Node.js runtime.
* Uses ModuleWithDirection and simple module instantiation without HMR support.
*/
// moduleCache and moduleFactories are declared in runtime-base.ts
// this is read in runtime-utils.ts so it creates a module with direction for hmr
createModuleWithDirectionFlag = true
interface Tur... | leCache as ModuleCache<ModuleWithDirection>
nodeContextPrototype.R = resolvePathFromModule
nodeContextPrototype.b = createWorker
nodeContextPrototype.C = clearChunkCache
function instantiateModule(
id: ModuleId,
sourceType: SourceType,
sourceData: S | tPrototype = Context.prototype as TurbopackNodeBuildContext
nodeContextPrototype.q = exportUrl
nodeContextPrototype.M = moduleFactories
// Cast moduleCache to ModuleWithDirection for production mode
nodeContextPrototype.c = modu | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/build-base.ts",
"language": "typescript",
"file_size": 3543,
"cut_index": 614,
"middle_length": 229
} |
<reference path="../../shared/runtime/dev-extensions.ts" />
/// <reference path="../../shared/runtime/hmr-runtime.ts" />
/**
* Development Node.js runtime.
* Uses HotModule and shared HMR logic for hot module replacement support.
*/
// Cast the module cache to HotModule for development mode
// (hmr-runtime.ts dec... | _turbopack_runtime_modules__
interface TurbopackNodeDevBuildContext extends TurbopackBaseContext<HotModule> {
R: ResolvePathFromModule
x: ExternalRequire
y: ExternalImport
C: typeof clearChunkCache
}
const nodeDevContextPrototype =
Context.prot | -utils.ts so it creates a module with direction for hmr
createModuleWithDirectionFlag = true
if (!globalThis.__turbopack_runtime_modules__) {
globalThis.__turbopack_runtime_modules__ = new Set()
}
runtimeModules = globalThis._ | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/dev-base.ts",
"language": "typescript",
"file_size": 4224,
"cut_index": 614,
"middle_length": 229
} |
/>
/**
* Note: hmr-runtime.ts is embedded before this file, so its functions
* (initializeServerHmr, emitMessage) are available in the same scope.
*/
// Initialize server HMR client (connects to shared HMR infrastructure)
let hmrClientInitialized = false
function ensureHmrClientInitialized() {
if (hmrClientIniti... | tMessage returns false if any listener failed to apply the update
return emitMessage({
type: 'turbopack-message',
data: update,
})
} catch (err) {
console.error('[Server HMR] Failed to apply update:', err)
return false
}
}
| HotModule-typed cache from dev-runtime.ts
initializeServerHmr(moduleFactories, devModuleCache)
}
function __turbopack_server_hmr_apply__(update: NodeJsHmrPayload): boolean {
try {
ensureHmrClientInitialized()
// emi | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/dev/dev-nodejs.ts",
"language": "typescript",
"file_size": 3198,
"cut_index": 614,
"middle_length": 229
} |
>
/**
* Extensions to the shared runtime types that are specific to the development
* runtime (e.g. `module.hot`).
*/
declare const enum HotUpdateStatus {
idle = 'idle',
}
type HotUpdateStatusHandler = (status: HotUpdateStatus) => void
interface HotData {
prevExports?: Exports
}
// Used through reference co... | e AcceptErrorHandler = (
err: Error,
context: { moduleId: ModuleId; dependencyId: ModuleId }
) => void
type AcceptCallback = (outdatedDependencies: ModuleId[]) => void
interface AcceptFunction {
// accept updates for self
(errorHandler?: AcceptErr | s: ((data: object) => void)[]
acceptedDependencies: Record<ModuleId, AcceptCallback | (() => void)>
acceptedErrorHandlers: Record<ModuleId, AcceptErrorHandler | undefined>
declinedDependencies: Record<ModuleId, true>
}
typ | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime/dev-extensions.ts",
"language": "typescript",
"file_size": 2020,
"cut_index": 563,
"middle_length": 229
} |
instantiated as part of the runtime of a chunk.
*/
let runtimeModules: Set<ModuleId>
/**
* Maps module IDs to persisted data between executions of their hot module
* implementation (`hot.data`).
*/
const moduleHotData: Map<ModuleId, HotData> = new Map()
/**
* Maps module instances to their hot module state.
* U... | duleId[]) {
super(message)
this.dependencyChain = dependencyChain
}
}
type ModuleEffect =
| {
type: 'unaccepted'
dependencyChain: ModuleId[]
}
| {
type: 'self-declined'
dependencyChain: ModuleId[]
moduleId: | being updated).
*/
const queuedInvalidatedModules: Set<ModuleId> = new Set()
class UpdateApplyError extends Error {
name = 'UpdateApplyError'
dependencyChain: ModuleId[]
constructor(message: string, dependencyChain: Mo | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime/hmr-runtime.ts",
"language": "typescript",
"file_size": 30983,
"cut_index": 1331,
"middle_length": 229
} |
*
* It is separate from `runtime-utils.ts` because it can be used outside of
* runtime code, hence it should not contain any function declarations that are
* specific to the runtime context.
*/
type CurrentScript = { src: ChunkUrl | null }
type ChunkListPath = string & { readonly brand: unique symbol }
type ChunkL... | l be requested from the server), i.e. including CHUNK_BASE_PATH and
* CHUNK_SUFFIX), e.g. `/_next/static/chunks/21a106126841c540.js?dpl=1123123`
*/
type ChunkUrl = string & { readonly brand: unique symbol }
/** The dependency specifier when importing ext | H and CHUNK_SUFFIX, e.g. `static/chunks/21a106126841c540.js`
*/
type ChunkPath = string & { readonly brand: unique symbol }
type ChunkScript = CurrentScript & { readonly brand: unique symbol }
/**
* The URL of a chunk (what wil | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime/runtime-types.d.ts",
"language": "typescript",
"file_size": 4736,
"cut_index": 614,
"middle_length": 229
} |
ript-eslint/no-unused-vars */
declare var RUNTIME_PUBLIC_PATH: string
declare var RELATIVE_ROOT_PATH: string
declare var ASSET_PREFIX: string
const path = require('path')
const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')
// Compute the relative path to the `distDir`.
const relativePathToDistR... | a file or a directory.
*
* This fn allows to calculate an absolute path for some global static values, such as
* `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.
* See ImportMetaBinding::code_generation for the usage.
| ping distDir from the absolute path to this file.
const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)
/**
* Returns an absolute path to the given module path.
* Module path should be relative, either path to | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared-node/node-externals-utils.ts",
"language": "typescript",
"file_size": 1657,
"cut_index": 537,
"middle_length": 229
} |
* eslint-disable @typescript-eslint/no-unused-vars */
/// <reference path="../shared/runtime/runtime-utils.ts" />
function readWebAssemblyAsResponse(path: string) {
const { createReadStream } = require('fs') as typeof import('fs')
const { Readable } = require('stream') as typeof import('stream')
const stream =... |
async function instantiateWebAssemblyFromPath(
path: string,
importsObj: WebAssembly.Imports
): Promise<Exports> {
const response = readWebAssemblyAsResponse(path)
const { instance } = await WebAssembly.instantiateStreaming(
response,
im | lication/wasm',
},
})
}
async function compileWebAssemblyFromPath(
path: string
): Promise<WebAssembly.Module> {
const response = readWebAssemblyAsResponse(path)
return await WebAssembly.compileStreaming(response)
} | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared-node/node-wasm-utils.ts",
"language": "typescript",
"file_size": 1040,
"cut_index": 513,
"middle_length": 229
} |
rection
createModuleWithDirectionFlag = true
// This file must not use `import` and `export` statements. Otherwise, it
// becomes impossible to augment interfaces declared in `<reference>`d files
// (e.g. `Module`). Hence, the need for `import()` here.
type RefreshRuntimeGlobals =
import('@next/react-refresh-utils/d... | ignature: RefreshRuntimeGlobals['$RefreshSig$']
registerExports: typeof registerExportsAndSetupBoundaryForReactRefresh
}
type RefreshHelpers = RefreshRuntimeGlobals['$RefreshHelpers$']
type ModuleFactory = (
this: Module['exports'],
context: Turbop | hSig$: RefreshRuntimeGlobals['$RefreshSig$']
declare var $RefreshInterceptModuleExecution$: RefreshRuntimeGlobals['$RefreshInterceptModuleExecution$']
type RefreshContext = {
register: RefreshRuntimeGlobals['$RefreshReg$']
s | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/base/dev-base.ts",
"language": "typescript",
"file_size": 18292,
"cut_index": 1331,
"middle_length": 229
} |
pt-eslint/no-unused-vars */
/// <reference path="../base/runtime-base.ts" />
/// <reference path="../base/dev-base.ts" />
/// <reference path="./runtime-backend-dom.ts" />
/// <reference path="../../../shared/require-type.d.ts" />
let DEV_BACKEND: DevRuntimeBackend
;(() => {
DEV_BACKEND = {
unloadChunk(chunkUrl... | document.querySelectorAll(
`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`
)
for (const link of Array.from(links)) {
link.remove()
| hunkUrl = chunkUrl.split('?')[0]
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedBaseChunkUrl = decodeURI(baseChunkUrl)
if (isCss(chunkUrl)) {
const links = | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/dom/dev-backend-dom.ts",
"language": "typescript",
"file_size": 5663,
"cut_index": 716,
"middle_length": 229
} |
/// <reference path="../../../browser/runtime/base/runtime-base.ts" />
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX
const s... | new Map()
;(() => {
BACKEND = {
async registerChunk(chunk, params) {
let chunkPath = getPathFromScript(chunk)
let chunkUrl = getUrlFromScript(chunk)
const resolver = getOrCreateResolver(chunkUrl)
resolver.resolve()
i | olean
resolve: () => void
reject: (error?: Error) => void
promise: Promise<any>
}
let BACKEND: RuntimeBackend
/**
* Maps chunk paths to the corresponding resolver.
*/
const chunkResolvers: Map<ChunkUrl, ChunkResolver> = | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/dom/runtime-backend-dom.ts",
"language": "typescript",
"file_size": 7560,
"cut_index": 716,
"middle_length": 229
} |
) {
return manifests.reduce((mergedManifest, manifest) => {
if (!mergedManifest) {
return structuredClone(manifest)
}
if (manifest.version === 2) {
for (const suite in manifest.suites) {
if (mergedManifest.suites[suite]) {
const mergedSuite = mergedManifest.suites[suite]
... | }
}
mergedManifest.rules.include.push(...(manifest.rules.include || []))
mergedManifest.rules.exclude.push(...(manifest.rules.exclude || []))
return mergedManifest
}
throw new Error(`Merging manifests is only supported for | mergedSuite.flakey = [
...(mergedSuite.flakey || []),
...(currentSuite.flakey || []),
]
} else {
mergedManifest.suites[suite] = structuredClone(manifest.suites[suite])
| {
"filepath": "test/get-test-filter.js",
"language": "javascript",
"file_size": 4716,
"cut_index": 614,
"middle_length": 229
} |
ormalize line endings (fixes Windows CRLF issues)
// The issue: jscodeshift's printer (recast) outputs CRLF on Windows, but test fixtures use LF
// We need to patch both defineTest (which uses internal closure references) and runInlineTest
if (process.platform === 'win32') {
try {
const testUtils = require('jscod... | : string) =>
str
.replace(/\r\n/g, '\n')
.replace(/[ \t]+$/gm, '')
.replace(/\n*$/, '\n')
// Patch runInlineTest to normalize both transform output and expected
testUtils.runInlineTest = function (
module: any,
| rom each line (not meaningful for code)
// - Ensure exactly one trailing newline (POSIX convention for text files)
// Using \n*$ to handle case where transform output has no trailing newline
const normalizeLF = (str | {
"filepath": "test/jest-setup-after-env.ts",
"language": "typescript",
"file_size": 4187,
"cut_index": 614,
"middle_length": 229
} |
tick'
it('should execute async modules in to correct order and without additional ticks (case a)', async () => {
tick.start()
await require('./case-a/f')
expect(tick.stop()).toEqual([
'e 0',
'async before 0',
'async middle 1',
'async after 2',
'b 3',
'c 3',
'a 3',
'd 3',
'asyn... | async after 5',
])
})
it('should execute async modules in to correct order and without additional ticks (case c)', async () => {
tick.start()
await require('./case-c/a')
expect(tick.stop()).toEqual(['b 0', 'a before 0', 'a after 1'])
})
it('shoul | .start()
await require('./case-b/e')
expect(tick.stop()).toEqual([
'async before 0',
'async middle 1',
'async after 2',
'c 3',
'b 3',
'a 3',
'd 3',
'async before 3',
'async middle 4',
' | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/async-modules/micro-ticks-parents/input/index.js",
"language": "javascript",
"file_size": 1732,
"cut_index": 537,
"middle_length": 229
} |
l type definitions for Node.js Turbopack runtime.
* These properties are stored on globalThis to persist across chunk reloads during HMR.
*/
declare global {
var __turbopack_module_factories__: ModuleFactories
var __turbopack_module_cache__: Record<ModuleId, any>
var __turbopack_runtime_modules__: Set<ModuleId... | * full cache reset.
*/
// NodeJsHmrPayload is only in scope inside the concatenated runtime chunk, not
// in this .d.ts file, so the handler parameter must use any here.
var __turbopack_server_hmr_handlers__:
| Map<string, { handler: (upda | valuated. Reset to undefined by the hot-reloader on
| {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/nodejs-globals.d.ts",
"language": "typescript",
"file_size": 963,
"cut_index": 582,
"middle_length": 52
} |
ime/hmr-runtime.ts" />
/* eslint-disable @typescript-eslint/no-unused-vars */
type NodeJsHmrPayload = {
resource: {
path: string
headers?: Record<string, string>
}
issues: Issue[]
type: 'partial'
instruction: EcmascriptMergedUpdate
}
/**
* Appends the module code with //# sourceURL and //# sourceM... | const sourceURL = moduleId ? `${fileHref}?${moduleId}` : fileHref
let code = entry.code + '\n\n//# sourceURL=' + sourceURL
if (entry.map) {
code +=
'\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
Buffer.from(ent | nlineSourcemaps(entry: EcmascriptModuleEntry): string {
const [chunkPath, moduleId] = entry.url.split('?', 2)
const absolutePath = path.resolve(RUNTIME_ROOT, chunkPath)
const fileHref = url.pathToFileURL(absolutePath).href
| {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/dev/hmr-client.ts",
"language": "typescript",
"file_size": 3658,
"cut_index": 614,
"middle_length": 229
} |
e
* update.
* SourceData is an array of ModuleIds or undefined.
*/
Update = 2,
}
type SourceData = ChunkPath | ModuleId | ModuleId[] | undefined
// @ts-ignore Defined in `dev-base.ts`
declare function getOrInstantiateModuleFromParent<M>(
id: ModuleId,
sourceModule: M
): M
// @ts-ignore Defined in `hmr... | WithDirectionFlag = false
const REEXPORTED_OBJECTS = new WeakMap<Module, ReexportedObjects>()
/**
* Constructs the `__turbopack_context__` object for a module.
*/
function Context(
this: TurbopackBaseContext<Module>,
module: Module,
exports: Expo | by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,
* nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it
* uses plain Module objects.
*/
let createModule | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime/runtime-utils.ts",
"language": "typescript",
"file_size": 23473,
"cut_index": 1331,
"middle_length": 229
} |
hared/runtime/runtime-utils.ts" />
/// A 'base' utilities to support runtime can have externals.
/// Currently this is for node.js / edge runtime both.
/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.
async function externalImport(id: DependencySpecifier) {
let r... | .default && 'default' in raw.default) {
return interopEsm(raw.default, createNS(raw), true)
}
return raw
}
contextPrototype.y = externalImport
function externalRequire(
id: ModuleId,
thunk: () => any,
esm: boolean = false
): Exports | EsmNa | g. querystring, url).
// For now, we fail semi-silently, but in the future this should be a
// compilation error.
throw new Error(`Failed to load external module ${id}: ${err}`)
}
if (raw && raw.__esModule && raw | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared-node/base-externals-utils.ts",
"language": "typescript",
"file_size": 1689,
"cut_index": 537,
"middle_length": 229
} |
d in WebWorkers to tell the runtime about the chunk suffix
declare var TURBOPACK_ASSET_SUFFIX: string
// Used in WebWorkers to tell the runtime about the current chunk url since it
// can't be detected via `document.currentScript`. Note it's stored in reversed
// order to use `push` and `pop`
declare var TURBOPACK_NEXT... | differs from
* the worker's own origin, so the override has to apply to both — using
* `WORKER_BASE_PATH` only for the entrypoint would leave the worker unable
* to load any chunks when `CHUNK_BASE_PATH` is on a different origin.
*/
declare var WORKER_ | side the worker). Mirrors webpack's
* `output.workerPublicPath`. `null` means "use CHUNK_BASE_PATH"; an empty
* string is a literal empty prefix (not a fallback).
*
* The worker's bootstrap rejects module chunks whose origin | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/base/runtime-base.ts",
"language": "typescript",
"file_size": 15531,
"cut_index": 921,
"middle_length": 229
} |
ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
module.exports = {
mode: 'development',
resolve: {
extensions: ['.jsx', '...'],
},
module: {
unsafeCache: true,
rules: [
{
test: /\.jsx$/,
loader: 'swc-loader',
options: {
jsc: {
... | },
externalHelpers: true,
transform: {
react: {
runtime: 'automatic',
refresh: true,
},
},
},
},
},
],
},
devServer: {
h | classPrivateProperty: true,
exportDefaultFrom: true,
exportNamespaceFrom: true,
decorators: true,
decoratorsBeforeExport: true,
importMeta: true,
| {
"filepath": "turbopack/crates/turbopack-bench/src/bundlers/webpack/webpack.config.js",
"language": "javascript",
"file_size": 1187,
"cut_index": 518,
"middle_length": 229
} |
rt './b'
import './c'
import D from './d'
import './e'
import './f'
import a from './dep?a'
import b from './dep?b'
import c from './dep?c'
import d from './dep?d'
import e from './dep?e'
import f from './dep?f'
it('should generate valid code', () => {
expect(A()).toBe('x')
expect(new D().method()).toBe('x')
})
... | xpect(c).toBe(true)
})
if (process.env.NODE_ENV === 'production') {
it('d should be used', () => {
expect(d).toBe(true)
})
it('e should be unused', () => {
expect(e).toBe(false)
})
}
it('f should be used', () => {
expect(f).toBe(true)
| ', () => {
e | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/inner-graph/export-default-named/input/index.js",
"language": "javascript",
"file_size": 809,
"cut_index": 536,
"middle_length": 14
} |
h="../../shared-node/node-externals-utils.ts" />
/// <reference path="../../shared-node/node-wasm-utils.ts" />
/// <reference path="./nodejs-globals.d.ts" />
/**
* Base Node.js runtime shared between production and development.
* Contains chunk loading, module caching, and other non-HMR functionality.
*/
process.e... | ult ?? exported
if (typeof exportedPath !== 'string') {
return exported as any
}
const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)
const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)
return url.pathToFileURL(r | Returns an absolute path to the given module's id.
*/
function resolvePathFromModule(
this: TurbopackBaseContext<Module>,
moduleId: string
): string {
const exported = this.r(moduleId)
const exportedPath = exported?.defa | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/runtime-base.ts",
"language": "typescript",
"file_size": 6495,
"cut_index": 716,
"middle_length": 229
} |
runtime (e.g. for Edge).
*
* It will be appended to the base development runtime code.
*/
/* eslint-disable @typescript-eslint/no-unused-vars */
/// <reference path="../base/runtime-base.ts" />
/// <reference path="../../../shared/require-type.d.ts" />
/// <reference path="../../../shared-node/base-externals-utils... | erChunk(chunk, params) {
let chunkPath = getPathFromScript(chunk)
registeredChunks.add(chunkPath)
instantiateDependentChunks(chunkPath)
if (params == null) {
return
}
if (params.otherChunks.length === 0) {
| ntime expects all chunks within the same chunk group to be
// registered before any of them are instantiated.
// Furthermore, modules must be instantiated synchronously, hence we don't
// use promises here.
regist | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/edge/runtime-backend-edge.ts",
"language": "typescript",
"file_size": 5034,
"cut_index": 614,
"middle_length": 229
} |
erence path="./dummy.ts" />
const moduleCache: ModuleCache<Module> = {}
contextPrototype.c = moduleCache
/**
* Gets or instantiates a runtime module.
*/
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getOrInstantiateRuntimeModule(
chunkPath: ChunkPath,
moduleId: ModuleId
):... | oduleFromParent: GetOrInstantiateModuleFromParent<
Module
> = (id, sourceModule) => {
const module = moduleCache[id]
if (module) {
if (module.error) {
throw module.error
}
return module
}
return instantiateModule(id, SourceTyp | untime, chunkPath)
}
/**
* Retrieves a module from the cache, or instantiate it if it is not cached.
*/
// Used by the backend
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const getOrInstantiateM | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/runtime/base/build-base.ts",
"language": "typescript",
"file_size": 2901,
"cut_index": 563,
"middle_length": 229
} |
ould allow to import an rejected async module again', async () => {
await expect(require('./main')).rejects.toEqual(
expect.objectContaining({
message: expect.stringContaining('expected rejection 1'),
})
)
await expect(require('./module')).rejects.toEqual(
expect.objectContaining({
message... | ire('./module?3')).rejects.toEqual(
expect.objectContaining({
message: expect.stringContaining('expected rejection 3'),
})
),
expect(require('./module?4')).rejects.toEqual(
expect.objectContaining({
message: expect | ted rejection 2'),
})
)
await expect(require('./reexport?2')).rejects.toEqual(
expect.objectContaining({
message: expect.stringContaining('expected rejection 1'),
})
)
await Promise.all([
expect(requ | {
"filepath": "turbopack/crates/turbopack-tests/tests/execution/webpack/async-modules/top-level-error/input/index.js",
"language": "javascript",
"file_size": 1235,
"cut_index": 518,
"middle_length": 229
} |
ack-message'
data: Record<string, any>
}
export type ClientOptions = {
addMessageListener: (cb: (msg: WebSocketMessage) => void) => void
sendMessage: SendMessage
onUpdateError: (err: unknown) => void
}
export function connect({
addMessageListener,
sendMessage,
onUpdateError = console.error,
}: C... | .data as ServerMessage)
}
applyAggregatedUpdates()
} catch (e: unknown) {
console.warn(
'[Fast Refresh] performing full reload\n\n' +
"Fast Refresh will perform a full reload when you edit a f | if (Array.isArray(msg.data)) {
for (let i = 0; i < msg.data.length; i++) {
handleSocketMessage(msg.data[i] as ServerMessage)
}
} else {
handleSocketMessage(msg | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/browser/dev/hmr-client/hmr-client.ts",
"language": "typescript",
"file_size": 15809,
"cut_index": 921,
"middle_length": 229
} |
communicate between the
* Turbopack runtime and the Turbopack server for issue reporting and HMR.
*/
type PartialServerMessage = {
resource: ResourceIdentifier
issues: Issue[]
type: 'partial'
instruction: PartialUpdate
}
// string encoding of a module factory (used in hmr updates)
type ModuleFactoryString =... | : 'ChunkListUpdate'
chunks?: Record<ChunkPath, ChunkUpdate>
merged?: MergedChunkUpdate[]
}
type ChunkUpdate =
| {
type: 'added'
}
| { type: 'deleted' }
| { type: 'total' }
// We currently don't have any chunks that can be updated par | type: 'issues'
}
| UnknownType
)
type UnknownType = {
type: 'future-type-marker-do-not-use-or-you-will-be-fired'
}
type PartialUpdate =
| ChunkListUpdate
| {
type: never
}
type ChunkListUpdate = {
type | {
"filepath": "turbopack/crates/turbopack-ecmascript-runtime/js/src/shared/runtime/dev-protocol.d.ts",
"language": "typescript",
"file_size": 2737,
"cut_index": 563,
"middle_length": 229
} |
etRedboxDescriptionWarning,
getRedboxErrorLink,
} from './next-test-utils'
import type { NextInstance } from './next-modes/base'
import type { Playwright } from './browsers/playwright'
export async function waitForHydration(browser: Playwright) {
await browser.eval(() => {
return new Promise<void>((resolve) =>... | : string = '/',
webDriverOptions:
| Parameters<NextInstance['browser']>[1]
| undefined = undefined
) {
let unwrappedByTypeScriptUsingKeyword = false
try {
await next.stop()
await next.clean()
if (initialFiles) {
for (const | {
clearTimeout(timeout)
resolve()
}
}
})
})
}
export async function createSandbox(
next: NextInstance,
initialFiles?: Map<string, string | ((contents: string) => string)>,
initialUrl | {
"filepath": "test/lib/development-sandbox.ts",
"language": "typescript",
"file_size": 5585,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-19/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-22/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-9/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-15/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-7/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-25/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-14/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-23/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-4/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-6/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-12/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-8/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-3/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-2/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-5/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | ame="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel=" | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classN | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-21/page.js",
"language": "javascript",
"file_size": 5864,
"cut_index": 716,
"middle_length": 229
} |
{ join } from 'path'
import { tmpdir } from 'os'
import execa from 'execa'
describe('merge-errors-json driver', () => {
it('should correctly merge errors.json files with conflicting new entries', async () => {
const base = {
'1': 'Original message 1',
'2': 'Original message 2',
}
const curre... | 1',
'6': 'From our branch 2',
})
})
it('should handle empty base file', async () => {
const base = {}
const current = {
'1': 'Message from a conflicting branch that was merged first',
}
const rebased = await simulateReb | base({
base,
current,
incoming: {
...base,
'3': 'From our branch 1',
'4': 'From our branch 2',
},
})
expect(rebased).toEqual({
...current,
'5': 'From our branch | {
"filepath": "test/scripts/merge-errors-json/merge-errors-json.test.ts",
"language": "typescript",
"file_size": 3200,
"cut_index": 614,
"middle_length": 229
} |
from 'e2e-utils'
import stripAnsi from 'strip-ansi'
describe('build-error-logs', () => {
const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname,
})
it('should only log error a single time', async () => {
await next.fetch('/')
const output = stripAnsi(next.cliOutput)
expect(ou... | gs).toHaveLength(1)
} else if (isRspack) {
expect([2, 3]).toContain(moduleNotFoundLogs.length)
} else {
// FIXME: next with webpack still logs the same error too many times
expect(moduleNotFoundLogs).toHaveLength(3)
}
})
})
| duleNotFoundLo | {
"filepath": "test/development/app-dir/build-error-logs/build-error-logs.test.ts",
"language": "typescript",
"file_size": 806,
"cut_index": 536,
"middle_length": 14
} |
getRedboxDescription,
getRedboxSource,
waitForRedbox,
} from 'next-test-utils'
import { outdent } from 'outdent'
describe('ecmascript-error-title', () => {
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
})
it('should show the specific SWC error message as title for syntax errors', asy... | t waitForRedbox(browser)
const description = await getRedboxDescription(browser)
expect(description).toBe("Expected '>', got '<eof>'")
const source = await getRedboxSource(browser)
expect(source).toContain("Expected '>', got '<eof> | export default () => <div/
`
)
if (isTurbopack) {
// The redbox description should show the specific SWC error message
// instead of the generic "Parsing ecmascript source code failed".
awai | {
"filepath": "test/development/app-dir/ecmascript-error-title/ecmascript-error-title.test.ts",
"language": "typescript",
"file_size": 2086,
"cut_index": 563,
"middle_length": 229
} |
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
// FIXME: er-enable when we have a better implementation of node binary resolving
describe.skip('externalize-node-binary-browser-error', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should error when import node binary on... | ect(redbox.description).toBe('Failed to compile')
expect(redbox.source).toMatchInlineSnapshot(`
"./node_modules/foo-browser-import-binary/binary.node
Error: Node.js binary module ./node_modules/foo-browser-import-binary/binary.node is n | urce: await getRedboxSource(browser),
}
exp | {
"filepath": "test/development/app-dir/externalize-node-binary-browser-error/externalize-node-binary-browser-error.test.ts",
"language": "typescript",
"file_size": 979,
"cut_index": 582,
"middle_length": 52
} |
from 'e2e-utils'
import {
waitForDevToolsIndicator,
assertNoDevToolsIndicator,
toggleDevToolsIndicatorPopover,
waitFor,
} from 'next-test-utils'
const COOLDOWN = 3000
describe('dev indicator - Hide DevTools Button', () => {
const { next } = nextTestSetup({
files: __dirname,
env: {
__NEXT_DEV_I... | .stop()
await next.start()
const browser2 = await next.browser('/')
await browser2.refresh()
await waitForDevToolsIndicator(browser2)
})
it('should still hide the dev indicator after reloading the page', async () => {
const browse | it toggleDevToolsIndicatorPopover(browser)
await browser.elementByCss('[data-preferences]').click()
await browser.elementByCss('[data-hide-dev-tools]').click()
await assertNoDevToolsIndicator(browser)
await next | {
"filepath": "test/development/app-dir/dev-indicator/hide-button.test.ts",
"language": "typescript",
"file_size": 1948,
"cut_index": 537,
"middle_length": 229
} |
from 'e2e-utils'
import { waitForStaticIndicator } from 'next-test-utils'
describe('app dir dev indicator - route type', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should have route type as static by default for static page', async () => {
const browser = await next.browser('/')
... | ')
} finally {
await next.patchFile('app/page.tsx', origContent)
}
})
it('should have route type as dynamic when on load of dynamic page', async () => {
const origContent = await next.readFile('app/page.tsx')
await next.patchFil | const origContent = await next.readFile('app/page.tsx')
await next.patchFile(
'app/page.tsx',
origContent.replace('// headers()', 'headers()')
)
try {
await waitForStaticIndicator(browser, 'Dynamic | {
"filepath": "test/development/app-dir/dev-indicator/route-type.test.ts",
"language": "typescript",
"file_size": 1552,
"cut_index": 537,
"middle_length": 229
} |
xSource,
} from 'next-test-utils'
describe('app-dir - server-component-next-dynamic-ssr-false', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should error when use dynamic ssr:false in server component', async () => {
const browser = await next.browser('/')
await waitForRedbox(br... | "./app/page.js (3:23)
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component.
1 | import dynamic from 'next/dynamic'
2 |
> 3 | const DynamicClient = dynamic(() | edbox.description).toMatchInlineSnapshot(
`"\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."`
)
expect(redbox.source).toMatchInlineSnapshot(`
| {
"filepath": "test/development/app-dir/server-component-next-dynamic-ssr-false/server-component-next-dynamic-ssr-false.test.ts",
"language": "typescript",
"file_size": 3168,
"cut_index": 614,
"middle_length": 229
} |
assName="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-aut... | me="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="n | <div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
classNa | {
"filepath": "test/.stats-app/app/edge-ssr-repeated-1/page.js",
"language": "javascript",
"file_size": 5863,
"cut_index": 716,
"middle_length": 229
} |
() => {
const { next } = nextTestSetup({ files: __dirname, patchFileDelay: 1000 })
const loggedAfterValueRegexp = /After: (\d\.\d+)/
let cliOutputLength: number
const getLoggedAfterValue = () => {
const match = next.cliOutput
.slice(cliOutputLength)
.match(loggedAfterValueRegexp)
if (!matc... | => {
const browser = await next.browser(`/${runtime}`)
const valueBeforePatch = await browser.elementById('value').text()
await next.patchFile(
'components/shared-page.tsx',
(content) => content.replace('foo', 'bar'),
| ['node'] : ['edge', 'node']
beforeEach(() => {
cliOutputLength = next.cliOutput.length
})
describe.each(runtimes)('%s runtime', (runtime) => {
it('should use cached fetch calls for fast refresh requests', async () | {
"filepath": "test/development/app-dir/server-components-hmr-cache/server-components-hmr-cache.test.ts",
"language": "typescript",
"file_size": 8803,
"cut_index": 716,
"middle_length": 229
} |
e: 'performance' | 'console'
name: string
properties: any
startTime: number
endTime: number
}>
declare global {
interface Window {
reactServerRequests: {
/** For tests */
getSnapshot: () => Array<
Omit<ReactServerRequests[number], 'startTime' | 'endTime' | 'type'>
>
getSto... | urn reactServerRequests
.filter((request) => {
const isRegisterTrackRequest =
request.type === 'console' &&
request.name === undefined &&
request.startTime === 0.001 &&
request.endTime === 0.001
| ts = []
const listeners = new Set<() => void>()
// The store implementation is just a local debugging aid.
// Assertions should happen on `getSnapshot` not on the UI.
window.reactServerRequests = {
getSnapshot: () => {
ret | {
"filepath": "test/development/app-dir/react-performance-track/instrumentation-client.ts",
"language": "typescript",
"file_size": 2929,
"cut_index": 563,
"middle_length": 229
} |
he default when visiting pages as an ordinary user.
// true is the default when having Chrome DevTools open.
// Hardcoded for now since most of the actual behavior is not intended.
const disableCache = false
const extraHTTPHeaders = disableCache
? { 'Cache-Control': 'no-cache' }
: undefined
const { n... | { name: '\u200bsetTimeout', properties: [] },
{ name: '\u200bsetTimeout', properties: [] },
])
)
})
it('should show fetch', async () => {
const browser = await next.browser('/fetch', { extraHTTPHeaders })
await browser.ele | elementByCss('[data-react-server-requests-done]', {
state: 'attached',
})
const track = await browser.eval('window.reactServerRequests.getSnapshot()')
expect(track).toEqual(
expect.arrayContaining([
| {
"filepath": "test/development/app-dir/react-performance-track/react-performance-track.test.ts",
"language": "typescript",
"file_size": 4672,
"cut_index": 614,
"middle_length": 229
} |
import { useSyncExternalStore } from 'react'
const reactServerRequestsServerSnapshot: never[] = []
const ServerRequestsStore = {
subscribe:
typeof window === 'undefined'
? () => () => {}
: window.reactServerRequests.subscribe,
getSnapshot:
typeof window === 'undefined'
? () => []
... | {reactServerRequests.map((request, index) => (
<li key={index}>
<details>
<summary>
<strong>
{request.type}: {request.name || '<Unnamed>'}
</strong>
( | ernalStore(
ServerRequestsStore.subscribe,
ServerRequestsStore.getSnapshot,
ServerRequestsStore.getServerSnapshot
)
return (
<>
<p>{reactServerRequests.length} Server Request entries</p>
<ol>
| {
"filepath": "test/development/app-dir/react-performance-track/app/ReactServerRequests.tsx",
"language": "tsx",
"file_size": 1268,
"cut_index": 524,
"middle_length": 229
} |
{ ReactNode, Suspense } from 'react'
import { ReactServerRequests } from './ReactServerRequests'
import Link from 'next/link'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body style={{ display: 'flex', flexDirection: 'row', gap: '1rem' }}>
<ul>
<... | <Link href="/headers">headers</Link>
</li>
<li>
<Link href="/cookies">cookies</Link>
</li>
<li>
<Link href="/draftMode">draftMode</Link>
</li>
</ul>
<main> | imeout</Link>
</li>
<li>
<Link href="/params/next">params</Link>
</li>
<li>
<Link href="/searchparams?slug=next">searchParams</Link>
</li>
<li>
| {
"filepath": "test/development/app-dir/react-performance-track/app/layout.tsx",
"language": "tsx",
"file_size": 1239,
"cut_index": 518,
"middle_length": 229
} |
ts child dependency update without re-evaluating',
async () => {
const browser = await next.browser('/dep-accept')
// Wait for initial render and hydration (eval time only appears after useEffect)
await retry(async () => {
const text = await browser.elementByCss('#dep-value').te... | al accept call count
const initialCallCount = await browser
.elementByCss('#accept-call-count')
.text()
expect(initialCallCount).toBe('Accept Calls: 0')
// Patch the dependency to change its exported value
| Match(/Parent Evaluated At: \d+/)
})
// Capture the parent evaluation timestamp
const parentEvalTime = await browser
.elementByCss('#parent-eval-time')
.text()
// Verify initi | {
"filepath": "test/development/app-dir/hmr-dep-accept/hmr-dep-accept.test.ts",
"language": "typescript",
"file_size": 9382,
"cut_index": 921,
"middle_length": 229
} |
import { useEffect, useState, useRef } from 'react'
import { value } from './dep'
// Track when this module was evaluated (should NOT change on dep update)
const evaluatedAt = Date.now()
export default function DepAcceptPage() {
const [depValue, setDepValue] = useState(value)
const [acceptCallCount, setAcceptCa... |
if (import.meta.turbopackHot) {
import.meta.turbopackHot.accept('./dep', () => {
// ESM bindings are automatically re-imported before this callback runs,
// so `value` already reflects the updated module.
if (mountedRef.c | e on client only to avoid hydration mismatch
setEvalTime(evaluatedAt)
return () => {
mountedRef.current = false
}
}, [])
useEffect(() => {
// import.meta.turbopackHot is the ESM equivalent of module.hot | {
"filepath": "test/development/app-dir/hmr-dep-accept/app/dep-accept/page.tsx",
"language": "tsx",
"file_size": 1379,
"cut_index": 524,
"middle_length": 229
} |
import { useEffect, useState, useRef } from 'react'
import { valueA } from './dep-a'
import { valueB } from './dep-b'
const evaluatedAt = Date.now()
export default function DepAcceptArrayPage() {
const [depAValue, setDepAValue] = useState(valueA)
const [depBValue, setDepBValue] = useState(valueB)
const [accep... | // ESM bindings are automatically re-imported before this callback runs,
// so `valueA` and `valueB` already reflect the updated modules.
if (mountedRef.current) {
setDepAValue(valueA)
setDepBValue(valueB)
| rue
setEvalTime(evaluatedAt)
return () => {
mountedRef.current = false
}
}, [])
useEffect(() => {
if (import.meta.turbopackHot) {
import.meta.turbopackHot.accept(['./dep-a', './dep-b'], () => {
| {
"filepath": "test/development/app-dir/hmr-dep-accept/app/dep-accept-array/page.tsx",
"language": "tsx",
"file_size": 1377,
"cut_index": 524,
"middle_length": 229
} |
client'
import { useEffect, useState } from 'react'
import { valueA } from './dep-a'
import { valueB } from './dep-b'
// Track when this module was evaluated
const evaluatedAt = Date.now()
export default function DepDeclineArrayPage() {
const [evalTime, setEvalTime] = useState<number | null>(null)
useEffect(() ... | .decline(['./dep-a', './dep-b'])
}
}, [])
return (
<div>
<p id="dep-a-value">{valueA}</p>
<p id="dep-b-value">{valueB}</p>
{evalTime !== null && (
<p id="parent-eval-time">Parent Evaluated At: {evalTime}</p>
)}
| a.turbopackHot | {
"filepath": "test/development/app-dir/hmr-dep-accept/app/dep-decline-array/page.tsx",
"language": "tsx",
"file_size": 806,
"cut_index": 517,
"middle_length": 14
} |
ywright'
export type { Playwright }
if (!process.env.TEST_FILE_PATH) {
process.env.TEST_FILE_PATH = module.parent!.filename
}
let deviceIP: string
const isBrowserStack = !!process.env.BROWSERSTACK
;(global as any).browserName = process.env.BROWSER_NAME || 'chrome'
if (isBrowserStack) {
const nets = os.networkIn... | l(async () => {
await Promise.all(browserTeardown.map((f) => f())).catch((e) =>
console.error('browser teardown', e)
)
if (browserQuit) {
await browserQuit()
}
})
}
export interface WebdriverOptions {
permissions?: Permiss | ress
done = true
break
}
}
if (done) break
}
}
let browserTeardown: (() => Promise<void>)[] = []
let browserQuit: (() => Promise<void>) | undefined
if (typeof afterAll === 'function') {
afterAl | {
"filepath": "test/lib/next-webdriver.ts",
"language": "typescript",
"file_size": 5923,
"cut_index": 716,
"middle_length": 229
} |
client. This option is only supported when nested inside an outer `act`
* scope. The blocked response will be fulfilled when the outer
* scope completes.
*
* The list of expected responses does not need to be exhaustive — any
* responses that don't match will proceed like normal. However, `act` will
* error ... | ted, pass "no-requests".
*/
type ActConfig =
| ExpectedResponseConfig
| Array<ExpectedResponseConfig>
| 'block'
| 'no-requests'
| null
export function createRouterAct(
page: Playwright.Page,
options?: {
/**
* Status codes that are | iple responses.
*
* If no expected responses are provided, the only expectation is that at
* least one request is initiated. (This is the same as passing an
* empty array.)
*
* Alternatively, if no network activity is expec | {
"filepath": "test/lib/router-act.ts",
"language": "typescript",
"file_size": 24171,
"cut_index": 1331,
"middle_length": 229
} |
ess.env.TRACE_PLAYWRIGHT
const defaultTimeout = process.env.NEXT_E2E_TEST_TIMEOUT
? parseInt(process.env.NEXT_E2E_TEST_TIMEOUT, 10)
: // In development mode, compilation can take longer due to lower CPU
// availability in GitHub Actions.
60 * 1000
// loose global to register teardown functions before quit... | ntext?.close()
await browser?.close()
context = undefined
browser = undefined
}
async function teardown(tearDownFn: () => Promise<void>) {
pendingTeardown.push(tearDownFn)
await tearDownFn()
pendingTeardown.splice(pendingTeardown.indexOf(tearD | uit` might need to be removed, instead should introduce per-instance teardown
const pendingTeardown: Array<() => Promise<void>> = []
export async function quit() {
await Promise.all(pendingTeardown.map((fn) => fn()))
await co | {
"filepath": "test/lib/browsers/playwright.ts",
"language": "typescript",
"file_size": 22247,
"cut_index": 1331,
"middle_length": 229
} |
_res: http.ServerResponse
resolve: (value?: string) => any
reject: (value: any) => any
}
type TestDataServer = {
_server: http.Server
listen: (port: number) => void
close: () => void
}
// Creates a lightweight HTTP server for use in e2e testing. This simulates the
// data service that would be used in a r... | t can respond with any text it wants.
//
// Examples:
// response.resolve() // Responds with the key itself
// response.resolve('custom') // Responds with custom text
// response.reject(new Error('oops!')) // Responds with a 500 error
//
// Based on |
// timing of when the data is fulfilled, without needing to mock any lower
// level I/O.
//
// Receives requests of the form: /?key=foo
//
// Responds in plain text. By default, the response is the key itself, but the
// e2e tes | {
"filepath": "test/lib/test-data-service/writer.ts",
"language": "typescript",
"file_size": 2205,
"cut_index": 563,
"middle_length": 229
} |
ates static and dynamic content in a response stream
* by splitting on PPR boundary sentinel markers.
*
* This function is used in Partial Prerendering (PPR) tests to analyze the output
* of Next.js pages and verify that static and dynamic content are properly separated.
*
* @param fn - A function that returns a ... | // Content after the boundary
*/
export async function splitResponseWithPPRSentinel(
fn: () => Promise<NodeJS.ReadableStream>
): Promise<[staticPart: string, dynamicPart: string]> {
const stream = await fn()
const chunks: string[] = []
await new | [staticPart, dynamicPart] = await splitResponseWithPPRSentinel(async () => {
* return fetch('/some-ppr-page').then(res => res.body)
* })
* console.log(staticPart) // Content before the boundary
* console.log(dynamicPart) | {
"filepath": "test/lib/e2e-utils/ppr.ts",
"language": "typescript",
"file_size": 1552,
"cut_index": 537,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.