MCPcopy Create free account
hub / github.com/rollup/plugins / wrapCode

Function wrapCode

packages/commonjs/src/generate-exports.js:1–19  ·  view source on GitHub ↗
(magicString, uses, moduleName, exportsName, indentExclusionRanges)

Source from the content-addressed store, hash-verified

1export function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
2 const args = [];
3 const passedArgs = [];
4 if (uses.module) {
5 args.push('module');
6 passedArgs.push(moduleName);
7 }
8 if (uses.exports) {
9 args.push('exports');
10 passedArgs.push(uses.module ? `${moduleName}.exports` : exportsName);
11 }
12 magicString
13 .trim()
14 .indent('\t', { exclude: indentExclusionRanges })
15 .prepend(`(function (${args.join(', ')}) {\n`)
16 // For some reason, this line is only indented correctly when using a
17 // require-wrapper if we have this leading space
18 .append(` \n} (${passedArgs.join(', ')}));`);
19}
20
21export function rewriteExportsAndGetExportsBlock(
22 magicString,

Callers 1

transformCommonjsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected