Skip to content

Commit 4f3ddd0

Browse files
committed
fix: wrong path import
- fix wrong path import (was importing path/posix instead of path - add vinyl-sourcempas-apply to external (rollup config) - run prettier
1 parent 55c26d2 commit 4f3ddd0

File tree

14 files changed

+63
-56
lines changed

14 files changed

+63
-56
lines changed

packages/gulp-purgecss/build.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as path from "path";
1616
"plugin-error",
1717
"purgecss",
1818
"glob",
19+
"vinyl-sourcemaps-apply",
1920
]);
2021
await buildRollup(rollupConfig);
2122
await extractAPI(__dirname);

packages/gulp-purgecss/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function gulpPurgeCSS(options: UserDefinedOptions): internal.Transform {
4040
},
4141
],
4242
stdin: true,
43-
sourceMap: !!file.sourceMap
43+
sourceMap: !!file.sourceMap,
4444
};
4545
const purgedCSSResults = await new PurgeCSS().purge(optionsGulp);
4646
const purge = purgedCSSResults[0];
@@ -77,7 +77,7 @@ function gulpPurgeCSS(options: UserDefinedOptions): internal.Transform {
7777
raw: css,
7878
},
7979
],
80-
sourceMap: !!file.sourceMap
80+
sourceMap: !!file.sourceMap,
8181
};
8282

8383
const purgedCSSResults = await new PurgeCSS().purge(optionsGulp);

packages/postcss-purgecss/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ async function purgeCSS(
7373
}
7474

