( maxWorkers: number | undefined, )
| 2923 | } |
| 2924 | |
| 2925 | const lessProcessor = ( |
| 2926 | maxWorkers: number | undefined, |
| 2927 | ): StylePreprocessor<LessStylePreprocessorInternalOptions> => { |
| 2928 | let worker: ReturnType<typeof makeLessWorker> | undefined |
| 2929 | |
| 2930 | return { |
| 2931 | close() { |
| 2932 | worker?.stop() |
| 2933 | }, |
| 2934 | async process(environment, source, root, options, resolvers) { |
| 2935 | const lessPath = loadPreprocessorPath(PreprocessLang.less, root) |
| 2936 | worker ??= makeLessWorker(environment, resolvers, maxWorkers) |
| 2937 | |
| 2938 | const { content, map: additionalMap } = await getSource( |
| 2939 | source, |
| 2940 | options.filename, |
| 2941 | options.additionalData, |
| 2942 | options.enableSourcemap, |
| 2943 | ) |
| 2944 | |
| 2945 | let result: Less.RenderOutput | undefined |
| 2946 | const optionsWithoutAdditionalData = { |
| 2947 | ...options, |
| 2948 | additionalData: undefined, |
| 2949 | } |
| 2950 | try { |
| 2951 | result = await worker.run( |
| 2952 | pathToFileURL(lessPath).href, |
| 2953 | content, |
| 2954 | optionsWithoutAdditionalData, |
| 2955 | ) |
| 2956 | } catch (e) { |
| 2957 | const error = e as Less.RenderError |
| 2958 | // normalize error info |
| 2959 | const normalizedError: RollupError = new Error( |
| 2960 | `[less] ${error.message || error.type}`, |
| 2961 | ) as RollupError |
| 2962 | normalizedError.loc = { |
| 2963 | file: error.filename || options.filename, |
| 2964 | line: error.line, |
| 2965 | column: error.column, |
| 2966 | } |
| 2967 | return { code: '', error: normalizedError, deps: [] } |
| 2968 | } |
| 2969 | |
| 2970 | const map: ExistingRawSourceMap | undefined = |
| 2971 | result.map && JSON.parse(result.map) |
| 2972 | if (map) { |
| 2973 | delete map.sourcesContent |
| 2974 | } |
| 2975 | |
| 2976 | return { |
| 2977 | code: result.css.toString(), |
| 2978 | map, |
| 2979 | additionalMap, |
| 2980 | deps: result.imports, |
| 2981 | } |
| 2982 | }, |
no outgoing calls
no test coverage detected