MCPcopy Index your code
hub / github.com/webpack/css-loader / addExportToLocalsCode

Function addExportToLocalsCode

src/utils.js:1202–1235  ·  view source on GitHub ↗
(names, value)

Source from the content-addressed store, hash-verified

1200 let identifierId = 0;
1201
1202 const addExportToLocalsCode = (names, value) => {
1203 const normalizedNames = Array.isArray(names)
1204 ? new Set(names)
1205 : new Set([names]);
1206
1207 for (let name of normalizedNames) {
1208 const serializedValue = isTemplateLiteralSupported
1209 ? convertToTemplateLiteral(value)
1210 : JSON.stringify(value);
1211
1212 if (options.modules.namedExport) {
1213 if (name === "default") {
1214 name = `_${name}`;
1215 }
1216
1217 if (!validIdentifier.test(name) || keywords.has(name)) {
1218 identifierId += 1;
1219
1220 const id = `_${identifierId.toString(16)}`;
1221
1222 localsCode += `var ${id} = ${serializedValue};\n`;
1223 localsCode += `export { ${id} as ${JSON.stringify(name)} };\n`;
1224 } else {
1225 localsCode += `export var ${name} = ${serializedValue};\n`;
1226 }
1227 } else {
1228 if (localsCode) {
1229 localsCode += `,\n`;
1230 }
1231
1232 localsCode += `\t${JSON.stringify(name)}: ${serializedValue}`;
1233 }
1234 }
1235 };
1236
1237 for (const { name, value } of exports) {
1238 addExportToLocalsCode(

Callers 1

getExportCodeFunction · 0.85

Calls 1

convertToTemplateLiteralFunction · 0.85

Tested by

no test coverage detected