mirror of https://github.com/webpack/webpack.git
				
				
				
			Merge pull request #13708 from webpack/bugfix/crash-unsafe-cache
fixes #13691
This commit is contained in:
		
						commit
						6bccc34eab
					
				|  | @ -766,6 +766,7 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 					if (!unsafeCacheData.has(module)) { | ||||
| 						unsafeCacheData.set(module, module.getUnsafeCacheData()); | ||||
| 					} | ||||
| 					this._restoredUnsafeCacheEntries.add(module); | ||||
| 				} | ||||
| 
 | ||||
| 				callback(null, factoryResult); | ||||
|  |  | |||
|  | @ -265,7 +265,7 @@ class AssetGenerator extends Generator { | |||
| 	 * @returns {Set<string>} available types (do not mutate) | ||||
| 	 */ | ||||
| 	getTypes(module) { | ||||
| 		if (module.buildInfo.dataUrl || this.emit === false) { | ||||
| 		if ((module.buildInfo && module.buildInfo.dataUrl) || this.emit === false) { | ||||
| 			return JS_TYPES; | ||||
| 		} else { | ||||
| 			return JS_AND_ASSET_TYPES; | ||||
|  | @ -289,7 +289,7 @@ class AssetGenerator extends Generator { | |||
| 				return originalSource.size(); | ||||
| 			} | ||||
| 			default: | ||||
| 				if (module.buildInfo.dataUrl) { | ||||
| 				if (module.buildInfo && module.buildInfo.dataUrl) { | ||||
| 					const originalSource = module.originalSource(); | ||||
| 
 | ||||
| 					if (!originalSource) { | ||||
|  |  | |||
|  | @ -116,7 +116,7 @@ class JsonGenerator extends Generator { | |||
| 	 * @returns {number} estimate size of the module | ||||
| 	 */ | ||||
| 	getSize(module, type) { | ||||
| 		let data = module.buildInfo.jsonData; | ||||
| 		let data = module.buildInfo && module.buildInfo.jsonData; | ||||
| 		if (!data) return 0; | ||||
| 		return stringifySafe(data).length + 10; | ||||
| 	} | ||||
|  | @ -145,7 +145,7 @@ class JsonGenerator extends Generator { | |||
| 			concatenationScope | ||||
| 		} | ||||
| 	) { | ||||
| 		const data = module.buildInfo.jsonData; | ||||
| 		const data = module.buildInfo && module.buildInfo.jsonData; | ||||
| 		if (data === undefined) { | ||||
| 			return new RawSource( | ||||
| 				runtimeTemplate.missingModuleStatement({ | ||||
|  |  | |||
|  | @ -0,0 +1,5 @@ | |||
| import "./unchanged-module.js"; | ||||
| import "./unchanged-module.json"; | ||||
| new URL("./unchanged-module.svg", import.meta.url); | ||||
| 
 | ||||
| export default "0"; | ||||
|  | @ -0,0 +1,5 @@ | |||
| import value from "./changing-module"; | ||||
| 
 | ||||
| it("should compile and cleanup correctly", () => { | ||||
| 	expect(value).toBe(WATCH_STEP); | ||||
| }); | ||||
|  | @ -0,0 +1,3 @@ | |||
| import "./unchanged-module.js"; | ||||
| import "./unchanged-module.json"; | ||||
| new URL("./unchanged-module.svg", import.meta.url); | ||||
|  | @ -0,0 +1 @@ | |||
| export default 42; | ||||
|  | @ -0,0 +1 @@ | |||
| {} | ||||
|  | @ -0,0 +1 @@ | |||
| <svg></svg> | ||||
| After Width: | Height: | Size: 12 B | 
|  | @ -0,0 +1,5 @@ | |||
| import "./unchanged-module.js"; | ||||
| import "./unchanged-module.json"; | ||||
| new URL("./unchanged-module.svg", import.meta.url); | ||||
| 
 | ||||
| export default "1"; | ||||
|  | @ -0,0 +1,5 @@ | |||
| import "./unchanged-module.js"; | ||||
| import "./unchanged-module.json"; | ||||
| new URL("./unchanged-module.svg", import.meta.url); | ||||
| 
 | ||||
| export default "2"; | ||||
|  | @ -0,0 +1,10 @@ | |||
| /** @type {import("../../../../").Configuration} */ | ||||
| module.exports = { | ||||
| 	mode: "development", | ||||
| 	cache: { | ||||
| 		type: "memory" | ||||
| 	}, | ||||
| 	module: { | ||||
| 		unsafeCache: true | ||||
| 	} | ||||
| }; | ||||
		Loading…
	
		Reference in New Issue