(map, resourcePath)
| 830 | } |
| 831 | |
| 832 | function normalizeSourceMap(map, resourcePath) { |
| 833 | let newMap = map; |
| 834 | |
| 835 | // Some loader emit source map as string |
| 836 | // Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON. |
| 837 | if (typeof newMap === "string") { |
| 838 | newMap = JSON.parse(newMap); |
| 839 | } |
| 840 | |
| 841 | delete newMap.file; |
| 842 | |
| 843 | const { sourceRoot } = newMap; |
| 844 | |
| 845 | delete newMap.sourceRoot; |
| 846 | |
| 847 | if (newMap.sources) { |
| 848 | // Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91) |
| 849 | // We should normalize path because previous loaders like `sass-loader` using backslash when generate source map |
| 850 | newMap.sources = newMap.sources.map((source) => { |
| 851 | // Non-standard syntax from `postcss` |
| 852 | if (source.indexOf("<") === 0) { |
| 853 | return source; |
| 854 | } |
| 855 | |
| 856 | const sourceType = getURLType(source); |
| 857 | |
| 858 | // Do no touch `scheme-relative` and `absolute` URLs |
| 859 | if (sourceType === "path-relative" || sourceType === "path-absolute") { |
| 860 | const absoluteSource = |
| 861 | sourceType === "path-relative" && sourceRoot |
| 862 | ? path.resolve(sourceRoot, normalizePath(source)) |
| 863 | : normalizePath(source); |
| 864 | |
| 865 | return path.relative(path.dirname(resourcePath), absoluteSource); |
| 866 | } |
| 867 | |
| 868 | return source; |
| 869 | }); |
| 870 | } |
| 871 | |
| 872 | return newMap; |
| 873 | } |
| 874 | |
| 875 | function getPreRequester({ loaders, loaderIndex }) { |
| 876 | const cache = Object.create(null); |
no test coverage detected