( result, api, replacements, options, isTemplateLiteralSupported, loaderContext, )
| 996 | } |
| 997 | |
| 998 | function getModuleCode( |
| 999 | result, |
| 1000 | api, |
| 1001 | replacements, |
| 1002 | options, |
| 1003 | isTemplateLiteralSupported, |
| 1004 | loaderContext, |
| 1005 | ) { |
| 1006 | if (options.modules.exportOnlyLocals === true) { |
| 1007 | return ""; |
| 1008 | } |
| 1009 | |
| 1010 | let sourceMapValue = ""; |
| 1011 | |
| 1012 | if (options.sourceMap) { |
| 1013 | const sourceMap = result.map; |
| 1014 | |
| 1015 | sourceMapValue = `,${normalizeSourceMapForRuntime( |
| 1016 | sourceMap, |
| 1017 | loaderContext, |
| 1018 | )}`; |
| 1019 | } |
| 1020 | |
| 1021 | let code = isTemplateLiteralSupported |
| 1022 | ? convertToTemplateLiteral(result.css) |
| 1023 | : JSON.stringify(result.css); |
| 1024 | |
| 1025 | let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${ |
| 1026 | options.sourceMap |
| 1027 | ? "___CSS_LOADER_API_SOURCEMAP_IMPORT___" |
| 1028 | : "___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___" |
| 1029 | });\n`; |
| 1030 | |
| 1031 | for (const item of api) { |
| 1032 | const { url, layer, supports, media, dedupe } = item; |
| 1033 | |
| 1034 | if (url) { |
| 1035 | // eslint-disable-next-line no-undefined |
| 1036 | const printedParam = printParams(media, undefined, supports, layer); |
| 1037 | |
| 1038 | beforeCode += `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify( |
| 1039 | `@import url(${url});`, |
| 1040 | )}${printedParam.length > 0 ? `, ${printedParam}` : ""}]);\n`; |
| 1041 | } else { |
| 1042 | const printedParam = printParams(media, dedupe, supports, layer); |
| 1043 | |
| 1044 | beforeCode += `___CSS_LOADER_EXPORT___.i(${item.importName}${ |
| 1045 | printedParam.length > 0 ? `, ${printedParam}` : "" |
| 1046 | });\n`; |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | for (const item of replacements) { |
| 1051 | const { replacementName, importName, localName } = item; |
| 1052 | |
| 1053 | if (localName) { |
| 1054 | code = code.replace(new RegExp(replacementName, "g"), () => |
| 1055 | options.modules.namedExport |
no test coverage detected