@vmz/vmz 0.2.2 → 0.2.4
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/cli/cli.js +1 -2
- package/dist/workspace/pack-client-packages.js +39 -13
- package/package.json +14 -14
package/dist/cli/cli.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Node CLI command implementations .
|
|
3
3
|
*/
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import { existsSync } from 'node:fs';
|
|
6
5
|
import path from 'node:path';
|
|
7
6
|
import { createCli } from '@vmz/commander';
|
|
8
7
|
import { registerApplicationCommands } from './application-cmd.js';
|
|
@@ -358,7 +357,7 @@ async function cmdServe(args) {
|
|
|
358
357
|
}
|
|
359
358
|
const outDir = resolveProfileArtifactDir(outDirRoot, selected.profile);
|
|
360
359
|
const hostJs = path.join(outDir, 'vmz-serve-host.mjs');
|
|
361
|
-
|
|
360
|
+
{
|
|
362
361
|
try {
|
|
363
362
|
materializeServeHostRuntime(outDir);
|
|
364
363
|
log.info(`materialized ${hostJs} from @vmz/core (release builds omit it)`);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Not full oxc chunk-split/minify (`oxc-pending` remains for release minify).
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
14
|
import { resolvePackageRoot } from './packages.js';
|
|
@@ -29,15 +29,15 @@ export function packClientBareImports(outDir, opts = {}) {
|
|
|
29
29
|
const skippedVmz = [];
|
|
30
30
|
for (const file of listClientJs(outDir)) {
|
|
31
31
|
for (const spec of collectBareSpecs(readFileSync(file, 'utf8'))) {
|
|
32
|
-
|
|
33
|
-
bareQueue.push(spec);
|
|
32
|
+
bareQueue.push({ spec: String(spec), from: file });
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
while (bareQueue.length) {
|
|
37
|
-
const
|
|
36
|
+
const item = bareQueue.shift();
|
|
37
|
+
const { spec } = item;
|
|
38
38
|
if (bareToVendor.has(spec))
|
|
39
39
|
continue;
|
|
40
|
-
const resolved = resolveBareToSource(projectRoot, spec);
|
|
40
|
+
const resolved = resolveBareToSource(projectRoot, spec, item.from);
|
|
41
41
|
if (!resolved) {
|
|
42
42
|
if (!unresolved.includes(spec))
|
|
43
43
|
unresolved.push(spec);
|
|
@@ -59,7 +59,12 @@ export function packClientBareImports(outDir, opts = {}) {
|
|
|
59
59
|
for (const file of [...listClientJs(outDir), ...listVendorJs(outDir)]) {
|
|
60
60
|
const before = readFileSync(file, 'utf8');
|
|
61
61
|
let after = rewriteBareImports(before, file, bareToVendor);
|
|
62
|
-
|
|
62
|
+
try {
|
|
63
|
+
after = rewriteRelativeTsSpecs(after);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw new Error(`pack module ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
+
}
|
|
63
68
|
if (after !== before) {
|
|
64
69
|
writeFileSync(file, after, 'utf8');
|
|
65
70
|
rewritten.push(path.relative(outDir, file).replace(/\\/g, '/'));
|
|
@@ -105,10 +110,8 @@ function materializeSourceTree(outDir, resolved, materializedSources, bareQueue)
|
|
|
105
110
|
writeFileSync(destAbs, js, 'utf8');
|
|
106
111
|
if (sourceFile === resolved.sourceFile)
|
|
107
112
|
entryDest = destAbs;
|
|
108
|
-
for (const bare of collectBareSpecs(js))
|
|
109
|
-
|
|
110
|
-
bareQueue.push(bare);
|
|
111
|
-
}
|
|
113
|
+
for (const bare of collectBareSpecs(js))
|
|
114
|
+
bareQueue.push({ spec: String(bare), from: sourceFile });
|
|
112
115
|
for (const rel of collectRelativeSpecs(js)) {
|
|
113
116
|
const target = resolveRelativeSource(path.dirname(sourceFile), rel);
|
|
114
117
|
if (target && !materializedSources.has(target))
|
|
@@ -208,9 +211,25 @@ function isRelativeOrAbsolute(spec) {
|
|
|
208
211
|
function shouldSkipBare(spec) {
|
|
209
212
|
return SKIP_PREFIXES.some((p) => spec.startsWith(p));
|
|
210
213
|
}
|
|
211
|
-
function resolveBareToSource(projectRoot, spec) {
|
|
214
|
+
function resolveBareToSource(projectRoot, spec, fromFile) {
|
|
212
215
|
const { pkgName, subpath } = splitPackageSpec(spec);
|
|
213
|
-
let pkgRoot =
|
|
216
|
+
let pkgRoot = null;
|
|
217
|
+
if (fromFile && existsSync(fromFile)) {
|
|
218
|
+
let cur = path.dirname(realpathSync(fromFile));
|
|
219
|
+
for (let i = 0; i < 12; i++) {
|
|
220
|
+
const nested = path.join(cur, 'node_modules', ...pkgName.split('/'));
|
|
221
|
+
if (existsSync(path.join(nested, 'package.json'))) {
|
|
222
|
+
pkgRoot = nested;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
const parent = path.dirname(cur);
|
|
226
|
+
if (parent === cur)
|
|
227
|
+
break;
|
|
228
|
+
cur = parent;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (!pkgRoot)
|
|
232
|
+
pkgRoot = resolvePackageRoot(projectRoot, pkgName);
|
|
214
233
|
if (!pkgRoot) {
|
|
215
234
|
let cur = projectRoot;
|
|
216
235
|
for (let i = 0; i < 8; i++) {
|
|
@@ -303,9 +322,16 @@ function packageDirName(pkgName) {
|
|
|
303
322
|
function materializeModule(sourceFile) {
|
|
304
323
|
const ext = path.extname(sourceFile).toLowerCase();
|
|
305
324
|
const raw = readFileSync(sourceFile, 'utf8');
|
|
325
|
+
if (ext === '.json')
|
|
326
|
+
return raw;
|
|
306
327
|
if (ext === '.ts' || ext === '.tsx')
|
|
307
328
|
return transpileTs(raw, sourceFile);
|
|
308
|
-
|
|
329
|
+
try {
|
|
330
|
+
return rewriteRelativeTsSpecs(raw);
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
throw new Error(`pack source ${sourceFile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
334
|
+
}
|
|
309
335
|
}
|
|
310
336
|
function transpileTs(source, filename) {
|
|
311
337
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vmz/vmz",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VMZ Node toolchain — N-API workspace session + CLI (publish name @vmz/vmz)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@vmz/commander": "0.2.
|
|
52
|
-
"@vmz/core": "0.2.
|
|
53
|
-
"@vmz/diagnostic": "0.2.
|
|
54
|
-
"@vmz/plugin": "0.2.
|
|
55
|
-
"@vmz/protocol": "0.2.
|
|
51
|
+
"@vmz/commander": "0.2.4",
|
|
52
|
+
"@vmz/core": "0.2.4",
|
|
53
|
+
"@vmz/diagnostic": "0.2.4",
|
|
54
|
+
"@vmz/plugin": "0.2.4",
|
|
55
|
+
"@vmz/protocol": "0.2.4",
|
|
56
56
|
"jiti": "^2.6.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@vmz/plugin-markdown-it": "0.2.
|
|
60
|
-
"@vmz/test": "0.2.
|
|
59
|
+
"@vmz/plugin-markdown-it": "0.2.4",
|
|
60
|
+
"@vmz/test": "0.2.4",
|
|
61
61
|
"typescript": "^5.8.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
"cli"
|
|
93
93
|
],
|
|
94
94
|
"optionalDependencies": {
|
|
95
|
-
"@vmz/vmz-win32-x64": "0.2.
|
|
96
|
-
"@vmz/vmz-win32-arm64": "0.2.
|
|
97
|
-
"@vmz/vmz-darwin-x64": "0.2.
|
|
98
|
-
"@vmz/vmz-darwin-arm64": "0.2.
|
|
99
|
-
"@vmz/vmz-linux-x64": "0.2.
|
|
100
|
-
"@vmz/vmz-linux-arm64": "0.2.
|
|
95
|
+
"@vmz/vmz-win32-x64": "0.2.4",
|
|
96
|
+
"@vmz/vmz-win32-arm64": "0.2.4",
|
|
97
|
+
"@vmz/vmz-darwin-x64": "0.2.4",
|
|
98
|
+
"@vmz/vmz-darwin-arm64": "0.2.4",
|
|
99
|
+
"@vmz/vmz-linux-x64": "0.2.4",
|
|
100
|
+
"@vmz/vmz-linux-arm64": "0.2.4"
|
|
101
101
|
},
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|