@better-css-modules/core 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,8 +6,8 @@ import { createJiti } from "jiti";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs$1 from "node:fs/promises";
|
|
8
8
|
import { ResolverFactory } from "oxc-resolver";
|
|
9
|
-
import fg from "fast-glob";
|
|
10
9
|
import picomatch from "picomatch";
|
|
10
|
+
import { glob } from "tinyglobby";
|
|
11
11
|
import { SourceMapGenerator } from "source-map-js";
|
|
12
12
|
const { parse, generate: generate$1, lexer } = csstree.fork({
|
|
13
13
|
atrules: patches.next.atrules,
|
|
@@ -742,6 +742,25 @@ function categoryOf(name) {
|
|
|
742
742
|
return null;
|
|
743
743
|
}
|
|
744
744
|
//#endregion
|
|
745
|
+
//#region src/glob.ts
|
|
746
|
+
/**
|
|
747
|
+
* The files under `cwd` that a pattern matches and no ignore pattern does, as
|
|
748
|
+
* absolute paths. A pattern does not enter dot directories unless it names
|
|
749
|
+
* them, while an ignore pattern reaches into them too, as the matcher of the
|
|
750
|
+
* watcher and the plugins does (`createMatcher`).
|
|
751
|
+
*/
|
|
752
|
+
async function globFiles(patterns, options) {
|
|
753
|
+
const { cwd, ignore } = options;
|
|
754
|
+
const files = await glob(patterns, {
|
|
755
|
+
cwd,
|
|
756
|
+
ignore,
|
|
757
|
+
absolute: true,
|
|
758
|
+
expandDirectories: false
|
|
759
|
+
});
|
|
760
|
+
const ignored = picomatch(ignore, { dot: true });
|
|
761
|
+
return files.filter((file) => !ignored(path.relative(cwd, file).split(path.sep).join("/")));
|
|
762
|
+
}
|
|
763
|
+
//#endregion
|
|
745
764
|
//#region src/project.ts
|
|
746
765
|
/** Globs no `include` pattern should reach: dependencies and the tool's own output. */
|
|
747
766
|
function defaultIgnore(config) {
|
|
@@ -786,10 +805,9 @@ function createMatcher(config) {
|
|
|
786
805
|
/** The CSS Modules files the config includes. */
|
|
787
806
|
async function findCssModules(config) {
|
|
788
807
|
const { include, exclude } = patternsOf(config);
|
|
789
|
-
return (await
|
|
808
|
+
return (await globFiles(include, {
|
|
790
809
|
cwd: config.root,
|
|
791
|
-
ignore: exclude
|
|
792
|
-
absolute: true
|
|
810
|
+
ignore: exclude
|
|
793
811
|
})).sort();
|
|
794
812
|
}
|
|
795
813
|
/** Read and analyze one file. A stylesheet that does not parse yields its syntax diagnostic. */
|
|
@@ -1544,13 +1562,11 @@ async function wroteDts(dtsPath) {
|
|
|
1544
1562
|
* are taken, because outDir may hold other files, or be the root itself.
|
|
1545
1563
|
*/
|
|
1546
1564
|
async function outputsIn(config) {
|
|
1547
|
-
const
|
|
1548
|
-
const outputs = await fg(patterns, {
|
|
1565
|
+
const outputs = await globFiles(config.include.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [`${pattern}.d.ts`, `${pattern}.d.ts.map`]), {
|
|
1549
1566
|
cwd: path.join(config.root, config.outDir),
|
|
1550
|
-
ignore: ["**/node_modules/**"]
|
|
1551
|
-
absolute: true
|
|
1567
|
+
ignore: ["**/node_modules/**"]
|
|
1552
1568
|
});
|
|
1553
1569
|
return [...new Set(outputs.map((file) => path.resolve(file.replace(/\.map$/, ""))))].sort();
|
|
1554
1570
|
}
|
|
1555
1571
|
//#endregion
|
|
1556
|
-
export {
|
|
1572
|
+
export { valueStart as C, parse as D, lexer as E, property as O, paramsStart as S, generate$1 as T, formatGitHubAnnotation as _, resolveLayer as a, defineConfig as b, loadGlobalCss as c, findCssModules as d, loadCssModules as f, formatDiagnostic as g, tokenCategories as h, createLayerWrapper as i, walk as k, createMatcher as l, categoryOf as m, regenerateDts as n, declaresToken as o, globFiles as p, checkLayer as r, isForeign as s, generate as t, defaultIgnore as u, sortDiagnostics as v, find as w, loadConfig as x, ConfigError as y };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as valueStart, D as parse, E as lexer, O as property, S as paramsStart, T as generate$1, _ as formatGitHubAnnotation, a as resolveLayer, b as defineConfig, c as loadGlobalCss, d as findCssModules, f as loadCssModules, g as formatDiagnostic, h as tokenCategories, k as walk$1, m as categoryOf, o as declaresToken, p as globFiles, r as checkLayer, s as isForeign, t as generate, u as defaultIgnore, v as sortDiagnostics, w as find, x as loadConfig, y as ConfigError } from "./dts-QJXWpHAG.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { ResolverFactory } from "oxc-resolver";
|
|
5
|
-
import fg from "fast-glob";
|
|
6
5
|
import { parseSync } from "oxc-parser";
|
|
7
6
|
//#region src/breakpoint.ts
|
|
8
7
|
/** Media features that compare the width of the viewport. */
|
|
@@ -1857,10 +1856,9 @@ function isUsed(moduleUsage, name) {
|
|
|
1857
1856
|
}
|
|
1858
1857
|
async function findSources(config, cwd) {
|
|
1859
1858
|
const ignore = [...defaultIgnore(config), ...IGNORED_DIRS.map((dir) => `${dir}/**`)];
|
|
1860
|
-
return (await
|
|
1859
|
+
return (await globFiles(SOURCE_GLOBS, {
|
|
1861
1860
|
cwd,
|
|
1862
|
-
ignore
|
|
1863
|
-
absolute: true
|
|
1861
|
+
ignore
|
|
1864
1862
|
})).filter((file) => !/\.d\.[mc]?ts$/.test(file)).sort();
|
|
1865
1863
|
}
|
|
1866
1864
|
function langOf(file) {
|
package/dist/internal.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as formatDiagnostic, i as createLayerWrapper, l as createMatcher, n as regenerateDts, t as generate } from "./dts-QJXWpHAG.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { watch } from "chokidar";
|
|
4
4
|
//#region src/watcher.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-css-modules/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Analysis, type generation, unused-class detection, token checks, watcher and config for better-css-modules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css-modules",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@csstools/css-syntax-patches-for-csstree": "1.1.14",
|
|
36
36
|
"chokidar": "5.0.0",
|
|
37
37
|
"css-tree": "3.2.1",
|
|
38
|
-
"fast-glob": "3.3.3",
|
|
39
38
|
"jiti": "2.6.1",
|
|
40
39
|
"oxc-parser": "0.151.0",
|
|
41
40
|
"oxc-resolver": "11.24.2",
|
|
42
41
|
"picomatch": "4.0.7",
|
|
43
|
-
"postcss": "8.5.
|
|
44
|
-
"source-map-js": "1.2.
|
|
42
|
+
"postcss": "8.5.31",
|
|
43
|
+
"source-map-js": "1.2.2",
|
|
44
|
+
"tinyglobby": "0.2.17"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/css-tree": "3.2.0",
|