* @param {"dart-sass" | "sass" | "sass-embedded" | "sass_string" | "sass_file_url"} implementationName implementation name * @returns {Promise } a sass implementation
(implementationName)
| 54 | * @returns {Promise<SassImplementation>} a sass implementation |
| 55 | */ |
| 56 | async function getImplementationByName(implementationName) { |
| 57 | if (implementationName === "dart-sass") { |
| 58 | return import("sass"); |
| 59 | } else if (implementationName === "sass-embedded") { |
| 60 | // Match the loader's `await import("sass-embedded")` so tests and loader |
| 61 | // hold the same module instance (CJS and ESM builds are cached |
| 62 | // separately). |
| 63 | return import("sass-embedded"); |
| 64 | } else if (implementationName === "sass_string") { |
| 65 | // Absolute filesystem path; on Windows this is a backslash-separated |
| 66 | // path like `C:\\...` which dynamic `import()` does not accept until |
| 67 | // it's normalized to a `file:` URL. The ESM entry is used so the |
| 68 | // loader's `await import(path)` exposes named exports (`info`, |
| 69 | // `compileStringAsync`, …) directly instead of via `.default`. |
| 70 | return resolveEsmPath("sass"); |
| 71 | } else if (implementationName === "sass_file_url") { |
| 72 | return pathToFileURL(resolveEsmPath("sass")).href; |
| 73 | } |
| 74 | |
| 75 | throw new Error(`Can't find ${implementationName}`); |
| 76 | } |
| 77 | |
| 78 | export default getImplementationByName; |
searching dependent graphs…