esbuild-sass-plugin
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -0,0 +0,0 @@ import { SassPluginOptions } from "./index"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { OnLoadResult } from "esbuild"; |
@@ -0,0 +0,0 @@ "use strict"; |
import { Plugin } from "esbuild"; | ||
import { SassPluginOptions } from "./index"; | ||
export declare function sassPlugin(options?: SassPluginOptions): Plugin; |
@@ -0,0 +0,0 @@ "use strict"; |
import { SassPluginOptions, Type } from "./index"; | ||
import PostcssModulesPlugin from "postcss-modules"; | ||
import { OnLoadResult } from "esbuild"; | ||
export declare function loadSass({ implementation: module, basedir }: SassPluginOptions): any; | ||
export declare function loadSass({ implementation: module, includePaths }: SassPluginOptions): any; | ||
export declare function makeModule(contents: string, type: Type): string; | ||
export declare function postcssModules(options: Parameters<PostcssModulesPlugin>[0] & { | ||
basedir?: string; | ||
includePaths?: string[] | undefined; | ||
}): (source: string, dirname: string, path: string) => Promise<OnLoadResult>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.postcssModules = exports.makeModule = exports.loadSass = void 0; | ||
function requireModule(module, basedir = process.cwd()) { | ||
function requireModule(module, includePaths) { | ||
try { | ||
return require(require.resolve(module, { paths: [basedir] })); | ||
return require(require.resolve(module, includePaths ? { paths: includePaths } : { paths: [process.cwd()] })); | ||
} | ||
@@ -13,4 +13,4 @@ catch (e) { | ||
} | ||
function loadSass({ implementation: module = "sass", basedir = process.cwd() }) { | ||
return requireModule(module, basedir); | ||
function loadSass({ implementation: module = "sass", includePaths }) { | ||
return requireModule(module, includePaths); | ||
} | ||
@@ -44,4 +44,6 @@ exports.loadSass = loadSass; | ||
function postcssModules(options) { | ||
const postcss = requireModule("postcss", options.basedir); | ||
const postcssModulesPlugin = requireModule("postcss-modules", options.basedir); | ||
var _a, _b; | ||
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); | ||
return async (source, dirname, path) => { | ||
@@ -48,0 +50,0 @@ let cssModule; |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "esbuild plugin for sass/scss files supporting both css loader and css result import (lit-element)", | ||
@@ -30,3 +30,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"setup": "cd test/fixture && yarn install && cd ../..", | ||
"setup": "cd test/fixture && yarn install && cd ../issues && yarn install && cd ../..", | ||
"build": "tsc", | ||
@@ -33,0 +33,0 @@ "build:watch": "tsc --watch", |
@@ -0,0 +0,0 @@ ![logo created with https://cooltext.com](https://images.cooltext.com/5500652.png) |
@@ -0,0 +0,0 @@ import {SassPluginOptions} from "./index"; |
@@ -6,5 +6,5 @@ import {SassPluginOptions, Type} from "./index"; | ||
function requireModule(module:string, basedir:string = process.cwd()) { | ||
function requireModule(module: string, includePaths: string[] | undefined) { | ||
try { | ||
return require(require.resolve(module, {paths: [basedir]})); | ||
return require(require.resolve(module, includePaths ? {paths: includePaths} : {paths: [process.cwd()]})); | ||
} catch (e) { | ||
@@ -16,4 +16,4 @@ console.error(`Cannot find module '${module}', make sure it's installed. e.g. yarn add -D ${module}`, e); | ||
export function loadSass({implementation: module = "sass", basedir = process.cwd()}: SassPluginOptions) { | ||
return requireModule(module, basedir); | ||
export function loadSass({implementation: module = "sass", includePaths}: SassPluginOptions) { | ||
return requireModule(module, includePaths); | ||
} | ||
@@ -48,6 +48,7 @@ | ||
export function postcssModules(options: Parameters<PostcssModulesPlugin>[0] & { basedir?: string }) { | ||
export function postcssModules(options: Parameters<PostcssModulesPlugin>[0] & { basedir?: string, includePaths?: string[] | undefined }) { | ||
const postcss: Postcss = requireModule("postcss", options.basedir); | ||
const postcssModulesPlugin: PostcssModulesPlugin = requireModule("postcss-modules", options.basedir); | ||
const includePaths = options.includePaths ?? [options.basedir ?? process.cwd()]; | ||
const postcss: Postcss = requireModule("postcss", includePaths); | ||
const postcssModulesPlugin: PostcssModulesPlugin = requireModule("postcss-modules", includePaths); | ||
@@ -54,0 +55,0 @@ return async (source: string, dirname: string, path: string): Promise<OnLoadResult> => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
49372
736