@knighted/css 1.0.8 → 1.0.9
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.
- package/dist/cjs/generateTypes.cjs +10 -7
- package/dist/cjs/generateTypes.cjs.map +1 -1
- package/dist/cjs/lexer.cjs +229 -0
- package/dist/cjs/lexer.cjs.map +1 -0
- package/dist/cjs/lexer.d.cts +11 -0
- package/dist/cjs/moduleInfo.cjs +5 -20
- package/dist/cjs/moduleInfo.cjs.map +1 -1
- package/dist/cjs/moduleInfo.d.cts +3 -2
- package/dist/generateTypes.js +10 -7
- package/dist/generateTypes.js.map +1 -1
- package/dist/lexer.d.ts +11 -0
- package/dist/lexer.js +223 -0
- package/dist/lexer.js.map +1 -0
- package/dist/moduleInfo.d.ts +3 -2
- package/dist/moduleInfo.js +5 -20
- package/dist/moduleInfo.js.map +1 -1
- package/loader-queries.d.ts +2 -0
- package/package.json +1 -1
|
@@ -11,11 +11,11 @@ const promises_1 = __importDefault(require("node:fs/promises"));
|
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
12
|
const node_module_1 = require("node:module");
|
|
13
13
|
const node_url_1 = require("node:url");
|
|
14
|
-
const es_module_lexer_1 = require("es-module-lexer");
|
|
15
14
|
const node_module_type_1 = require("node-module-type");
|
|
16
15
|
const get_tsconfig_1 = require("get-tsconfig");
|
|
17
16
|
const tsconfig_paths_1 = require("tsconfig-paths");
|
|
18
17
|
const css_js_1 = require("./css.cjs");
|
|
18
|
+
const lexer_js_1 = require("./lexer.cjs");
|
|
19
19
|
const stableSelectorsLiteral_js_1 = require("./stableSelectorsLiteral.cjs");
|
|
20
20
|
const stableNamespace_js_1 = require("./stableNamespace.cjs");
|
|
21
21
|
let activeCssWithMeta = css_js_1.cssWithMeta;
|
|
@@ -70,7 +70,6 @@ async function generateTypes(options = {}) {
|
|
|
70
70
|
const include = normalizeIncludeOptions(options.include, rootDir);
|
|
71
71
|
const cacheDir = node_path_1.default.resolve(options.outDir ?? node_path_1.default.join(rootDir, '.knighted-css'));
|
|
72
72
|
const tsconfig = loadTsconfigResolutionContext(rootDir);
|
|
73
|
-
await es_module_lexer_1.init;
|
|
74
73
|
await promises_1.default.mkdir(cacheDir, { recursive: true });
|
|
75
74
|
const internalOptions = {
|
|
76
75
|
rootDir,
|
|
@@ -211,13 +210,17 @@ async function findSpecifierImports(filePath) {
|
|
|
211
210
|
return [];
|
|
212
211
|
}
|
|
213
212
|
const matches = [];
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const specifier
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
try {
|
|
214
|
+
const { imports } = await (0, lexer_js_1.analyzeModule)(source, filePath);
|
|
215
|
+
for (const specifier of imports) {
|
|
216
|
+
if (specifier.includes(SELECTOR_REFERENCE)) {
|
|
217
|
+
matches.push({ specifier, importer: filePath });
|
|
218
|
+
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
+
catch {
|
|
222
|
+
// ignore and fall back to regex below
|
|
223
|
+
}
|
|
221
224
|
const requireRegex = /require\((['"])([^'"`]+?\.knighted-css[^'"`]*)\1\)/g;
|
|
222
225
|
let reqMatch;
|
|
223
226
|
while ((reqMatch = requireRegex.exec(source)) !== null) {
|