olova 2.0.62 → 2.0.63
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 +38 -4
- package/dist/index.js.map +1 -1
- package/dist/vite.js +38 -4
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2143,11 +2143,45 @@ var RUNTIME_MODULE_ID = "\0olova:runtime";
|
|
|
2143
2143
|
var CORE_MODULE_ID = "\0olova:core";
|
|
2144
2144
|
var GLOBAL_MODULE_ID = "\0olova:global";
|
|
2145
2145
|
var STYLE_QUERY = "?olova&type=style";
|
|
2146
|
+
function findPackageRoot(startDir) {
|
|
2147
|
+
let currentDir = startDir;
|
|
2148
|
+
while (true) {
|
|
2149
|
+
const packageJsonPath = path.join(currentDir, "package.json");
|
|
2150
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
2151
|
+
return currentDir;
|
|
2152
|
+
}
|
|
2153
|
+
const parentDir = path.dirname(currentDir);
|
|
2154
|
+
if (parentDir === currentDir) {
|
|
2155
|
+
return null;
|
|
2156
|
+
}
|
|
2157
|
+
currentDir = parentDir;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
function readPackageJson(packageRoot) {
|
|
2161
|
+
if (!packageRoot) {
|
|
2162
|
+
return null;
|
|
2163
|
+
}
|
|
2164
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
2165
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
2166
|
+
return null;
|
|
2167
|
+
}
|
|
2168
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
2169
|
+
}
|
|
2146
2170
|
function olovaPlugin() {
|
|
2147
2171
|
let config;
|
|
2148
2172
|
const cssCache = /* @__PURE__ */ new Map();
|
|
2149
2173
|
const pluginDir = path.dirname(fileURLToPath(import.meta.url));
|
|
2150
|
-
const
|
|
2174
|
+
const packageRoot = findPackageRoot(pluginDir);
|
|
2175
|
+
const packageJson = readPackageJson(packageRoot);
|
|
2176
|
+
const resolvePackageEntry = (exportKey, relativePath) => {
|
|
2177
|
+
const exportEntry = packageJson?.exports?.[exportKey];
|
|
2178
|
+
const publishedPath = typeof exportEntry === "string" ? exportEntry : exportEntry?.import ?? exportEntry?.default;
|
|
2179
|
+
if (packageRoot && publishedPath) {
|
|
2180
|
+
const publishedCandidate = path.resolve(packageRoot, publishedPath);
|
|
2181
|
+
if (fs.existsSync(publishedCandidate)) {
|
|
2182
|
+
return normalizePath(publishedCandidate);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2151
2185
|
const candidates = [
|
|
2152
2186
|
path.resolve(pluginDir, relativePath),
|
|
2153
2187
|
path.resolve(pluginDir, relativePath.replace(/\.ts$/, ".js"))
|
|
@@ -2159,9 +2193,9 @@ function olovaPlugin() {
|
|
|
2159
2193
|
}
|
|
2160
2194
|
return normalizePath(candidates[0]);
|
|
2161
2195
|
};
|
|
2162
|
-
const runtimeEntry = resolvePackageEntry("../runtime/index.ts");
|
|
2163
|
-
const coreEntry = resolvePackageEntry("../core/index.ts");
|
|
2164
|
-
const globalEntry = resolvePackageEntry("../runtime/global.ts");
|
|
2196
|
+
const runtimeEntry = resolvePackageEntry("./runtime", "../runtime/index.ts");
|
|
2197
|
+
const coreEntry = resolvePackageEntry("./core", "../core/index.ts");
|
|
2198
|
+
const globalEntry = resolvePackageEntry("./global", "../runtime/global.ts");
|
|
2165
2199
|
const shouldRewriteRuntimeScript = (id, code) => {
|
|
2166
2200
|
if (id.includes("/node_modules/") || id.endsWith(".d.ts")) {
|
|
2167
2201
|
return false;
|