@master/css-compiler 2.0.0-rc.80 → 2.0.0-rc.82
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/index.js +46 -8
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -37,6 +37,51 @@ function findPackageRoot(entryFile, packageName) {
|
|
|
37
37
|
directory = parentDirectory;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
function resolvePackageDirectory(directory) {
|
|
41
|
+
try {
|
|
42
|
+
return realpathSync(directory);
|
|
43
|
+
} catch {
|
|
44
|
+
return directory;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function findNodeModulesPackageRoot(baseDirectory, packageName) {
|
|
48
|
+
let directory = resolve(baseDirectory);
|
|
49
|
+
const packagePath = packageName.split("/");
|
|
50
|
+
while (true) {
|
|
51
|
+
const packageJSONFile = resolve(directory, "node_modules", ...packagePath, "package.json");
|
|
52
|
+
if (existsSync(packageJSONFile)) try {
|
|
53
|
+
const packageJSON = readJSONFile(packageJSONFile);
|
|
54
|
+
if (packageJSON.name === packageName) return {
|
|
55
|
+
directory: resolvePackageDirectory(dirname(packageJSONFile)),
|
|
56
|
+
packageJSON
|
|
57
|
+
};
|
|
58
|
+
} catch {}
|
|
59
|
+
const parentDirectory = dirname(directory);
|
|
60
|
+
if (parentDirectory === directory) return;
|
|
61
|
+
directory = parentDirectory;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function resolvePackageRoot(packageName, fromFile, projectDir) {
|
|
65
|
+
const resolvedFromFile = resolve(projectDir || "", fromFile);
|
|
66
|
+
const searchDirectories = [
|
|
67
|
+
projectDir,
|
|
68
|
+
resolvedFromFile,
|
|
69
|
+
dirname(resolvedFromFile),
|
|
70
|
+
process.cwd()
|
|
71
|
+
].filter((directory) => typeof directory === "string");
|
|
72
|
+
for (const directory of new Set(searchDirectories)) {
|
|
73
|
+
const packageRoot = findNodeModulesPackageRoot(directory, packageName);
|
|
74
|
+
if (packageRoot) return packageRoot;
|
|
75
|
+
}
|
|
76
|
+
const resolver = createProjectRequire(fromFile, projectDir);
|
|
77
|
+
let packageEntryFile;
|
|
78
|
+
try {
|
|
79
|
+
packageEntryFile = resolver.resolve(packageName);
|
|
80
|
+
} catch {
|
|
81
|
+
packageEntryFile = require.resolve(packageName);
|
|
82
|
+
}
|
|
83
|
+
return findPackageRoot(packageEntryFile, packageName);
|
|
84
|
+
}
|
|
40
85
|
function getPackageStyleEntry(packageJSON) {
|
|
41
86
|
if (typeof packageJSON.style === "string") return packageJSON.style;
|
|
42
87
|
if (!packageJSON.exports || typeof packageJSON.exports !== "object") return;
|
|
@@ -50,14 +95,7 @@ function createProjectRequire(fromFile, projectDir) {
|
|
|
50
95
|
}
|
|
51
96
|
function resolveMasterCSSPackageEntryFile(importSource, fromFile = process.cwd(), projectDir) {
|
|
52
97
|
if (!MASTER_CSS_PACKAGE_IDS.has(importSource)) return;
|
|
53
|
-
const
|
|
54
|
-
let packageEntryFile;
|
|
55
|
-
try {
|
|
56
|
-
packageEntryFile = resolver.resolve(importSource);
|
|
57
|
-
} catch {
|
|
58
|
-
packageEntryFile = require.resolve(importSource);
|
|
59
|
-
}
|
|
60
|
-
const packageRoot = findPackageRoot(packageEntryFile, importSource);
|
|
98
|
+
const packageRoot = resolvePackageRoot(importSource, fromFile, projectDir);
|
|
61
99
|
if (!packageRoot) return;
|
|
62
100
|
const styleEntry = getPackageStyleEntry(packageRoot.packageJSON);
|
|
63
101
|
if (!styleEntry) return;
|
package/package.json
CHANGED
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"csstype": "^3.2.3",
|
|
51
51
|
"lightningcss": "^1.32.0",
|
|
52
52
|
"lightningcss-wasm": "^1.32.0",
|
|
53
|
-
"@master/css-
|
|
54
|
-
"@master/css-
|
|
55
|
-
"@master/css-
|
|
53
|
+
"@master/css-lexer": "^2.0.0-rc.82",
|
|
54
|
+
"@master/css-schema": "^2.0.0-rc.82",
|
|
55
|
+
"@master/css-engine": "^2.0.0-rc.82"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/css-tree": "^2.3.11",
|
|
59
|
-
"@master/css-preset": "^2.0.0-rc.
|
|
59
|
+
"@master/css-preset": "^2.0.0-rc.82"
|
|
60
60
|
},
|
|
61
|
-
"version": "2.0.0-rc.
|
|
61
|
+
"version": "2.0.0-rc.82",
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown --config ../../shared/tsdown-package.config.ts",
|
|
64
64
|
"dev": "tsdown --config ../../shared/tsdown-package.config.ts --watch",
|