Skip to content

Commit 1174c90

Browse files
committed
build: packages
1 parent c15e1e6 commit 1174c90

17 files changed

+372
-189
lines changed

packages/postcss-purgecss/lib/postcss-purgecss.d.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ interface UserDefinedOptions {
2727
whitelistPatterns?: Array<RegExp>;
2828
whitelistPatternsChildren?: Array<RegExp>;
2929
}
30-
declare const purgeCSSPlugin: postcss.Plugin<Pick<
31-
UserDefinedOptions,
32-
| "content"
33-
| "defaultExtractor"
34-
| "extractors"
35-
| "fontFace"
36-
| "keyframes"
37-
| "output"
38-
| "rejected"
39-
| "stdin"
40-
| "stdout"
41-
| "variables"
42-
| "whitelist"
43-
| "whitelistPatterns"
44-
| "whitelistPatternsChildren"
30+
declare const purgeCSSPlugin: postcss.Plugin<postcss.PluginInitializer<
31+
Pick<
32+
UserDefinedOptions,
33+
| "content"
34+
| "defaultExtractor"
35+
| "extractors"
36+
| "fontFace"
37+
| "keyframes"
38+
| "output"
39+
| "rejected"
40+
| "stdin"
41+
| "stdout"
42+
| "variables"
43+
| "whitelist"
44+
| "whitelistPatterns"
45+
| "whitelistPatternsChildren"
46+
>
4547
>>;
46-
export { purgeCSSPlugin };
48+
export { purgeCSSPlugin as default };

