MCPcopy
hub / github.com/webpack/webpack / getSourceForCommonJsExternal

Function getSourceForCommonJsExternal

lib/ExternalModule.js:185–198  ·  view source on GitHub ↗
(moduleAndSpecifiers)

Source from the content-addressed store, hash-verified

183 * @returns {SourceData} the generated source
184 */
185const getSourceForCommonJsExternal = (moduleAndSpecifiers) => {
186 if (!Array.isArray(moduleAndSpecifiers)) {
187 return {
188 expression: `require(${JSON.stringify(moduleAndSpecifiers)})`
189 };
190 }
191 const moduleName = moduleAndSpecifiers[0];
192 return {
193 expression: `require(${JSON.stringify(moduleName)})${propertyAccess(
194 moduleAndSpecifiers,
195 1
196 )}`
197 };
198};
199
200/**
201 * Gets external module node commonjs init fragment.

Callers 1

_getSourceDataMethod · 0.85

Calls 2

propertyAccessFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected