esbuild-sass-plugin
Advanced tools
Comparing version 1.5.1 to 1.5.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.postcssModules = exports.makeModule = exports.loadSass = void 0; | ||
function requireModule(module, includePaths) { | ||
function requireTool(module, includePaths) { | ||
try { | ||
@@ -9,2 +9,7 @@ return require(require.resolve(module, includePaths ? { paths: includePaths } : { paths: [process.cwd()] })); | ||
catch (e) { | ||
try { | ||
return require(module); | ||
} | ||
catch (ignored) { | ||
} | ||
console.error(`Cannot find module '${module}', make sure it's installed. e.g. yarn add -D ${module}`, e); | ||
@@ -15,3 +20,3 @@ process.exit(1); | ||
function loadSass({ implementation: module = "sass", includePaths }) { | ||
return requireModule(module, includePaths); | ||
return requireTool(module, includePaths); | ||
} | ||
@@ -47,4 +52,4 @@ exports.loadSass = loadSass; | ||
const includePaths = (_a = options.includePaths) !== null && _a !== void 0 ? _a : [(_b = options.basedir) !== null && _b !== void 0 ? _b : process.cwd()]; | ||
const postcss = requireModule("postcss", includePaths); | ||
const postcssModulesPlugin = requireModule("postcss-modules", includePaths); | ||
const postcss = requireTool("postcss", includePaths); | ||
const postcssModulesPlugin = requireTool("postcss-modules", includePaths); | ||
return async (source, dirname, path) => { | ||
@@ -51,0 +56,0 @@ let cssModule; |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "esbuild plugin for sass/scss files supporting both css loader and css result import (lit-element)", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -6,6 +6,10 @@ import {SassPluginOptions, Type} from "./index"; | ||
function requireModule(module: string, includePaths: string[] | undefined) { | ||
function requireTool(module: string, includePaths: string[] | undefined) { | ||
try { | ||
return require(require.resolve(module, includePaths ? {paths: includePaths} : {paths: [process.cwd()]})); | ||
} catch (e) { | ||
try { | ||
return require(module); // extra attempt at finding a co-located tools | ||
} catch (ignored) { | ||
} | ||
console.error(`Cannot find module '${module}', make sure it's installed. e.g. yarn add -D ${module}`, e); | ||
@@ -17,3 +21,3 @@ process.exit(1); | ||
export function loadSass({implementation: module = "sass", includePaths}: SassPluginOptions) { | ||
return requireModule(module, includePaths); | ||
return requireTool(module, includePaths); | ||
} | ||
@@ -51,4 +55,4 @@ | ||
const includePaths = options.includePaths ?? [options.basedir ?? process.cwd()]; | ||
const postcss: Postcss = requireModule("postcss", includePaths); | ||
const postcssModulesPlugin: PostcssModulesPlugin = requireModule("postcss-modules", includePaths); | ||
const postcss: Postcss = requireTool("postcss", includePaths); | ||
const postcssModulesPlugin: PostcssModulesPlugin = requireTool("postcss-modules", includePaths); | ||
@@ -55,0 +59,0 @@ return async (source: string, dirname: string, path: string): Promise<OnLoadResult> => { |
Sorry, the diff of this file is not supported yet
49673
745
5