Skip to content

fix: cssnano types #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,625 changes: 1,276 additions & 1,349 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
}
},
"dependencies": {
"@types/cssnano": "^4.0.1",
"cssnano": "^5.0.6",
"jest-worker": "^27.0.2",
"postcss": "^8.3.5",
Expand All @@ -71,7 +70,7 @@
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@types/clean-css": "^4.2.5",
"@types/csso": "^4.2.0",
"@types/csso": "^5.0.0",
"@types/serialize-javascript": "^5.0.1",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^27.0.6",
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ const { minify } = require("./minify");
/** @typedef {import("webpack").WebpackError} WebpackError */
/** @typedef {import("jest-worker").Worker} JestWorker */
/** @typedef {import("source-map").RawSourceMap} RawSourceMap */
/** @typedef {import("cssnano").CssNanoOptions} CssNanoOptions */
/** @typedef {import("webpack").Asset} Asset */
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
/** @typedef {import("postcss").Syntax} Syntax */
/** @typedef {import("postcss").Parser} Parser */
/** @typedef {import("postcss").Stringifier} Stringifier */

/**
* @typedef {Object} CssNanoOptions
* @property {string} [configFile]
* @property {[string, object] | string | undefined} [preset]
*/

/** @typedef {Error & { plugin?: string, text?: string, source?: string } | string} Warning */

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
/** @typedef {import("postcss").Postcss} Postcss */
/** @typedef {import("cssnano")} CssNano */

const notSettled = Symbol(`not-settled`);

Expand Down Expand Up @@ -167,6 +166,7 @@ async function cssnanoMinify(
/** @type {Postcss} */
// eslint-disable-next-line global-require
const postcss = require("postcss").default;
// @ts-ignore
// eslint-disable-next-line global-require
const cssnano = require("cssnano");
// @ts-ignore
Expand Down
7 changes: 5 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ declare namespace CssMinimizerPlugin {
WebpackError,
JestWorker,
RawSourceMap,
CssNanoOptions,
Asset,
ProcessOptions,
Syntax,
Parser,
Stringifier,
CssNanoOptions,
Warning,
WarningObject,
ErrorObject,
Expand Down Expand Up @@ -133,12 +133,15 @@ type Compilation = import("webpack").Compilation;
type WebpackError = import("webpack").WebpackError;
type JestWorker = import("jest-worker").Worker;
type RawSourceMap = import("source-map").RawSourceMap;
type CssNanoOptions = import("cssnano").CssNanoOptions;
type Asset = import("webpack").Asset;
type ProcessOptions = import("postcss").ProcessOptions;
type Syntax = import("postcss").Syntax;
type Parser = import("postcss").Parser;
type Stringifier = import("postcss").Stringifier;
type CssNanoOptions = {
configFile?: string | undefined;
preset?: [string, object] | string | undefined;
};
type Warning =
| (Error & {
plugin?: string;
Expand Down
3 changes: 0 additions & 3 deletions types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ export type MinimizedResult = import("./index.js").MinimizedResult;
export type CustomOptions = import("./index.js").CustomOptions;
export type ProcessOptions = import("postcss").ProcessOptions;
export type Postcss = import("postcss").Postcss;
export type CssNano = import("cssnano/node_modules/postcss").Plugin<
import("cssnano").CssNanoOptions
>;
/**
* @template T
* @typedef {() => Promise<T>} Task
Expand Down