packages/postcss-purgecss/lib/postcss-purgecss.esm.d.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ interface UserDefinedOptions {
2727
whitelistPatterns?: Array<RegExp>;
2828
whitelistPatternsChildren?: Array<RegExp>;
2929
}
30-
declare const purgeCSSPlugin: postcss.Plugin<Pick<
31-
UserDefinedOptions,
32-
| "content"
33-
| "defaultExtractor"
34-
| "extractors"
35-
| "fontFace"
36-
| "keyframes"
37-
| "output"
38-
| "rejected"
39-
| "stdin"
40-
| "stdout"
41-
| "variables"
42-
| "whitelist"
43-
| "whitelistPatterns"
44-
| "whitelistPatternsChildren"
30+
declare const purgeCSSPlugin: postcss.Plugin<postcss.PluginInitializer<
31+
Pick<
32+
UserDefinedOptions,
33+
| "content"
34+
| "defaultExtractor"
35+
| "extractors"
36+
| "fontFace"
37+
| "keyframes"
38+
| "output"
39+
| "rejected"
40+
| "stdin"
41+
| "stdout"
42+
| "variables"
43+
| "whitelist"
44+
| "whitelistPatterns"
45+
| "whitelistPatternsChildren"
46+
>
4547
>>;
46-
export { purgeCSSPlugin };
48+
export { purgeCSSPlugin as default };
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
import e from "postcss";
22
import {
33
PurgeCSS as s,
4-
mergeExtractorSelectors as t,
5-
defaultOptions as o
4+
mergeExtractorSelectors as o,
5+
defaultOptions as t
66
} from "purgecss";
77
const r = e.plugin("postcss-plugin-purgecss", function(e) {
8-
return async function(r, c) {
9-
const n = new s(),
10-
p = { ...o, ...e };
11-
n.options = p;
12-
const { content: i, extractors: m } = p,
13-
a = i.filter(e => "string" == typeof e),
14-
l = i.filter(e => "object" == typeof e),
15-
u = await n.extractSelectorsFromFiles(a, m),
16-
f = n.extractSelectorsFromString(l, m),
17-
g = t(u, f);
18-
n.walkThroughCSS(r, g),
19-
n.options.fontFace && n.removeUnusedFontFaces(),
20-
n.options.keyframes && n.removeUnusedKeyframes(),
21-
n.options.rejected &&
22-
n.selectorsRemoved.size > 0 &&
23-
(c.messages.push({
8+
return async function(r, n) {
9+
const c = new s(),
10+
i = { ...t, ...e };
11+
c.options = i;
12+
const { content: p, extractors: a } = i,
13+
m = p.filter(e => "string" == typeof e),
14+
l = p.filter(e => "object" == typeof e),
15+
u = await c.extractSelectorsFromFiles(m, a),
16+
f = c.extractSelectorsFromString(l, a),
17+
g = o(u, f);
18+
c.walkThroughCSS(r, g),
19+
c.options.fontFace && c.removeUnusedFontFaces(),
20+
c.options.keyframes && c.removeUnusedKeyframes(),
21+
c.options.variables && c.removeUnusedCSSVariables(),
22+
c.options.rejected &&
23+
c.selectorsRemoved.size > 0 &&
24+
(n.messages.push({
2425
type: "purgecss",
2526
plugin: "postcss-purgecss",
2627
text: `purging ${
27-
n.selectorsRemoved.size
28-
} selectors:\n ${Array.from(n.selectorsRemoved)
28+
c.selectorsRemoved.size
29+
} selectors:\n ${Array.from(c.selectorsRemoved)
2930
.map(e => e.trim())
3031
.join("\n ")}`
3132
}),
32-
n.selectorsRemoved.clear());
33+
c.selectorsRemoved.clear());
3334
};
3435
});
3536
export default r;

packages/postcss-purgecss/lib/postcss-purgecss.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ const purgeCSSPlugin = postcss.plugin("postcss-plugin-purgecss", function(e) {
1313
u = c.filter(e => "string" == typeof e),
1414
p = c.filter(e => "object" == typeof e),
1515
i = await r.extractSelectorsFromFiles(u, n),
16-
l = r.extractSelectorsFromString(p, n),
17-
g = purgecss.mergeExtractorSelectors(i, l);
18-
r.walkThroughCSS(s, g),
16+
a = r.extractSelectorsFromString(p, n),
17+
l = purgecss.mergeExtractorSelectors(i, a);
18+
r.walkThroughCSS(s, l),
1919
r.options.fontFace && r.removeUnusedFontFaces(),
2020
r.options.keyframes && r.removeUnusedKeyframes(),
21+
r.options.variables && r.removeUnusedCSSVariables(),
2122
r.options.rejected &&
2223
r.selectorsRemoved.size > 0 &&
2324
(t.messages.push({
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare const purgecssFromHtml: (content: string) => string[];
2-
export { purgecssFromHtml };
2+
export { purgecssFromHtml as default };
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare const purgecssFromHtml: (content: string) => string[];
2-
export { purgecssFromHtml };
2+
export { purgecssFromHtml as default };
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare const purgeFromPug: (content: string) => string[];
2-
export { purgeFromPug };
2+
export { purgeFromPug as default };
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare const purgeFromPug: (content: string) => string[];
2-
export { purgeFromPug };
2+
export { purgeFromPug as default };

packages/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ declare class PurgeCSSPlugin {
4141
purgedStats: PurgedStats;
4242
constructor(options: UserDefinedOptions);
4343
apply(compiler: Compiler): void;
44-
onHooksCompilation(compilation: Compilation): Promise<void>;
4544
onHooksDone(stats: Stats, callback: () => void): void;
4645
getAssetsToPurge(
4746
assetsFromCompilation: PurgeAsset[],
@@ -50,4 +49,4 @@ declare class PurgeCSSPlugin {
5049
initializePlugin(compilation: Compilation): void;
5150
runPluginHook(compilation: Compilation, entryPaths: string[]): Promise<void>;
5251
}
53-
export { PurgeCSSPlugin };
52+
export { PurgeCSSPlugin as default };

packages/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.esm.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ declare class PurgeCSSPlugin {
4141
purgedStats: PurgedStats;
4242
constructor(options: UserDefinedOptions);
4343
apply(compiler: Compiler): void;
44-
onHooksCompilation(compilation: Compilation): Promise<void>;
4544
onHooksDone(stats: Stats, callback: () => void): void;
4645
getAssetsToPurge(
4746
assetsFromCompilation: PurgeAsset[],
@@ -50,4 +49,4 @@ declare class PurgeCSSPlugin {
5049
initializePlugin(compilation: Compilation): void;
5150
runPluginHook(compilation: Compilation, entryPaths: string[]): Promise<void>;
5251
}
53-
export { PurgeCSSPlugin };
52+
export { PurgeCSSPlugin as default };

packages/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.esm.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ const r = [".css", ".scss", ".styl", ".sass", ".less"],
2626
a = "PurgeCSS";
2727
export default class {
2828
constructor(t) {
29-
this.options = t;
29+
(this.purgedStats = {}), (this.options = t);
3030
}
3131
apply(t) {
3232
t.hooks.compilation.tap(a, t => {
3333
this.initializePlugin(t);
3434
}),
3535
t.hooks.done.tap(a, this.onHooksDone.bind(this));
3636
}
37-
async onHooksCompilation(t) {
38-
this.initializePlugin(t);
39-
}
4037
onHooksDone(t, s) {
4138
t.hasErrors()
4239
? this.options.verbose &&

packages/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@ const styleExtensions = [".css", ".scss", ".styl", ".sass", ".less"],
3636
pluginName = "PurgeCSS";
3737
class PurgeCSSPlugin {
3838
constructor(t) {
39-
this.options = t;
39+
(this.purgedStats = {}), (this.options = t);
4040
}
4141
apply(t) {
4242
t.hooks.compilation.tap(pluginName, t => {
4343
this.initializePlugin(t);
4444
}),
4545
t.hooks.done.tap(pluginName, this.onHooksDone.bind(this));
4646
}
47-
async onHooksCompilation(t) {
48-
this.initializePlugin(t);
49-
}
5047
onHooksDone(t, e) {
5148
t.hasErrors()
5249
? this.options.verbose &&

packages/purgecss/lib/purgecss.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ declare class PurgeCSS {
8181
private usedAnimations;
8282
private usedFontFaces;
8383
selectorsRemoved: Set<string>;
84+
private variablesStructure;
8485
options: Options;
86+
private collectDeclarationsData;
8587
/**
8688
* Get the extractor corresponding to the extension file
8789
* @param filename Name of the file
@@ -143,6 +145,10 @@ declare class PurgeCSS {
143145
purge(
144146
userOptions: UserDefinedOptions | string | undefined
145147
): Promise<ResultPurge[]>;
148+
/**
149+
* Remove unused CSS variables
150+
*/
151+
removeUnusedCSSVariables(): void;
146152
/**
147153
* Remove unused font-faces
148154
*/
@@ -164,4 +170,5 @@ declare class PurgeCSS {
164170
*/
165171
walkThroughCSS(root: postcss.Root, selectors: ExtractorResultDetailed): void;
166172
}
173+
export { PurgeCSS as default };
167174
export { defaultOptions, setOptions, mergeExtractorSelectors, PurgeCSS };

packages/purgecss/lib/purgecss.esm.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ declare class PurgeCSS {
8181
private usedAnimations;
8282
private usedFontFaces;
8383
selectorsRemoved: Set<string>;
84+
private variablesStructure;
8485
options: Options;
86+
private collectDeclarationsData;
8587
/**
8688
* Get the extractor corresponding to the extension file
8789
* @param filename Name of the file
@@ -143,6 +145,10 @@ declare class PurgeCSS {
143145
purge(
144146
userOptions: UserDefinedOptions | string | undefined
145147
): Promise<ResultPurge[]>;
148+
/**
149+
* Remove unused CSS variables
150+
*/
151+
removeUnusedCSSVariables(): void;
146152
/**
147153
* Remove unused font-faces
148154
*/
@@ -164,4 +170,5 @@ declare class PurgeCSS {
164170
*/
165171
walkThroughCSS(root: postcss.Root, selectors: ExtractorResultDetailed): void;
166172
}
173+
export { PurgeCSS as default };
167174
export { defaultOptions, setOptions, mergeExtractorSelectors, PurgeCSS };

0 commit comments

Comments
 (0)