revojs 0.2.60 → 0.2.61

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.
@@ -86,6 +86,7 @@ export declare function posixPath(path: string): string;
86
86
  export declare function resolvePattern(pattern: string, cwd?: string): string[];
87
87
  export declare function resolvePaths(patterns: string | ArrayLike<string>, cwd?: string): string[];
88
88
  export declare function matchesConsumer(path: string, consumer: Consumer): boolean;
89
+ export declare function findPackageManifest(from: string, name?: string): string | undefined;
89
90
  export declare function resolveFrameworkPackages(root: string): string[];
90
91
  export declare function resolveSource(source: Source): Map<string, Map<string, string>>;
91
92
  export declare function useModule(source: string | URL): {
@@ -1,12 +1,10 @@
1
1
  import { mimeType } from "../assets/index.js";
2
2
  import { mergeObjects, toExportNames } from "../shared/index.js";
3
3
  import package_default from "../package.js";
4
- import { findPackageJSON } from "node:module";
5
4
  import { spawnSync } from "child_process";
6
5
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
7
6
  import { createRequire } from "module";
8
7
  import { globSync } from "node:fs";
9
- import { pathToFileURL } from "node:url";
10
8
  import { dirname, extname, isAbsolute, join, posix, relative, resolve, win32 } from "path";
11
9
  import { fileURLToPath } from "url";
12
10
  import "vite";
@@ -55,6 +53,17 @@ function matchesConsumer(path, consumer) {
55
53
  const marker = /\.(client|server)\.[^./]+$/.exec(path)?.[1];
56
54
  return marker === void 0 || marker === consumer;
57
55
  }
56
+ function findPackageManifest(from, name) {
57
+ let directory = from;
58
+ while (true) {
59
+ let path = join(directory, "package.json");
60
+ if (name !== void 0) path = join(directory, "node_modules", name, "package.json");
61
+ if (existsSync(path)) return path;
62
+ const parent = dirname(directory);
63
+ if (parent === directory) return;
64
+ directory = parent;
65
+ }
66
+ }
58
67
  function resolveFrameworkPackages(root) {
59
68
  const packages = /* @__PURE__ */ new Set();
60
69
  const checked = /* @__PURE__ */ new Set();
@@ -75,12 +84,7 @@ function resolveFrameworkPackages(root) {
75
84
  for (const dependencies of groups) for (const name in dependencies) {
76
85
  if (checked.has(name)) continue;
77
86
  checked.add(name);
78
- let dependencyPath;
79
- try {
80
- dependencyPath = findPackageJSON(name, pathToFileURL(path).href);
81
- } catch {
82
- continue;
83
- }
87
+ const dependencyPath = findPackageManifest(dirname(path), name);
84
88
  if (dependencyPath === void 0) continue;
85
89
  const dependency = JSON.parse(readFileSync(dependencyPath, "utf8"));
86
90
  if (name === package_default.name || dependency.dependencies?.[package_default.name] !== void 0 || dependency.peerDependencies?.[package_default.name] !== void 0) {
@@ -99,7 +103,7 @@ function resolveSource(source) {
99
103
  if (paths.length === 0) continue;
100
104
  let scope = PACKAGE_CACHE.get(from);
101
105
  if (scope === void 0) {
102
- const path = findPackageJSON(pathToFileURL(from).href);
106
+ const path = findPackageManifest(dirname(from));
103
107
  if (path === void 0) throw new Error(`Unable to resolve package.json for ${from}`);
104
108
  const manifest = JSON.parse(readFileSync(path, "utf8"));
105
109
  if (typeof manifest.name !== "string" || manifest.name.length === 0) throw new Error(`Missing "name" field in ${path}`);
@@ -397,4 +401,4 @@ async function revojs(inputConfig) {
397
401
  }
398
402
  var PACKAGE_CACHE = /* @__PURE__ */ new Map();
399
403
  //#endregion
400
- export { addTemplate, addTypes, addVirtual, core, createConfig, defineModule, matchesConsumer, module, posixPath, resolveFrameworkPackages, resolvePaths, resolvePattern, resolveSource, revojs, useModule };
404
+ export { addTemplate, addTypes, addVirtual, core, createConfig, defineModule, findPackageManifest, matchesConsumer, module, posixPath, resolveFrameworkPackages, resolvePaths, resolvePattern, resolveSource, revojs, useModule };
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "revojs";
3
- var version = "0.2.60";
3
+ var version = "0.2.61";
4
4
  var repository = {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/tellua/revojs.git"
@@ -32,7 +32,7 @@ var exports = {
32
32
  var scripts = {
33
33
  "build": "vite build",
34
34
  "test": "node --test tests/*.test.mjs",
35
- "typecheck": "tsc --noEmit -p tsconfig.json",
35
+ "typecheck": "bun check",
36
36
  "watch": "vite build --watch"
37
37
  };
38
38
  var dependencies = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.2.60",
3
+ "version": "0.2.61",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "scripts": {
40
40
  "build": "vite build",
41
41
  "test": "node --test tests/*.test.mjs",
42
- "typecheck": "tsc --noEmit -p tsconfig.json",
42
+ "typecheck": "bun check",
43
43
  "watch": "vite build --watch"
44
44
  },
45
45
  "dependencies": {