7575
/**
76-
*
76+
*
7777
* @param opts - opts
78-
* @returns
79-
*
78+
* @returns
79+
*
8080
* @public
8181
*/
8282
const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions> = function (
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {
22
UserDefinedOptions as PurgeCSSUserDefinedOptions,
3-
RawContent
3+
RawContent,
44
} from "purgecss";
55

6-
76
/**
87
* {@inheritDoc purgecss#UserDefinedOptions}
9-
*
8+
*
109
* @public
1110
*/
12-
export interface UserDefinedOptions extends Omit<PurgeCSSUserDefinedOptions,"content" | "css"> {
13-
content?: PurgeCSSUserDefinedOptions['content'];
11+
export interface UserDefinedOptions
12+
extends Omit<PurgeCSSUserDefinedOptions, "content" | "css"> {
13+
content?: PurgeCSSUserDefinedOptions["content"];
1414
contentFunction?: (sourceFile: string) => Array<string | RawContent>;
1515
}

packages/purgecss-from-html/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ const getSelectorsInNodes = (
9595

9696
/**
9797
* Get the potential selectors from HTML code
98-
*
98+
*
9999
* @param content - HTML code
100100
* @returns the attributes, classes, ids, and tags from the HTML code
101-
*
101+
*
102102
* @public
103103
*/
104104
const purgecssFromHtml = (content: string): ExtractorResultDetailed => {

packages/purgecss-from-jsx/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ extend<NodeState>(walk.base);
1818

1919
/**
2020
* Create function to extract selectors from jsx code
21-
*
21+
*
2222
* @param options - acorn options
2323
* @returns function to extract selectors from jsx code
24-
*
24+
*
2525
* @public
2626
*/
2727
function purgeFromJsx(options?: acorn.Options) {

packages/purgecss-from-pug/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import lex from "pug-lexer";
22

33
/**
44
* Get the potential selectors from Pug code
5-
*
5+
*
66
* @param content - Pug code
77
* @returns the attributes, classes, ids, and tags from the Pug code
8-
*
8+
*
99
* @public
1010
*/
1111
const purgeFromPug = (content: string): string[] => {

packages/purgecss-from-tsx/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as ts from "typescript";
44

55
/**
66
* Create function to extract selectors from tsx code
7-
*
7+
*
88
* @param options - acorn options
99
* @returns the function to extract selectors from tsx code
10-
*
10+
*
1111
* @public
1212
*/
1313
function purgeFromTsx(options?: {

packages/purgecss-webpack-plugin/src/types/index.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type {
22
ComplexSafelist,
33
StringRegExpArray,
4-
UserDefinedOptions as PurgeCSSUserDefinedOptions
4+
UserDefinedOptions as PurgeCSSUserDefinedOptions,
55
} from "purgecss";
66

7-
87
/**
9-
* @public
8+
* @public
109
*/
1110
export type PathFunction = () => string[];
1211
/**
@@ -28,11 +27,14 @@ export type PurgedStats = {
2827
/**
2928
* @public
3029
*/
31-
export type UserDefinedOptions = Omit<PurgeCSSUserDefinedOptions, "css" | "content" | "safelist" | "blocklist" | "sourceMap"> & {
30+
export type UserDefinedOptions = Omit<
31+
PurgeCSSUserDefinedOptions,
32+
"css" | "content" | "safelist" | "blocklist" | "sourceMap"
33+
> & {
3234
paths: string[] | PathFunction;
3335
moduleExtensions?: string[];
3436
verbose?: boolean;
35-
safelist: PurgeCSSUserDefinedOptions['safelist'] | SafelistFunction;
36-
blocklist: PurgeCSSUserDefinedOptions['blocklist'] | BlocklistFunction;
37+
safelist: PurgeCSSUserDefinedOptions["safelist"] | SafelistFunction;
38+
blocklist: PurgeCSSUserDefinedOptions["blocklist"] | BlocklistFunction;
3739
only?: string[];
38-
}
40+
};
+14-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
import { PurgeCSS } from '../src/'
2-
import { ROOT_TEST_EXAMPLES } from './utils';
1+
import { PurgeCSS } from "../src/";
2+
import { ROOT_TEST_EXAMPLES } from "./utils";
33

44
describe("source map option", () => {
5-
it('contains the source map inlined in the CSS file', async () => {
5+
it("contains the source map inlined in the CSS file", async () => {
66
const resultsPurge = await new PurgeCSS().purge({
77
content: [`${ROOT_TEST_EXAMPLES}others/remove_unused.js`],
88
css: [`${ROOT_TEST_EXAMPLES}others/remove_unused.css`],
9-
sourceMap: true
9+
sourceMap: true,
1010
});
1111

12-
expect(resultsPurge[0].css).toContain('sourceMappingURL=data:application/json;base64');
12+
expect(resultsPurge[0].css).toContain(
13+
"sourceMappingURL=data:application/json;base64"
14+
);
1315
});
1416

15-
it('contains the source map separately when setting inline to false', async () => {
17+
it("contains the source map separately when setting inline to false", async () => {
1618
const resultsPurge = await new PurgeCSS().purge({
1719
content: [`${ROOT_TEST_EXAMPLES}others/remove_unused.js`],
1820
css: [`${ROOT_TEST_EXAMPLES}others/remove_unused.css`],
1921
sourceMap: {
20-
inline: false
21-
}
22+
inline: false,
23+
},
2224
});
2325

24-
expect(resultsPurge[0].sourceMap).toContain('sources":["__tests__/test_examples/others/remove_unused.css"]');
25-
})
26+
expect(resultsPurge[0].sourceMap).toContain(
27+
'sources":["__tests__/test_examples/others/remove_unused.css"]'
28+
);
29+
});
2630
});

packages/purgecss/src/types/index.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export type ComplexSafelist = {
8383
/**
8484
* You can safelist selectors and their children based on a regular
8585
* expression with `safelist.deep`
86-
*
86+
*
8787
* @example
88-
*
88+
*
8989
* ```ts
9090
* const purgecss = await new PurgeCSS().purge({
9191
* content: [],
@@ -95,10 +95,10 @@ export type ComplexSafelist = {
9595
* }
9696
* })
9797
* ```
98-
*
99-
* In this example, selectors such as `.bg-red .child-of-bg` will be left
98+
*
99+
* In this example, selectors such as `.bg-red .child-of-bg` will be left
100100
* in the final CSS, even if `child-of-bg` is not found.
101-
*
101+
*
102102
*/
103103
deep?: RegExp[];
104104
greedy?: RegExp[];
@@ -113,7 +113,7 @@ export type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
113113

114114
/**
115115
* Options used by PurgeCSS to remove unused CSS
116-
*
116+
*
117117
* @public
118118
*/
119119
export interface UserDefinedOptions {
@@ -136,7 +136,7 @@ export interface UserDefinedOptions {
136136
/** {@inheritDoc Options.rejectedCss} */
137137
rejectedCss?: boolean;
138138
/** {@inheritDoc Options.sourceMap } */
139-
sourceMap?: boolean | postcss.SourceMapOptions & { to?: string }
139+
sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
140140
/** {@inheritDoc Options.stdin} */
141141
stdin?: boolean;
142142
/** {@inheritDoc Options.stdout} */
@@ -157,29 +157,29 @@ export interface UserDefinedOptions {
157157
* Options used by PurgeCSS to remove unused CSS
158158
* Those options are used internally
159159
* @see {@link UserDefinedOptions} for the options defined by the user
160-
*
160+
*
161161
* @public
162162
*/
163163
export interface Options {
164164
/**
165165
* You can specify content that should be analyzed by PurgeCSS with an
166166
* array of filenames or globs. The files can be HTML, Pug, Blade, etc.
167-
*
167+
*
168168
* @example
169-
*
169+
*
170170
* ```ts
171171
* await new PurgeCSS().purge({
172172
* content: ['index.html', '*.js', '*.html', '*.vue'],
173173
* css: ['css/app.css']
174174
* })
175175
* ```
176-
*
176+
*
177177
* @example
178178
* PurgeCSS also works with raw content. To do this, you need to pass an
179179
* object with the `raw` property instead of a filename. To work properly
180180
* with custom extractors you need to pass the `extension` property along
181181
* with the raw content.
182-
*
182+
*
183183
* ```ts
184184
* await new PurgeCSS().purge({
185185
* content: [
@@ -211,9 +211,9 @@ export interface Options {
211211
/**
212212
* If there are any unused \@font-face rules in your css, you can remove
213213
* them by setting the `fontFace` option to `true`.
214-
*
214+
*
215215
* @defaultValue `false`
216-
*
216+
*
217217
* @example
218218
* ```ts
219219
* await new PurgeCSS().purge({
@@ -229,7 +229,7 @@ export interface Options {
229229
rejected: boolean;
230230
rejectedCss: boolean;
231231
/** {@inheritDoc postcss#SourceMapOptions} */
232-
sourceMap: boolean | postcss.SourceMapOptions & { to?: string }
232+
sourceMap: boolean | (postcss.SourceMapOptions & { to?: string });
233233
stdin: boolean;
234234
stdout: boolean;
235235
variables: boolean;

packages/rollup-plugin-purgecss/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { UserDefinedOptions } from "./types";
77
export * from "./types";
88

99
/**
10-
*
10+
*
1111
* @param options - options
12-
* @returns
13-
*
12+
* @returns
13+
*
1414
* @public
1515
*/
1616
function pluginPurgeCSS(options: UserDefinedOptions): Plugin {

scripts/build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "@microsoft/api-extractor";
88
import typescript from "@rollup/plugin-typescript";
99
import { terser } from "rollup-plugin-terser";
10-
import path from "path/posix";
10+
import * as path from "path";
1111

1212
const rollupBaseConfig: RollupOptions = {
1313
input: "./src/index.ts",
@@ -95,7 +95,7 @@ const extractorAPIBaseConfig: IExtractorConfigPrepareOptions = {
9595
},
9696
"ae-internal-missing-underscore": {
9797
logLevel: ExtractorLogLevel.None,
98-
}
98+
},
9999
},
100100
tsdocMessageReporting: {
101101
default: {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
declare module 'vinyl-sourcemaps-apply';
1+
declare module "vinyl-sourcemaps-apply";

0 commit comments

Comments
 (0)