New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-sass-plugin

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-sass-plugin - npm Package Compare versions

Comparing version 2.14.0 to 2.15.0

4

lib/cache.d.ts

@@ -0,6 +1,8 @@

/// <reference types="node" />
import { SassPluginOptions } from './index';
import { OnLoadArgs, OnLoadResult } from 'esbuild';
import { Stats } from 'fs';
type OnLoadCallback = (args: OnLoadArgs) => (OnLoadResult | Promise<OnLoadResult>);
type PluginLoadCallback = (path: string) => (OnLoadResult | Promise<OnLoadResult>);
export declare function useCache(options: SassPluginOptions | undefined, loadCallback: PluginLoadCallback): OnLoadCallback;
export declare function useCache(options: SassPluginOptions | undefined, fsStatCache: Map<string, Stats>, loadCallback: PluginLoadCallback): OnLoadCallback;
export {};

@@ -5,4 +5,10 @@ "use strict";

const fs_1 = require("fs");
function collectStats(watchFiles) {
return Promise.all(watchFiles.map(filename => fs_1.promises.stat(filename)));
function collectStats(watchFiles, fsStatCache) {
return Promise.all(watchFiles.map(async (filename) => {
if (!fsStatCache.has(filename)) {
const stats = await fs_1.promises.stat(filename);
fsStatCache.set(filename, stats);
}
return fsStatCache.get(filename);
}));
}

@@ -23,3 +29,3 @@ function maxMtimeMs(stats) {

}
function useCache(options = {}, loadCallback) {
function useCache(options = {}, fsStatCache, loadCallback) {
const cache = getCache(options);

@@ -32,3 +38,3 @@ if (cache) {

let watchFiles = cached.result.watchFiles;
let stats = await collectStats(watchFiles);
let stats = await collectStats(watchFiles, fsStatCache);
for (const { mtimeMs } of stats) {

@@ -45,3 +51,3 @@ if (mtimeMs > cached.mtimeMs) {

cached = {
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles)),
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles, fsStatCache)),
result

@@ -48,0 +54,0 @@ };

@@ -24,3 +24,3 @@ "use strict";

name: 'sass-plugin',
setup({ initialOptions, onResolve, onLoad, resolve }) {
setup({ initialOptions, onResolve, onLoad, resolve, onStart }) {
var _a, _b;

@@ -37,2 +37,4 @@ options.loadPaths = Array.from(new Set([

}
const fsStatCache = new Map();
onStart(() => fsStatCache.clear());
const transform = options.transform ? options.transform.bind(options) : null;

@@ -54,3 +56,3 @@ const cssChunks = {};

const renderSync = (0, render_1.createRenderer)(options, (_a = options.sourceMap) !== null && _a !== void 0 ? _a : sourcemap);
onLoad({ filter: (_b = options.filter) !== null && _b !== void 0 ? _b : DEFAULT_FILTER }, (0, cache_1.useCache)(options, async (path) => {
onLoad({ filter: (_b = options.filter) !== null && _b !== void 0 ? _b : DEFAULT_FILTER }, (0, cache_1.useCache)(options, fsStatCache, async (path) => {
var _a;

@@ -57,0 +59,0 @@ try {

{
"name": "esbuild-sass-plugin",
"version": "2.14.0",
"version": "2.15.0",
"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",

@@ -164,3 +164,3 @@ ![cooltext394785080075403](https://user-images.githubusercontent.com/160981/136289874-26ce7269-ea08-47dd-be31-9bf0ef7a0b8d.png)

### `cssImports`
when this is set to `true` the plugin rewrites the node-modules relative URLs startig with the `~` prefix so that
when this is set to `true` the plugin rewrites the node-modules relative URLs starting with the `~` prefix so that
esbuild can resolve them similarly to what `css-loader` does.

@@ -167,0 +167,0 @@ > Although this practice is [kind of deprecated nowadays](https://webpack.js.org/loaders/sass-loader/#resolving-import-at-rules)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc