mirror of https://github.com/webpack/webpack.git
				
				
				
			Merge pull request #14435 from webpack/bugfix/webpack-extension
This commit is contained in:
		
						commit
						ada210827a
					
				|  | @ -466,6 +466,26 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 							: "") + | ||||
| 						stringifyLoadersAndResource(loaders, resourceData.resource); | ||||
| 
 | ||||
| 					const settings = {}; | ||||
| 					const useLoadersPost = []; | ||||
| 					const useLoaders = []; | ||||
| 					const useLoadersPre = []; | ||||
| 
 | ||||
| 					// handle .webpack[] suffix
 | ||||
| 					let resource; | ||||
| 					let match; | ||||
| 					if ( | ||||
| 						matchResourceData && | ||||
| 						typeof (resource = matchResourceData.resource) === "string" && | ||||
| 						(match = /\.webpack\[([^\]]+)\]$/.exec(resource)) | ||||
| 					) { | ||||
| 						settings.type = match[1]; | ||||
| 						matchResourceData.resource = matchResourceData.resource.slice( | ||||
| 							0, | ||||
| 							-settings.type.length - 10 | ||||
| 						); | ||||
| 					} else { | ||||
| 						settings.type = "javascript/auto"; | ||||
| 						const resourceDataForRules = matchResourceData || resourceData; | ||||
| 						const result = this.ruleSet.exec({ | ||||
| 							resource: resourceDataForRules.path, | ||||
|  | @ -474,7 +494,9 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 							resourceFragment: resourceDataForRules.fragment, | ||||
| 							scheme, | ||||
| 							assertions, | ||||
| 						mimetype: matchResourceData ? "" : resourceData.data.mimetype || "", | ||||
| 							mimetype: matchResourceData | ||||
| 								? "" | ||||
| 								: resourceData.data.mimetype || "", | ||||
| 							dependency: dependencyType, | ||||
| 							descriptionData: matchResourceData | ||||
| 								? undefined | ||||
|  | @ -483,10 +505,6 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 							compiler: contextInfo.compiler, | ||||
| 							issuerLayer: contextInfo.issuerLayer || "" | ||||
| 						}); | ||||
| 					const settings = {}; | ||||
| 					const useLoadersPost = []; | ||||
| 					const useLoaders = []; | ||||
| 					const useLoadersPre = []; | ||||
| 						for (const r of result) { | ||||
| 							if (r.type === "use") { | ||||
| 								if (!noAutoLoaders && !noPrePostAutoLoaders) { | ||||
|  | @ -511,6 +529,7 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 								settings[r.type] = r.value; | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
| 					let postLoaders, normalLoaders, preLoaders; | ||||
| 
 | ||||
|  | @ -528,23 +547,6 @@ class NormalModuleFactory extends ModuleFactory { | |||
| 						} | ||||
| 						for (const loader of preLoaders) allLoaders.push(loader); | ||||
| 						let type = settings.type; | ||||
| 						if (!type) { | ||||
| 							let resource; | ||||
| 							let match; | ||||
| 							if ( | ||||
| 								matchResourceData && | ||||
| 								typeof (resource = matchResourceData.resource) === "string" && | ||||
| 								(match = /\.webpack\[([^\]]+)\]$/.exec(resource)) | ||||
| 							) { | ||||
| 								type = match[1]; | ||||
| 								matchResourceData.resource = matchResourceData.resource.slice( | ||||
| 									0, | ||||
| 									-type.length - 10 | ||||
| 								); | ||||
| 							} else { | ||||
| 								type = "javascript/auto"; | ||||
| 							} | ||||
| 						} | ||||
| 						const resolveOptions = settings.resolve; | ||||
| 						const layer = settings.layer; | ||||
| 						if (layer !== undefined && !layers) { | ||||
|  |  | |||
|  | @ -13,9 +13,15 @@ const config = (i, options) => ({ | |||
| 	}, | ||||
| 	module: { | ||||
| 		rules: [ | ||||
| 			{ | ||||
| 				oneOf: [ | ||||
| 					{ | ||||
| 						test: /\.css$/, | ||||
| 						use: [MCEP.loader, "css-loader"] | ||||
| 					}, | ||||
| 					{ test: /\.js$/ }, | ||||
| 					{ type: "asset" } | ||||
| 				] | ||||
| 			} | ||||
| 		] | ||||
| 	}, | ||||
|  |  | |||
|  | @ -7,10 +7,16 @@ module.exports = { | |||
| 			} | ||||
| 		}, | ||||
| 		rules: [ | ||||
| 			{ | ||||
| 				oneOf: [ | ||||
| 					{ | ||||
| 						test: /\.css\.js$/, | ||||
| 						use: "./loader", | ||||
| 						type: "asset/source" | ||||
| 					}, | ||||
| 					{ test: /\.(js|jpg|png)$/ }, | ||||
| 					{ type: "asset/resource" } | ||||
| 				] | ||||
| 			} | ||||
| 		] | ||||
| 	}, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue