esbuild-sass-plugin
Advanced tools
Comparing version 1.4.8 to 1.4.9
@@ -140,23 +140,29 @@ "use strict"; | ||
} | ||
let cached = group.get(args.path); | ||
if (cached) { | ||
let watchFiles = cached.result.watchFiles; | ||
let stats = await collectStats(watchFiles); | ||
for (const { mtimeMs } of stats) { | ||
if (mtimeMs > cached.mtimeMs) { | ||
cached.result = await transform(watchFiles[0], cached.type); | ||
cached.mtimeMs = maxMtimeMs(stats); | ||
break; | ||
try { | ||
let cached = group.get(args.path); | ||
if (cached) { | ||
let watchFiles = cached.result.watchFiles; | ||
let stats = await collectStats(watchFiles); | ||
for (const { mtimeMs } of stats) { | ||
if (mtimeMs > cached.mtimeMs) { | ||
cached.result = await transform(watchFiles[0], cached.type); | ||
cached.mtimeMs = maxMtimeMs(stats); | ||
break; | ||
} | ||
} | ||
return cached.result; | ||
} | ||
return cached.result; | ||
let type = typeOf(args); | ||
let result = await transform(path, type); | ||
group.set(args.path, { | ||
type, | ||
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles)), | ||
result | ||
}); | ||
return result; | ||
} | ||
let type = typeOf(args); | ||
let result = await transform(path, type); | ||
group.set(args.path, { | ||
type, | ||
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles)), | ||
result | ||
}); | ||
return result; | ||
catch (error) { | ||
group.delete(args.path); | ||
throw error; | ||
} | ||
}; | ||
@@ -169,18 +175,32 @@ } | ||
} | ||
const watchFilesCache = "watch" in build ? {} : null; | ||
async function transform(path, type) { | ||
let { css, watchFiles } = path.endsWith(".css") ? readCssFileSync(path) : renderSync(path); | ||
if (options.transform) { | ||
css = await options.transform(css, path_1.dirname(path)); | ||
var _a; | ||
try { | ||
let { css, watchFiles } = path.endsWith(".css") ? readCssFileSync(path) : renderSync(path); | ||
if (options.transform) { | ||
css = await options.transform(css, path_1.dirname(path)); | ||
} | ||
watchFiles = [...watchFiles]; | ||
if (watchFilesCache) { | ||
watchFilesCache[path] = watchFiles; | ||
} | ||
return type === "css" ? { | ||
contents: css, | ||
loader: "css", | ||
resolveDir: path_1.dirname(path), | ||
watchFiles | ||
} : { | ||
contents: makeModule(css, type), | ||
loader: "js", | ||
resolveDir: path_1.dirname(path), | ||
watchFiles | ||
}; | ||
} | ||
return type === "css" ? { | ||
contents: css, | ||
loader: "css", | ||
resolveDir: path_1.dirname(path), | ||
watchFiles | ||
} : { | ||
contents: makeModule(css, type), | ||
loader: "js", | ||
resolveDir: path_1.dirname(path), | ||
watchFiles | ||
}; | ||
catch (err) { | ||
return { | ||
errors: [{ text: err.message }], | ||
watchFiles: (_a = watchFilesCache === null || watchFilesCache === void 0 ? void 0 : watchFilesCache[path]) !== null && _a !== void 0 ? _a : [path] | ||
}; | ||
} | ||
} | ||
@@ -187,0 +207,0 @@ build.onLoad({ filter: /./, namespace: "sass" }, cached(transform)); |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "1.4.8", | ||
"version": "1.4.9", | ||
"description": "esbuild plugin for sass/scss files supporting both css loader and css result import (lit-element)", | ||
@@ -55,21 +55,21 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"esbuild": "^0.12.9", | ||
"esbuild": "^0.12.18", | ||
"picomatch": "^2.3.0", | ||
"resolve": "^1.20.0", | ||
"sass": "^1.35.1" | ||
"sass": "^1.37.5" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.19", | ||
"@types/chai": "^4.2.21", | ||
"@types/chai-string": "^1.4.2", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^15.12.4", | ||
"@types/resolve": "^1.20.0", | ||
"@types/sass": "^1.16.0", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.4.13", | ||
"@types/resolve": "^1.20.1", | ||
"@types/sass": "^1.16.1", | ||
"chai": "^4.3.4", | ||
"chai-string": "^1.5.0", | ||
"mocha": "^9.0.1", | ||
"mocha": "^9.0.3", | ||
"nyc": "^15.1.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.4" | ||
"ts-node": "^10.1.0", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
@@ -164,23 +164,28 @@ import {Loader, OnLoadArgs, OnLoadResult, OnResolveArgs, Plugin} from "esbuild"; | ||
} | ||
let cached = group.get(args.path); | ||
if (cached) { | ||
let watchFiles = cached.result.watchFiles!; | ||
let stats = await collectStats(watchFiles); | ||
for (const {mtimeMs} of stats) { | ||
if (mtimeMs > cached.mtimeMs) { | ||
cached.result = await transform(watchFiles[0], cached.type); | ||
cached.mtimeMs = maxMtimeMs(stats); | ||
break; | ||
try { | ||
let cached = group.get(args.path); | ||
if (cached) { | ||
let watchFiles = cached.result.watchFiles!; | ||
let stats = await collectStats(watchFiles); | ||
for (const {mtimeMs} of stats) { | ||
if (mtimeMs > cached.mtimeMs) { | ||
cached.result = await transform(watchFiles[0], cached.type); | ||
cached.mtimeMs = maxMtimeMs(stats); | ||
break; | ||
} | ||
} | ||
return cached.result; | ||
} | ||
return cached.result; | ||
let type = typeOf(args); | ||
let result = await transform(path, type); | ||
group.set(args.path, { | ||
type, | ||
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles)), | ||
result | ||
}); | ||
return result; | ||
} catch (error) { | ||
group.delete(args.path); | ||
throw error; | ||
} | ||
let type = typeOf(args); | ||
let result = await transform(path, type); | ||
group.set(args.path, { | ||
type, | ||
mtimeMs: maxMtimeMs(await collectStats(result.watchFiles)), | ||
result | ||
}); | ||
return result; | ||
}; | ||
@@ -193,18 +198,31 @@ } else { | ||
const watchFilesCache = "watch" in build ? {} : null; | ||
async function transform(path: string, type: string): Promise<OnLoadResult> { | ||
let {css, watchFiles} = path.endsWith(".css") ? readCssFileSync(path) : renderSync(path); | ||
if (options.transform) { | ||
css = await options.transform(css, dirname(path)); | ||
try { | ||
let {css, watchFiles} = path.endsWith(".css") ? readCssFileSync(path) : renderSync(path); | ||
if (options.transform) { | ||
css = await options.transform(css, dirname(path)); | ||
} | ||
watchFiles = [...watchFiles]; | ||
if (watchFilesCache) { | ||
watchFilesCache[path] = watchFiles; | ||
} | ||
return type === "css" ? { | ||
contents: css, | ||
loader: "css" as Loader, | ||
resolveDir: dirname(path), | ||
watchFiles | ||
} : { | ||
contents: makeModule(css, type), | ||
loader: "js" as Loader, | ||
resolveDir: dirname(path), | ||
watchFiles | ||
}; | ||
} catch (err) { | ||
return { | ||
errors: [{text: err.message}], | ||
watchFiles: watchFilesCache?.[path] ?? [path] | ||
} | ||
} | ||
return type === "css" ? { | ||
contents: css, | ||
loader: "css" as Loader, | ||
resolveDir: dirname(path), | ||
watchFiles | ||
} : { | ||
contents: makeModule(css, type), | ||
loader: "js" as Loader, | ||
resolveDir: dirname(path), | ||
watchFiles | ||
}; | ||
} | ||
@@ -211,0 +229,0 @@ |
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
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
43017
640
Updatedesbuild@^0.12.18
Updatedsass@^1.37.5