File tree Expand file tree Collapse file tree 8 files changed +29
-225
lines changed
Expand file tree Collapse file tree 8 files changed +29
-225
lines changed Original file line number Diff line number Diff line change 6363 "sharp" : " ^0.27.2" ,
6464 "svgo" : " 2"
6565 },
66- "peerDependencies" : {},
66+ "peerDependencies" : {
67+ "@bsmth/loader-cache" : " ^1.0.1"
68+ },
6769 "husky" : {
6870 "hooks" : {
6971 "pre-commit" : " lint-staged"
Original file line number Diff line number Diff line change 1+ import { deprecate } from 'util' ;
2+ import { CachePlugin as _CachePlugin } from '@bsmth/loader-cache' ;
3+
14export { default } from './loader' ;
2- export { default as CachePlugin } from './plugin' ;
5+
6+ export const CachePlugin = deprecate (
7+ _CachePlugin ,
8+ '[@bsmth/img-loader]: CachePlugin has moved to `@bsmth/loader-cache`, '
9+ + 'please import it from there instead.' ,
10+ ) ;
311
412export const raw = true ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ import { promises as fs } from 'fs';
33import { promisify } from 'util' ;
44import { exec } from 'child_process' ;
55
6+ import {
7+ read as cacheRead ,
8+ getFilename ,
9+ } from '@bsmth/loader-cache' ;
610import type BasisOptions from '../types/BasisOptions' ;
7- import { getFile , getFilename } from './cache' ;
811import { trackJob , completeJob } from './jobTracker' ;
912
1013const asyncExec = promisify ( exec ) ;
@@ -41,7 +44,7 @@ export default async function createBasisFile({
4144 buffer : Buffer ;
4245 path : string ;
4346 } > {
44- const cached = await getFile ( { inputHash, options, resource } ) ;
47+ const cached = await cacheRead ( { inputHash, options, resource } ) ;
4548
4649 if ( cached ) {
4750 return cached ;
Original file line number Diff line number Diff line change @@ -5,8 +5,11 @@ import imageminSvgo from 'imagemin-svgo';
55import imageminGifsicle from 'imagemin-gifsicle' ;
66
77import sharp from 'sharp' ;
8+ import {
9+ read as cacheRead ,
10+ write as cacheWrite ,
11+ } from '@bsmth/loader-cache' ;
812import type { ImgLoaderQualityOptions } from '../types/ImgLoaderOptions' ;
9- import { getFile , writeFile } from './cache' ;
1013import { completeJob , trackJob } from './jobTracker' ;
1114
1215
@@ -41,7 +44,7 @@ export default async function createImageFile({
4144 } > {
4245 const relevantOptions = options [ compressorForType [ type ] ] ;
4346
44- const cached = await getFile ( {
47+ const cached = await cacheRead ( {
4548 options : relevantOptions ,
4649 inputHash,
4750 resource,
Original file line number Diff line number Diff line change 11import sharp from 'sharp' ;
22
3+ import {
4+ read as cacheRead ,
5+ write as cacheWrite ,
6+ } from '@bsmth/loader-cache' ;
37import type { ImgLoaderInternalOptions } from '../types/ImgLoaderOptions' ;
4- import { getFile , writeFile } from './cache' ;
58import { completeJob , trackJob } from './jobTracker' ;
69
710
@@ -34,7 +37,7 @@ export default async function resize({
3437 resource,
3538 } ;
3639
37- const cached = await getFile ( cacheOpts ) ;
40+ const cached = await cacheRead ( cacheOpts ) ;
3841
3942 if ( cached ) return cached ;
4043
@@ -53,7 +56,7 @@ export default async function resize({
5356 } ) ;
5457
5558 const buffer = await texture . png ( ) . toBuffer ( ) ;
56- const path = await writeFile ( {
59+ const path = await cacheWrite ( {
5760 buffer,
5861 ...cacheOpts ,
5962 } ) ;
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import path from 'path';
44import { promises as fs } from 'fs' ;
55import objHash from 'object-hash' ;
66
7+ import { ensureCacheReady } from '@bsmth/loader-cache' ;
78import defaultOptions from './defaultOptions' ;
8- import { ensureCacheReady } from './lib/cache' ;
99import generateDeclarations from './lib/generateDeclarations' ;
1010import deriveExportOptions from './lib/deriveExportOptions' ;
1111import deriveOutputFilename from './lib/deriveOutputFilename' ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments