Unverified Commit 7e11a155 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: improve missing factory message (#84881)

Don't mention HMR for prod builds
parent 1112dce6
......@@ -55,7 +55,7 @@ function instantiateModule(
// This can happen if modules incorrectly handle HMR disposes/updates,
// e.g. when they keep a `setTimeout` around which still executes old code
// and contains e.g. a `require("something")` call.
factoryNotAvailable(id, sourceType, sourceData)
throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData))
}
const module: Module = createModuleObject(id)
......
......@@ -194,7 +194,10 @@ function instantiateModule(
// This can happen if modules incorrectly handle HMR disposes/updates,
// e.g. when they keep a `setTimeout` around which still executes old code
// and contains e.g. a `require("something")` call.
factoryNotAvailable(id, sourceType, sourceData)
throw new Error(
factoryNotAvailableMessage(id, sourceType, sourceData) +
' It might have been deleted in an HMR update.'
)
}
const hotData = moduleHotData.get(id)!
......
......@@ -106,11 +106,11 @@ const availableModules: Map<ModuleId, Promise<any> | true> = new Map()
const availableModuleChunks: Map<ChunkPath, Promise<any> | true> = new Map()
function factoryNotAvailable(
function factoryNotAvailableMessage(
moduleId: ModuleId,
sourceType: SourceType,
sourceData: SourceData
): never {
): string {
let instantiationReason
switch (sourceType) {
case SourceType.Runtime:
......@@ -128,9 +128,7 @@ function factoryNotAvailable(
(sourceType) => `Unknown source type: ${sourceType}`
)
}
throw new Error(
`Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`
)
return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`
}
function loadChunk(
......
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="9cf0cfff-fe6b-e2a6-ed5a-275f25467c66")}catch(e){}}();
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="8faf1c28-5e36-9739-d4ef-60847ff8a1f3")}catch(e){}}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0b8736b3.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]}
......@@ -523,7 +523,7 @@ const moduleFactories = new Map();
contextPrototype.M = moduleFactories;
const availableModules = new Map();
const availableModuleChunks = new Map();
function factoryNotAvailable(moduleId, sourceType, sourceData) {
function factoryNotAvailableMessage(moduleId, sourceType, sourceData) {
let instantiationReason;
switch(sourceType){
case 0:
......@@ -538,7 +538,7 @@ function factoryNotAvailable(moduleId, sourceType, sourceData) {
default:
invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
}
throw new Error(`Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`);
return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`;
}
function loadChunk(chunkData) {
return loadChunkInternal(1, this.m.id, chunkData);
......@@ -819,7 +819,7 @@ function instantiateModule(moduleId, sourceType, sourceData) {
// This can happen if modules incorrectly handle HMR disposes/updates,
// e.g. when they keep a `setTimeout` around which still executes old code
// and contains e.g. a `require("something")` call.
factoryNotAvailable(id, sourceType, sourceData);
throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData) + ' It might have been deleted in an HMR update.');
}
const hotData = moduleHotData.get(id);
const { hot, hotState } = createModuleHot(id, hotData);
......@@ -1834,5 +1834,5 @@ chunkListsToRegister.forEach(registerChunkList);
})();
//# debugId=9cf0cfff-fe6b-e2a6-ed5a-275f25467c66
//# debugId=8faf1c28-5e36-9739-d4ef-60847ff8a1f3
//# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js.map
\ No newline at end of file
......@@ -522,7 +522,7 @@ const moduleFactories = new Map();
contextPrototype.M = moduleFactories;
const availableModules = new Map();
const availableModuleChunks = new Map();
function factoryNotAvailable(moduleId, sourceType, sourceData) {
function factoryNotAvailableMessage(moduleId, sourceType, sourceData) {
let instantiationReason;
switch(sourceType){
case 0:
......@@ -537,7 +537,7 @@ function factoryNotAvailable(moduleId, sourceType, sourceData) {
default:
invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
}
throw new Error(`Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`);
return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`;
}
function loadChunk(chunkData) {
return loadChunkInternal(1, this.m.id, chunkData);
......@@ -818,7 +818,7 @@ function instantiateModule(moduleId, sourceType, sourceData) {
// This can happen if modules incorrectly handle HMR disposes/updates,
// e.g. when they keep a `setTimeout` around which still executes old code
// and contains e.g. a `require("something")` call.
factoryNotAvailable(id, sourceType, sourceData);
throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData) + ' It might have been deleted in an HMR update.');
}
const hotData = moduleHotData.get(id);
const { hot, hotState } = createModuleHot(id, hotData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment