one
Version:
One is a new React Framework that makes Vite serve both native and web.
32 lines (30 loc) • 1.36 kB
JavaScript
import { existsSync, readFileSync } from "fs";
import { fileURLToPath, URL } from "url";
import { describe, expect, test } from "vitest";
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
var packageDirectory = fileURLToPath(new URL("../", import.meta.url));
function collectExportTargets(value) {
if (typeof value === "string") {
return value.includes("*") ? [] : [value];
}
if (!value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object" || Array.isArray(value)) {
return [];
}
return Object.values(value).flatMap(collectExportTargets);
}
describe("package exports", function () {
test("all concrete targets exist in the built package", function () {
var packageJson = JSON.parse(readFileSync(`${packageDirectory}/package.json`, "utf8"));
if (!packageJson || (typeof packageJson === "undefined" ? "undefined" : _type_of(packageJson)) !== "object" || !("exports" in packageJson)) {
throw new Error("one package.json must define exports");
}
var missing = collectExportTargets(packageJson.exports).filter(function (target) {
return !existsSync(`${packageDirectory}/${target}`);
});
expect(missing).toEqual([]);
});
});
//# sourceMappingURL=package-exports.test.native.js.map