unrun 0.2.13 → 0.2.15

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.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as unrunCli, r as unrunSync, t as unrun } from "./src-BMOFH46e.mjs";
1
+ import { n as unrunCli, r as unrunSync, t as unrun } from "./src-Cy584dFT.mjs";
2
2
 
3
3
  export { unrun, unrunCli, unrunSync };
@@ -112,14 +112,17 @@ function isPathWithinDirectory(parent, child) {
112
112
  */
113
113
  function createExternalResolver(options) {
114
114
  const entryDir = path.dirname(options.path);
115
- const entryRequire = createRequire(options.path);
116
115
  const canResolveFromEntry = (specifier) => {
117
- try {
118
- entryRequire.resolve(specifier);
119
- return true;
120
- } catch {
121
- return false;
116
+ const packageName = getPackageName(specifier);
117
+ if (!packageName) return false;
118
+ let currentDir = entryDir;
119
+ while (true) {
120
+ if (existsSync(path.join(currentDir, "node_modules", packageName))) return true;
121
+ const parentDir = path.dirname(currentDir);
122
+ if (parentDir === currentDir) break;
123
+ currentDir = parentDir;
122
124
  }
125
+ return false;
123
126
  };
124
127
  return function external(id, importer) {
125
128
  if (!id || id.startsWith("\0")) return false;
@@ -133,11 +136,21 @@ function createExternalResolver(options) {
133
136
  const ownerInsideEntry = isPathWithinDirectory(entryDir, ownerDir);
134
137
  const entryInsideOwner = isPathWithinDirectory(ownerDir, entryDir);
135
138
  if (ownerInsideEntry && !entryInsideOwner) return false;
136
- if (!canResolveFromEntry(id)) return false;
137
139
  } catch {}
140
+ if (!canResolveFromEntry(id)) return false;
138
141
  return true;
139
142
  };
140
143
  }
144
+ function getPackageName(specifier) {
145
+ if (!specifier) return void 0;
146
+ if (specifier.startsWith("@")) {
147
+ const segments = specifier.split("/");
148
+ if (segments.length >= 2) return `${segments[0]}/${segments[1]}`;
149
+ return;
150
+ }
151
+ const [name] = specifier.split("/");
152
+ return name || void 0;
153
+ }
141
154
  function findContainingNodeModules(filePath) {
142
155
  let current = path.dirname(filePath);
143
156
  const { root } = path.parse(current);
@@ -524,6 +537,7 @@ async function bundle(options) {
524
537
  "import.meta.dirname": JSON.stringify(path.dirname(options.path)),
525
538
  "import.meta.env": "process.env"
526
539
  } },
540
+ logLevel: "silent",
527
541
  ...options.inputOptions
528
542
  };
529
543
  if (tsconfig) inputOptions.tsconfig = tsconfig;
@@ -1,4 +1,4 @@
1
- import { t as unrun } from "../src-BMOFH46e.mjs";
1
+ import { t as unrun } from "../src-Cy584dFT.mjs";
2
2
  import { runAsWorker } from "synckit";
3
3
 
4
4
  //#region src/sync/worker.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unrun",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "A tool to load and execute any JavaScript or TypeScript code at runtime.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,10 +43,12 @@
43
43
  "rolldown": "1.0.0-beta.52"
44
44
  },
45
45
  "devDependencies": {
46
- "@prettier/plugin-oxc": "^0.1.1",
47
46
  "@sxzz/eslint-config": "^7.3.2",
48
- "@sxzz/prettier-config": "^2.2.5",
47
+ "@sxzz/prettier-config": "^2.2.6",
49
48
  "@types/node": "^24.10.1",
49
+ "@vitest/browser": "4.0.14",
50
+ "@vitest/browser-playwright": "^4.0.14",
51
+ "@webcontainer/api": "^1.6.1",
50
52
  "acorn": "^8.15.0",
51
53
  "bumpp": "^10.3.2",
52
54
  "bundle-require": "^5.1.0",
@@ -65,6 +67,7 @@
65
67
  "mime": "^4.1.0",
66
68
  "moment-timezone": "^0.6.0",
67
69
  "nano-jsx": "^0.2.1",
70
+ "playwright": "^1.57.0",
68
71
  "preact": "^10.27.2",
69
72
  "preact-render-to-string": "^6.6.3",
70
73
  "prettier": "^3.7.1",
@@ -74,7 +77,7 @@
74
77
  "synckit": "^0.11.11",
75
78
  "test-ecosystem-ci": "^0.0.1",
76
79
  "tinyexec": "^1.0.2",
77
- "tsdown": "^0.16.7",
80
+ "tsdown": "^0.16.8",
78
81
  "tsx": "^4.20.6",
79
82
  "typedoc": "^0.28.14",
80
83
  "typedoc-plugin-markdown": "^4.9.0",
@@ -85,7 +88,7 @@
85
88
  "vite": "^7.2.4",
86
89
  "vitepress": "2.0.0-alpha.12",
87
90
  "vitepress-plugin-group-icons": "^1.6.5",
88
- "vitest": "4.0.8",
91
+ "vitest": "4.0.14",
89
92
  "vue": "^3.5.25",
90
93
  "vue-tsc": "^3.1.5",
91
94
  "zod": "^4.1.13"
@@ -99,10 +102,12 @@
99
102
  "lint:fix": "pnpm run lint --fix",
100
103
  "build": "tsdown",
101
104
  "dev": "tsdown --watch",
102
- "pretest": "node ./scripts/manage-pnpm-override.mjs add",
105
+ "pretest": "pnpm run build && node ./scripts/manage-pnpm-override.mjs add",
103
106
  "test": "vitest",
107
+ "pretest:browser": "pnpm run build",
108
+ "test:browser": "vitest run --browser --config vitest.browser.config.ts",
104
109
  "posttest": "node ./scripts/manage-pnpm-override.mjs remove",
105
- "pretest:run": "node ./scripts/manage-pnpm-override.mjs add",
110
+ "pretest:run": "pnpm run build && node ./scripts/manage-pnpm-override.mjs add",
106
111
  "test:run": "vitest run",
107
112
  "posttest:run": "node ./scripts/manage-pnpm-override.mjs remove",
108
113
  "ecosystem-ci": "ecosystem-ci",