Comparing version 1.0.5 to 1.0.6
// Replace class names in JS content with care | ||
import * as acorn from "acorn"; | ||
import { Parser } from "acorn"; | ||
import * as walk from "acorn-walk"; | ||
@@ -9,2 +9,11 @@ import { escapeString } from "./helpers.js"; | ||
import { isSelectorString, replaceClassNamesInCSS } from "./css-functions.js"; | ||
// @ts-expect-error I know what I'm doing | ||
class SyntacticParser extends Parser { | ||
raiseRecoverable(pos, message) { | ||
if (message.includes("Identifier ") && | ||
message.includes(" has already been declared")) | ||
return; | ||
Parser.prototype.raiseRecoverable.call(this, pos, message); // weird call syntax required because the TypeScript types for Parser doesn't contain the `raiseRecoverable` method | ||
} | ||
} | ||
export async function replaceClassNamesInJs(content, classMap, jsOptions, cssOptions) { | ||
@@ -74,3 +83,3 @@ const { ignoreStringPatterns = [], skipRules = [], mode = "acorn", } = jsOptions; | ||
if (mode === "acorn") { | ||
const ast = acorn.parse(content, { | ||
const ast = SyntacticParser.parse(content, { | ||
ecmaVersion: 2020, | ||
@@ -77,0 +86,0 @@ sourceType: "module", |
@@ -12,3 +12,3 @@ import { Command, Option } from "commander"; | ||
const booleanParser = (val) => val === "true"; | ||
program.version("1.0.5").name("breezify"); | ||
program.version("1.0.6").name("breezify"); | ||
program | ||
@@ -15,0 +15,0 @@ .command("do") |
{ | ||
"name": "breezify", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A tool for minifying CSS class names", | ||
@@ -5,0 +5,0 @@ "author": "Gleb Gorokhov <theververy@gmail.com>", |
@@ -58,3 +58,3 @@ <img src="./logo_light.svg#gh-light-mode-only" alt="logo" width="200" /> | ||
## Donations ❤️ | ||
## Donations 👉👈 | ||
@@ -238,3 +238,2 @@ If you like the project and want to support it, you can donate to the author: | ||
- `ignoreClassPatterns` (string[] | undefined): The RegExp patterns to ignore. Use as strings, without modifiers. Example: `["^ProseMirror"]` for class names with "ProseMirror" prefix. | ||
- `sourceMap` (boolean): Whether to generate source maps. Default: `false`. | ||
- `shuffle` (boolean | undefined): Whether to shuffle class names. Default: `true`. | ||
@@ -244,2 +243,4 @@ - `prefix` (string | undefined): The prefix to add to the class names. | ||
- `extractClassesFromHtml` (boolean | undefined): Whether to extract class names from <style> tags found in HTML files. Default: `true`. | ||
- `restructure` (boolean | undefined): Whether to restructure the output CSS with CSSO for more efficient minification. Default: `true`. | ||
- `forceMediaMerge` (boolean | undefined): Whether to force merging media queries with CSSO for more efficient minification. Default: `true`. | ||
@@ -246,0 +247,0 @@ ## JSOptions |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65956
1166
299