From 39cbcbec77cb60259306575e6d44db7f7b25fb93 Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Tue, 21 Dec 2021 22:51:49 +0300 Subject: [PATCH] chore: dependencies (#735) * Replace chalk to picocolors * Fix warning * Replace postcss-strip-inline-comments --- package.json | 7 ++--- src/cli.ts | 12 +++++++- src/features/css-prop.ts | 8 +++--- src/utils/loaders.ts | 10 +++---- yarn.lock | 62 ++++++++++++++++------------------------ 5 files changed, 48 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 98365760..5aa5f4ee 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,6 @@ "@types/loader-utils": "^2.0.1", "@types/resolve": "^1.20.0", "@types/webpack": "^4.41.26", - "chalk": "^4.1.0", "common-tags": "^1.8.0", "cosmiconfig": "^7.0.0", "css-loader": "^5.1.3", @@ -94,10 +93,10 @@ "loader-utils": "^2.0.0", "lodash": "^4.17.21", "magic-string": "^0.25.7", - "postcss": "^8.2.8", - "postcss-nested": "^5.0.5", + "picocolors": "^1.0.0", + "postcss": "^8.4.5", + "postcss-nested": "^5.0.6", "postcss-scss": "^4.0.2", - "postcss-strip-inline-comments": "^0.1.5", "resolve": "^1.20.0", "webpack-virtual-modules": "^0.3.2", "yargs": "^17.2.1" diff --git a/src/cli.ts b/src/cli.ts index d8be33af..373cfc3c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -7,8 +7,8 @@ import path from 'path'; import Processor from '@modular-css/processor'; import Output from '@modular-css/processor/lib/output'; import globby from 'globby'; +import { PluginCreator } from 'postcss'; import postcssScss from 'postcss-scss'; -import stripInlineComments from 'postcss-strip-inline-comments'; import resolve from 'resolve'; import yargs from 'yargs'; @@ -39,6 +39,16 @@ function composesPlugin(css: any) { composesPlugin.postcssPlugin = 'compat-composes-delimiter'; +const stripInlineComments: PluginCreator = () => { + return { + postcssPlugin: 'astroturf/strip-inline-comments', + Comment(comment) { + if (comment.raws.inline) comment.remove(); + }, + }; +}; +stripInlineComments.postcss = true; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions yargs .help() diff --git a/src/features/css-prop.ts b/src/features/css-prop.ts index 50cbb36a..d7053800 100644 --- a/src/features/css-prop.ts +++ b/src/features/css-prop.ts @@ -1,7 +1,7 @@ import { NodePath } from '@babel/core'; import generate from '@babel/generator'; import * as t from '@babel/types'; -import chalk from 'chalk'; +import pico from 'picocolors'; import { DynamicStyle, PluginState, ResolvedOptions } from '../types'; import { COMPONENTS, JSX_IDENTS, STYLES } from '../utils/Symbols'; @@ -60,11 +60,11 @@ function buildCssProp( if (!pluginOptions.noWarnings) // eslint-disable-next-line no-console console.warn( - chalk.yellow( + pico.yellow( 'It looks like you are trying to use the css prop with', - chalk.bold('astroturf'), + pico.bold('astroturf'), 'but have not enabled it. add', - chalk.bold('enableCssProp: true'), + pico.bold('enableCssProp: true'), 'to the loader or plugin options to compile the css prop.', ), ); diff --git a/src/utils/loaders.ts b/src/utils/loaders.ts index e1532066..81b9fccd 100644 --- a/src/utils/loaders.ts +++ b/src/utils/loaders.ts @@ -1,10 +1,10 @@ import { codeFrameColumns } from '@babel/code-frame'; import { SourceLocation } from '@babel/types'; -import chalk from 'chalk'; import levenshtein from 'fast-levenshtein'; import loaderUtils from 'loader-utils'; import sortBy from 'lodash/sortBy'; import MagicString from 'magic-string'; +import pico from 'picocolors'; import type { CssSyntaxError } from 'postcss'; import config from '../config'; @@ -100,11 +100,11 @@ export function buildDependencyError( } if (closest) idents = idents.filter((ident) => ident !== closest); - const identMsg = idents.map((s) => chalk.yellow(s)).join(', '); + const identMsg = idents.map((s) => pico.yellow(s)).join(', '); const alternative = isDefaultImport - ? `Instead try: ${chalk.yellow(`import ${closest} from '${request}';`)}` - : `Did you mean to import as ${chalk.yellow(closest)} instead?`; + ? `Instead try: ${pico.yellow(`import ${closest} from '${request}';`)}` + : `Did you mean to import as ${pico.yellow(closest)} instead?`; return new AstroturfLoaderError( // eslint-disable-next-line prefer-template @@ -116,7 +116,7 @@ export function buildDependencyError( { highlightCode: true, message: !isDefaultImport - ? `(Imported as ${chalk.bold(identifier)})` + ? `(Imported as ${pico.bold(identifier)})` : '', }, ) + diff --git a/yarn.lock b/yarn.lock index b6639f66..e9a58275 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5749,11 +5749,6 @@ has-bigints@^1.0.1: resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - integrity sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo= - has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -7112,11 +7107,6 @@ jest@^26.6.3: import-local "^3.0.2" jest-cli "^26.6.3" -js-base64@^2.1.9: - version "2.6.4" - resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4" - integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -8905,12 +8895,12 @@ postcss-modules-values@^4.0.0: dependencies: icss-utils "^5.0.0" -postcss-nested@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/postcss-nested/-/postcss-nested-5.0.5.tgz#f0a107d33a9fab11d7637205f5321e27223e3603" - integrity sha512-GSRXYz5bccobpTzLQZXOnSOfKl6TwVr5CyAQJUPub4nuRJSOECK5AqurxVgmtxP48p0Kc/ndY/YyS1yqldX0Ew== +postcss-nested@^5.0.6: + version "5.0.6" + resolved "https://registry.yarnpkg.com/postcss-nested/-/postcss-nested-5.0.6.tgz#466343f7fc8d3d46af3e7dba3fcd47d052a945bc" + integrity sha512-rKqm2Fk0KbA8Vt3AdGN0FB9OBOMDVajMG6ZCf/GoHgdxUJ4sBFp0A/uMIRm+MJUdo33YXEtjqIz8u7DAp8B7DA== dependencies: - postcss-selector-parser "^6.0.4" + postcss-selector-parser "^6.0.6" postcss-scss@^4.0.2: version "4.0.2" @@ -8927,12 +8917,13 @@ postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4: uniq "^1.0.1" util-deprecate "^1.0.2" -postcss-strip-inline-comments@^0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/postcss-strip-inline-comments/-/postcss-strip-inline-comments-0.1.5.tgz#7ff6bcdc14e633ed4cdfa020bae3eddad4f84b90" - integrity sha1-f/a83BTmM+1M36AguuPt2tT4S5A= +postcss-selector-parser@^6.0.6: + version "6.0.7" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.7.tgz#48404830a635113a71fd79397de8209ed05a66fc" + integrity sha512-U+b/Deoi4I/UmE6KOVPpnhS7I7AYdKbhGcat+qTQ27gycvaACvNEw11ba6RrkwVmDVRW7sigWgLj4/KbbJjeDA== dependencies: - postcss "^5.0.18" + cssesc "^3.0.0" + util-deprecate "^1.0.2" postcss-url@^10.0.0: version "10.1.3" @@ -8949,16 +8940,6 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0: resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb" integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ== -postcss@^5.0.18: - version "5.2.18" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5" - integrity sha512-zrUjRRe1bpXKsX1qAJNJjqZViErVuyEkMTRrwu4ud4sbTtIBRmtaYDrHmcGgmrbsW3MHfmtIf+vJumgQn+PrXg== - dependencies: - chalk "^1.1.3" - js-base64 "^2.1.9" - source-map "^0.5.6" - supports-color "^3.2.3" - postcss@^8.0.0, postcss@^8.2.8: version "8.3.11" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.11.tgz#c3beca7ea811cd5e1c4a3ec6d2e7599ef1f8f858" @@ -8968,6 +8949,15 @@ postcss@^8.0.0, postcss@^8.2.8: picocolors "^1.0.0" source-map-js "^0.6.2" +postcss@^8.4.5: + version "8.4.5" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.5.tgz#bae665764dfd4c6fcc24dc0fdf7e7aa00cc77f95" + integrity sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg== + dependencies: + nanoid "^3.1.30" + picocolors "^1.0.0" + source-map-js "^1.0.1" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -10115,6 +10105,11 @@ source-map-js@^0.6.2: resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e" integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug== +source-map-js@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.1.tgz#a1741c131e3c77d048252adfa24e23b908670caf" + integrity sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA== + source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" @@ -10486,13 +10481,6 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" - integrity sha1-ZawFBLOVQXHYpklGsq48u4pfVPY= - dependencies: - has-flag "^1.0.0" - supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"