@zenithbuild/bundler 0.6.7 → 0.6.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zenith Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ export interface BundlerPlatformPackage {
2
+ packageName: string;
3
+ binaryName: string;
4
+ os: NodeJS.Platform;
5
+ arch: string;
6
+ }
7
+ export declare function getBundlerPlatformPackage(platform?: NodeJS.Platform, arch?: string): BundlerPlatformPackage | null;
8
+ export declare function resolveBundlerPlatformPackageRoot(projectRoot?: string | null): string | null;
9
+ export declare function resolveBundlerBin(projectRoot?: string | null): string | null;
10
+ export declare function resolveLegacyBundlerBin(projectRoot?: string | null): string | null;
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, resolve } from 'node:path';
4
+ const PLATFORM_PACKAGES = {
5
+ 'darwin-arm64': {
6
+ packageName: '@zenithbuild/bundler-darwin-arm64',
7
+ binaryName: 'zenith-bundler',
8
+ os: 'darwin',
9
+ arch: 'arm64'
10
+ },
11
+ 'darwin-x64': {
12
+ packageName: '@zenithbuild/bundler-darwin-x64',
13
+ binaryName: 'zenith-bundler',
14
+ os: 'darwin',
15
+ arch: 'x64'
16
+ },
17
+ 'linux-x64': {
18
+ packageName: '@zenithbuild/bundler-linux-x64',
19
+ binaryName: 'zenith-bundler',
20
+ os: 'linux',
21
+ arch: 'x64'
22
+ },
23
+ 'win32-x64': {
24
+ packageName: '@zenithbuild/bundler-win32-x64',
25
+ binaryName: 'zenith-bundler.exe',
26
+ os: 'win32',
27
+ arch: 'x64'
28
+ }
29
+ };
30
+ function safeCreateRequire(projectRoot) {
31
+ if (!projectRoot) {
32
+ return createRequire(import.meta.url);
33
+ }
34
+ try {
35
+ return createRequire(resolve(projectRoot, 'package.json'));
36
+ }
37
+ catch {
38
+ return createRequire(import.meta.url);
39
+ }
40
+ }
41
+ function safeResolvePackageRoot(packageName, projectRoot) {
42
+ const requireFn = safeCreateRequire(projectRoot);
43
+ try {
44
+ return dirname(requireFn.resolve(`${packageName}/package.json`));
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
50
+ export function getBundlerPlatformPackage(platform = process.platform, arch = process.arch) {
51
+ return PLATFORM_PACKAGES[`${platform}-${arch}`] || null;
52
+ }
53
+ export function resolveBundlerPlatformPackageRoot(projectRoot) {
54
+ const platformPackage = getBundlerPlatformPackage();
55
+ if (!platformPackage) {
56
+ return null;
57
+ }
58
+ return safeResolvePackageRoot(platformPackage.packageName, projectRoot);
59
+ }
60
+ export function resolveBundlerBin(projectRoot) {
61
+ const platformPackage = getBundlerPlatformPackage();
62
+ if (!platformPackage) {
63
+ return null;
64
+ }
65
+ const packageRoot = resolveBundlerPlatformPackageRoot(projectRoot);
66
+ if (!packageRoot) {
67
+ return null;
68
+ }
69
+ const binaryPath = resolve(packageRoot, 'bin', platformPackage.binaryName);
70
+ return existsSync(binaryPath) ? binaryPath : null;
71
+ }
72
+ export function resolveLegacyBundlerBin(projectRoot) {
73
+ const packageRoot = safeResolvePackageRoot('@zenithbuild/bundler', projectRoot);
74
+ if (!packageRoot) {
75
+ return null;
76
+ }
77
+ const legacyBinary = resolve(packageRoot, 'target', 'release', process.platform === 'win32' ? 'zenith-bundler.exe' : 'zenith-bundler');
78
+ return existsSync(legacyBinary) ? legacyBinary : null;
79
+ }
package/package.json CHANGED
@@ -1,25 +1,26 @@
1
1
  {
2
2
  "name": "@zenithbuild/bundler",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "scripts": {
5
- "build": "cargo build --release",
5
+ "build": "rm -rf dist && cargo build --release && tsc -p tsconfig.meta.json && node ../../scripts/stage-bundler-platform-package.mjs",
6
6
  "contract:deps": "node dependency_contract.spec.js",
7
7
  "contract:scan": "node contract-scan.mjs",
8
8
  "contract:imports": "node --test tests/template_import_boundary.test.js",
9
9
  "prepublishOnly": "npm run build"
10
10
  },
11
11
  "devDependencies": {
12
+ "@types/node": "latest",
12
13
  "@types/bun": "latest",
13
14
  "typescript": "^5"
14
15
  },
15
- "main": "./package.json",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
16
18
  "exports": {
17
- ".": "./package.json",
19
+ ".": "./dist/index.js",
18
20
  "./package.json": "./package.json"
19
21
  },
20
22
  "files": [
21
- "target/release/zenith-bundler",
22
- "scripts",
23
+ "dist",
23
24
  "package.json",
24
25
  "README.md",
25
26
  "LICENSE"
@@ -34,13 +35,14 @@
34
35
  },
35
36
  "homepage": "https://github.com/zenithbuild/framework#readme",
36
37
  "dependencies": {
37
- "@zenithbuild/router": "0.6.7",
38
- "@zenithbuild/runtime": "0.6.7",
39
- "chokidar": "^5.0.0",
40
- "esbuild": "^0.27.3",
41
- "express": "^4.21.2",
42
- "rolldown": "^1.0.0-rc.3",
43
- "ws": "^8.19.0"
38
+ "@zenithbuild/router": "0.6.9",
39
+ "@zenithbuild/runtime": "0.6.9"
40
+ },
41
+ "optionalDependencies": {
42
+ "@zenithbuild/bundler-darwin-arm64": "0.6.9",
43
+ "@zenithbuild/bundler-darwin-x64": "0.6.9",
44
+ "@zenithbuild/bundler-linux-x64": "0.6.9",
45
+ "@zenithbuild/bundler-win32-x64": "0.6.9"
44
46
  },
45
47
  "type": "module",
46
48
  "private": false
@@ -1,55 +0,0 @@
1
- import { runtimeModuleSource } from '@zenithbuild/runtime/template';
2
- import { renderRouterModule } from '@zenithbuild/router/template';
3
-
4
- const IR_VERSION = 1;
5
-
6
- function normalizeNewlines(value) {
7
- return String(value).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
8
- }
9
-
10
- async function readStdin() {
11
- let data = '';
12
- for await (const chunk of process.stdin) {
13
- data += chunk;
14
- }
15
- return data;
16
- }
17
-
18
- async function main() {
19
- const rawInput = await readStdin();
20
- const parsed = rawInput.trim().length > 0 ? JSON.parse(rawInput) : {};
21
-
22
- const manifestJson = typeof parsed.manifestJson === 'string'
23
- ? normalizeNewlines(parsed.manifestJson)
24
- : '{}';
25
- const runtimeImport = typeof parsed.runtimeImport === 'string' && parsed.runtimeImport.length > 0
26
- ? parsed.runtimeImport
27
- : '/assets/runtime.placeholder.js';
28
- const coreImport = typeof parsed.coreImport === 'string' && parsed.coreImport.length > 0
29
- ? parsed.coreImport
30
- : '/assets/core.placeholder.js';
31
-
32
- const runtimeSource = normalizeNewlines(runtimeModuleSource());
33
- const routerSource = normalizeNewlines(
34
- renderRouterModule({
35
- manifestJson,
36
- runtimeImport,
37
- coreImport
38
- })
39
- );
40
-
41
- // Keep output key order deterministic.
42
- const output = {
43
- irVersion: IR_VERSION,
44
- runtimeSource,
45
- routerSource
46
- };
47
-
48
- process.stdout.write(JSON.stringify(output));
49
- }
50
-
51
- main().catch((error) => {
52
- const message = error instanceof Error ? error.stack || error.message : String(error);
53
- process.stderr.write(`[render-assets] ${message}\n`);
54
- process.exit(1);
55
- });
Binary file