MCPcopy
hub / github.com/webpack/webpack / getSourceForCommonJsExternalInNodeModule

Function getSourceForCommonJsExternalInNodeModule

lib/ExternalModule.js:243–266  ·  view source on GitHub ↗
(
	moduleAndSpecifiers,
	runtimeTemplate,
	universal = false
)

Source from the content-addressed store, hash-verified

241 * @returns {SourceData} the generated source
242 */
243const getSourceForCommonJsExternalInNodeModule = (
244 moduleAndSpecifiers,
245 runtimeTemplate,
246 universal = false
247) => {
248 const chunkInitFragments = [
249 getExternalModuleNodeCommonjsInitFragment(runtimeTemplate, universal)
250 ];
251 if (!Array.isArray(moduleAndSpecifiers)) {
252 return {
253 chunkInitFragments,
254 expression: `__WEBPACK_EXTERNAL_createRequire_require(${JSON.stringify(
255 moduleAndSpecifiers
256 )})`
257 };
258 }
259 const moduleName = moduleAndSpecifiers[0];
260 return {
261 chunkInitFragments,
262 expression: `__WEBPACK_EXTERNAL_createRequire_require(${JSON.stringify(
263 moduleName
264 )})${propertyAccess(moduleAndSpecifiers, 1)}`
265 };
266};
267
268/**
269 * Gets source for import external.

Callers 1

_getSourceDataMethod · 0.85

Calls 3

propertyAccessFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected