( maxWorkers: number | undefined, )
| 2619 | } |
| 2620 | |
| 2621 | const scssProcessor = ( |
| 2622 | maxWorkers: number | undefined, |
| 2623 | ): StylePreprocessor<SassStylePreprocessorInternalOptions> => { |
| 2624 | let worker: ReturnType<typeof makeScssWorker> | undefined |
| 2625 | let failedSassEmbedded: boolean | undefined |
| 2626 | const normalizedErrors = new WeakSet<Error>() |
| 2627 | |
| 2628 | return { |
| 2629 | async close() { |
| 2630 | await worker?.stop() |
| 2631 | }, |
| 2632 | async process(environment, source, root, options, resolvers) { |
| 2633 | let sassPackage = loadSassPackage(root, failedSassEmbedded ?? false) |
| 2634 | if (failedSassEmbedded === undefined) { |
| 2635 | failedSassEmbedded = false |
| 2636 | try { |
| 2637 | await import(sassPackage.path) |
| 2638 | } catch (e) { |
| 2639 | if (/sass-embedded-[a-z0-9]+-[a-z0-9]+/i.test(e.message)) { |
| 2640 | failedSassEmbedded = true |
| 2641 | sassPackage = loadSassPackage(root, failedSassEmbedded) |
| 2642 | } |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | worker ??= makeScssWorker(environment, resolvers, maxWorkers) |
| 2647 | |
| 2648 | const { content: data, map: additionalMap } = await getSource( |
| 2649 | source, |
| 2650 | options.filename, |
| 2651 | options.additionalData, |
| 2652 | options.enableSourcemap, |
| 2653 | ) |
| 2654 | |
| 2655 | const optionsWithoutAdditionalData = { |
| 2656 | ...options, |
| 2657 | additionalData: undefined, |
| 2658 | } |
| 2659 | try { |
| 2660 | const result = await worker.run( |
| 2661 | pathToFileURL(sassPackage.path).href, |
| 2662 | data, |
| 2663 | optionsWithoutAdditionalData, |
| 2664 | ) |
| 2665 | const deps = result.stats.includedFiles.map((f) => cleanScssBugUrl(f)) |
| 2666 | const map: ExistingRawSourceMap | undefined = result.map |
| 2667 | ? JSON.parse(result.map.toString()) |
| 2668 | : undefined |
| 2669 | |
| 2670 | if (map) { |
| 2671 | // Note: the real `Sourcemap#sources` maybe `null`, but rollup typing is not handle it. |
| 2672 | map.sources = map.sources!.map((url) => |
| 2673 | url!.startsWith('file://') |
| 2674 | ? normalizePath(fileURLToPath(url!)) |
| 2675 | : url, |
| 2676 | ) |
| 2677 | } |
| 2678 |
no outgoing calls
no test coverage detected