@swissjs/swite 0.3.0 → 0.3.1
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/adapters/proxy/SwiteProxyError.d.ts.map +1 -0
- package/dist/{proxy → adapters/proxy}/proxyToPython.d.ts +1 -1
- package/dist/adapters/proxy/proxyToPython.d.ts.map +1 -0
- package/dist/build-engine/builder.d.ts.map +1 -0
- package/dist/{builder.js → build-engine/builder.js} +8 -14
- package/dist/cli.js +5 -5
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/env.d.ts +25 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +84 -0
- package/dist/{handlers → dev-engine/handlers}/base-handler.d.ts +3 -1
- package/dist/dev-engine/handlers/base-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/base-handler.js +22 -2
- package/dist/dev-engine/handlers/js-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/js-handler.js +1 -1
- package/dist/dev-engine/handlers/mjs-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/mjs-handler.js +1 -1
- package/dist/dev-engine/handlers/node-module-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/node-module-handler.js +4 -4
- package/dist/{handlers → dev-engine/handlers}/ts-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/ts-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/ts-handler.js +5 -28
- package/dist/{handlers → dev-engine/handlers}/ui-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/ui-handler.d.ts.map +1 -0
- package/dist/dev-engine/handlers/ui-handler.js +84 -0
- package/dist/{handlers → dev-engine/handlers}/uix-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/uix-handler.d.ts.map +1 -0
- package/dist/dev-engine/handlers/uix-handler.js +70 -0
- package/dist/dev-engine/hmr/hmr-client-template.d.ts +10 -0
- package/dist/dev-engine/hmr/hmr-client-template.d.ts.map +1 -0
- package/dist/dev-engine/hmr/hmr-client-template.js +122 -0
- package/dist/dev-engine/hmr/hmr.d.ts.map +1 -0
- package/dist/{hmr.js → dev-engine/hmr/hmr.js} +2 -134
- package/dist/{middleware → dev-engine/middleware}/hmr-routes.d.ts +2 -2
- package/dist/dev-engine/middleware/hmr-routes.d.ts.map +1 -0
- package/dist/{middleware → dev-engine/middleware}/hmr-routes.js +1 -1
- package/dist/dev-engine/middleware/middleware-setup.d.ts +34 -0
- package/dist/dev-engine/middleware/middleware-setup.d.ts.map +1 -0
- package/dist/dev-engine/middleware/middleware-setup.js +327 -0
- package/dist/dev-engine/middleware/static-files.d.ts.map +1 -0
- package/dist/{middleware → dev-engine/middleware}/static-files.js +2 -2
- package/dist/{dev → dev-engine}/pythonDevManager.d.ts +1 -1
- package/dist/dev-engine/pythonDevManager.d.ts.map +1 -0
- package/dist/{dev → dev-engine}/pythonDevManager.js +1 -1
- package/dist/{router → dev-engine/router}/file-router.d.ts +4 -4
- package/dist/dev-engine/router/file-router.d.ts.map +1 -0
- package/dist/{router → dev-engine/router}/file-router.js +4 -4
- package/dist/dev-engine/server.d.ts.map +1 -0
- package/dist/{server.js → dev-engine/server.js} +6 -6
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/internal/cache/compilation-cache.d.ts.map +1 -0
- package/dist/{cache → internal/cache}/compilation-cache.js +3 -2
- package/dist/internal/generate-import-map-cli.d.ts.map +1 -0
- package/dist/{utils → internal}/generate-import-map-cli.js +1 -1
- package/dist/internal/generate-import-map.d.ts.map +1 -0
- package/dist/{utils → internal}/generate-import-map.js +3 -3
- package/dist/{utils → kernel}/package-finder.d.ts +3 -1
- package/dist/kernel/package-finder.d.ts.map +1 -0
- package/dist/{utils → kernel}/package-finder.js +29 -52
- package/dist/kernel/package-registry.d.ts.map +1 -0
- package/dist/kernel/workspace.d.ts.map +1 -0
- package/dist/{resolver → resolution}/bare-import-resolver.d.ts +1 -1
- package/dist/resolution/bare-import-resolver.d.ts.map +1 -0
- package/dist/{resolver → resolution}/bare-import-resolver.js +12 -49
- package/dist/resolution/cdn/cdn-fallback.d.ts.map +1 -0
- package/dist/resolution/path/file-path-resolver.d.ts.map +1 -0
- package/dist/{utils → resolution/path}/file-path-resolver.js +11 -20
- package/dist/resolution/path/path-fixup.d.ts +13 -0
- package/dist/resolution/path/path-fixup.d.ts.map +1 -0
- package/dist/resolution/path/path-fixup.js +20 -0
- package/dist/{resolver.d.ts → resolution/resolver.d.ts} +1 -1
- package/dist/resolution/resolver.d.ts.map +1 -0
- package/dist/{resolver.js → resolution/resolver.js} +8 -37
- package/dist/{import-rewriter.d.ts → resolution/rewriting/import-rewriter.d.ts} +1 -1
- package/dist/resolution/rewriting/import-rewriter.d.ts.map +1 -0
- package/dist/resolution/rewriting/import-rewriter.js +199 -0
- package/dist/{resolver → resolution}/symlink-registry.d.ts +1 -1
- package/dist/resolution/symlink-registry.d.ts.map +1 -0
- package/dist/{resolver → resolution}/symlink-registry.js +1 -1
- package/dist/resolution/url-resolver.d.ts.map +1 -0
- package/dist/{resolver → resolution}/url-resolver.js +38 -109
- package/dist/resolution/workspace-package-resolver.d.ts.map +1 -0
- package/dist/resolution/workspace-package-resolver.js +77 -0
- package/package.json +24 -15
- package/src/cli.ts +1 -1
- package/src/resolution/url-resolver.ts +1 -1
- package/dist/builder.d.ts.map +0 -1
- package/dist/cache/compilation-cache.d.ts.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/dev/pythonDevManager.d.ts.map +0 -1
- package/dist/env.d.ts +0 -19
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -112
- package/dist/handlers/base-handler.d.ts.map +0 -1
- package/dist/handlers/js-handler.d.ts.map +0 -1
- package/dist/handlers/mjs-handler.d.ts.map +0 -1
- package/dist/handlers/node-module-handler.d.ts.map +0 -1
- package/dist/handlers/ts-handler.d.ts.map +0 -1
- package/dist/handlers/ui-handler.d.ts.map +0 -1
- package/dist/handlers/ui-handler.js +0 -182
- package/dist/handlers/uix-handler.d.ts.map +0 -1
- package/dist/handlers/uix-handler.js +0 -135
- package/dist/hmr.d.ts.map +0 -1
- package/dist/import-rewriter.d.ts.map +0 -1
- package/dist/import-rewriter.js +0 -351
- package/dist/middleware/hmr-routes.d.ts.map +0 -1
- package/dist/middleware/middleware-setup.d.ts +0 -23
- package/dist/middleware/middleware-setup.d.ts.map +0 -1
- package/dist/middleware/middleware-setup.js +0 -596
- package/dist/middleware/static-files.d.ts.map +0 -1
- package/dist/proxy/SwiteProxyError.d.ts.map +0 -1
- package/dist/proxy/proxyToPython.d.ts.map +0 -1
- package/dist/resolver/bare-import-resolver.d.ts.map +0 -1
- package/dist/resolver/symlink-registry.d.ts.map +0 -1
- package/dist/resolver/url-resolver.d.ts.map +0 -1
- package/dist/resolver/workspace-package-resolver.d.ts.map +0 -1
- package/dist/resolver/workspace-package-resolver.js +0 -185
- package/dist/resolver.d.ts.map +0 -1
- package/dist/router/file-router.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/utils/cdn-fallback.d.ts.map +0 -1
- package/dist/utils/file-path-resolver.d.ts.map +0 -1
- package/dist/utils/generate-import-map-cli.d.ts.map +0 -1
- package/dist/utils/generate-import-map.d.ts.map +0 -1
- package/dist/utils/package-finder.d.ts.map +0 -1
- package/dist/utils/package-registry.d.ts.map +0 -1
- package/dist/utils/workspace.d.ts.map +0 -1
- /package/dist/{proxy → adapters/proxy}/SwiteProxyError.d.ts +0 -0
- /package/dist/{proxy → adapters/proxy}/SwiteProxyError.js +0 -0
- /package/dist/{proxy → adapters/proxy}/proxyToPython.js +0 -0
- /package/dist/{builder.d.ts → build-engine/builder.d.ts} +0 -0
- /package/dist/{config-loader.d.ts → config/config-loader.d.ts} +0 -0
- /package/dist/{config-loader.js → config/config-loader.js} +0 -0
- /package/dist/{config.d.ts → config/config.d.ts} +0 -0
- /package/dist/{config.js → config/config.js} +0 -0
- /package/dist/{handlers → dev-engine/handlers}/js-handler.d.ts +0 -0
- /package/dist/{handlers → dev-engine/handlers}/mjs-handler.d.ts +0 -0
- /package/dist/{handlers → dev-engine/handlers}/node-module-handler.d.ts +0 -0
- /package/dist/{hmr.d.ts → dev-engine/hmr/hmr.d.ts} +0 -0
- /package/dist/{middleware → dev-engine/middleware}/static-files.d.ts +0 -0
- /package/dist/{server.d.ts → dev-engine/server.d.ts} +0 -0
- /package/dist/{cache → internal/cache}/compilation-cache.d.ts +0 -0
- /package/dist/{utils → internal}/generate-import-map-cli.d.ts +0 -0
- /package/dist/{utils → internal}/generate-import-map.d.ts +0 -0
- /package/dist/{utils → kernel}/package-registry.d.ts +0 -0
- /package/dist/{utils → kernel}/package-registry.js +0 -0
- /package/dist/{utils → kernel}/workspace.d.ts +0 -0
- /package/dist/{utils → kernel}/workspace.js +0 -0
- /package/dist/{utils → resolution/cdn}/cdn-fallback.d.ts +0 -0
- /package/dist/{utils → resolution/cdn}/cdn-fallback.js +0 -0
- /package/dist/{utils → resolution/path}/file-path-resolver.d.ts +0 -0
- /package/dist/{resolver → resolution}/url-resolver.d.ts +0 -0
- /package/dist/{resolver → resolution}/workspace-package-resolver.d.ts +0 -0
|
@@ -7,7 +7,7 @@ import express from "express";
|
|
|
7
7
|
import { promises as fs, realpathSync, existsSync } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import chalk from "chalk";
|
|
10
|
-
import { findWorkspaceRoot } from "
|
|
10
|
+
import { findWorkspaceRoot } from "../../kernel/workspace.js";
|
|
11
11
|
/**
|
|
12
12
|
* Setup static file serving for public directory, node_modules, and workspace packages
|
|
13
13
|
*/
|
|
@@ -86,7 +86,7 @@ export async function setupStaticFiles(app, config) {
|
|
|
86
86
|
return next();
|
|
87
87
|
}
|
|
88
88
|
// Strip leading slash: req.path inside app.use('/node_modules') is already
|
|
89
|
-
// relative to that prefix, e.g. '/@
|
|
89
|
+
// relative to that prefix, e.g. '/@swissjs/shell/design-tokens/primitive.css'
|
|
90
90
|
const relPath = req.path.replace(/^\/+/, "");
|
|
91
91
|
if (!relPath)
|
|
92
92
|
return next();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonDevManager.d.ts","sourceRoot":"","sources":["../../src/dev-engine/pythonDevManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ/D;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAuCf;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAM3C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { initPythonProxy } from "../proxy/proxyToPython.js";
|
|
4
|
+
import { initPythonProxy } from "../adapters/proxy/proxyToPython.js";
|
|
5
5
|
const POLL_INTERVAL_MS = 500;
|
|
6
6
|
const HEALTH_TIMEOUT_MS = 15000;
|
|
7
7
|
const BACKOFF_THRESHOLD = 5;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RouteDefinition } from "@
|
|
2
|
-
import { RouteScanner } from "@
|
|
3
|
-
import { createFileWatcher } from "@
|
|
4
|
-
import { HMREngine } from "../hmr.js";
|
|
1
|
+
import type { RouteDefinition } from "@swissjs/core";
|
|
2
|
+
import { RouteScanner } from "@swissjs/plugin-file-router/core";
|
|
3
|
+
import { createFileWatcher } from "@swissjs/plugin-file-router/dev";
|
|
4
|
+
import { HMREngine } from "../hmr/hmr.js";
|
|
5
5
|
export interface FileRouterConfig {
|
|
6
6
|
root: string;
|
|
7
7
|
hmr: HMREngine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-router.d.ts","sourceRoot":"","sources":["../../../src/dev-engine/router/file-router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAmI3B"}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { promises as fs } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import chalk from "chalk";
|
|
9
|
-
import { RouteScanner } from "@
|
|
10
|
-
import { createFileWatcher } from "@
|
|
11
|
-
import { HMREngine } from "../hmr.js";
|
|
12
|
-
import { findWorkspaceRoot } from "
|
|
9
|
+
import { RouteScanner } from "@swissjs/plugin-file-router/core";
|
|
10
|
+
import { createFileWatcher } from "@swissjs/plugin-file-router/dev";
|
|
11
|
+
import { HMREngine } from "../hmr/hmr.js";
|
|
12
|
+
import { findWorkspaceRoot } from "../../kernel/workspace.js";
|
|
13
13
|
/**
|
|
14
14
|
* Setup file-based routing
|
|
15
15
|
* Scans for route files in pages/ directories and watches for changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dev-engine/server.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IAKb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,YAAY,CACb;IACP,OAAO,CAAC,MAAM,CAAyB;gBAE3B,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM;YAe/B,iBAAiB;IAuBzB,KAAK;CAsEZ"}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* SWITE - SWISS Development Server
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { RouteScanner } from "@
|
|
7
|
-
import { createFileWatcher } from "@
|
|
6
|
+
import { RouteScanner } from "@swissjs/plugin-file-router/core";
|
|
7
|
+
import { createFileWatcher } from "@swissjs/plugin-file-router/dev";
|
|
8
8
|
import express from "express";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { promises as fs } from "node:fs";
|
|
11
|
-
import { ModuleResolver } from "
|
|
12
|
-
import { HMREngine } from "./hmr.js";
|
|
11
|
+
import { ModuleResolver } from "../resolution/resolver.js";
|
|
12
|
+
import { HMREngine } from "./hmr/hmr.js";
|
|
13
13
|
import chalk from "chalk";
|
|
14
14
|
import { setupMiddleware } from "./middleware/middleware-setup.js";
|
|
15
|
-
import { buildSymlinkRegistry } from "
|
|
16
|
-
import { findSwissLibMonorepo } from "
|
|
15
|
+
import { buildSymlinkRegistry } from "../resolution/symlink-registry.js";
|
|
16
|
+
import { findSwissLibMonorepo } from "../kernel/package-finder.js";
|
|
17
17
|
export class SwiteServer {
|
|
18
18
|
constructor(config = {}) {
|
|
19
19
|
this.app = express();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { SwiteServer } from "./server.js";
|
|
2
|
-
export type { SwiteConfig } from "./server.js";
|
|
3
|
-
export { SwiteBuilder, build } from "./builder.js";
|
|
4
|
-
export type { BuildConfig } from "./builder.js";
|
|
5
|
-
export { ModuleResolver } from "./resolver.js";
|
|
6
|
-
export { HMREngine } from "./hmr.js";
|
|
7
|
-
export { defineConfig } from "./config.js";
|
|
8
|
-
export type { SwiteUserConfig, ServerConfig, ServicesConfig, PythonServiceConfig, } from "./config.js";
|
|
9
|
-
export { proxyToPython, initPythonProxy, setProductionMode } from "./proxy/proxyToPython.js";
|
|
10
|
-
export type { ProxyOptions } from "./proxy/proxyToPython.js";
|
|
11
|
-
export { SwiteProxyError } from "./proxy/SwiteProxyError.js";
|
|
12
|
-
export { loadUserConfig } from "./config-loader.js";
|
|
13
|
-
export { startPythonDevService, stopPythonDevService, } from "./dev/pythonDevManager.js";
|
|
1
|
+
export { SwiteServer } from "./dev-engine/server.js";
|
|
2
|
+
export type { SwiteConfig } from "./dev-engine/server.js";
|
|
3
|
+
export { SwiteBuilder, build } from "./build-engine/builder.js";
|
|
4
|
+
export type { BuildConfig } from "./build-engine/builder.js";
|
|
5
|
+
export { ModuleResolver } from "./resolution/resolver.js";
|
|
6
|
+
export { HMREngine } from "./dev-engine/hmr/hmr.js";
|
|
7
|
+
export { defineConfig } from "./config/config.js";
|
|
8
|
+
export type { SwiteUserConfig, ServerConfig, ServicesConfig, PythonServiceConfig, } from "./config/config.js";
|
|
9
|
+
export { proxyToPython, initPythonProxy, setProductionMode } from "./adapters/proxy/proxyToPython.js";
|
|
10
|
+
export type { ProxyOptions } from "./adapters/proxy/proxyToPython.js";
|
|
11
|
+
export { SwiteProxyError } from "./adapters/proxy/SwiteProxyError.js";
|
|
12
|
+
export { loadUserConfig } from "./config/config-loader.js";
|
|
13
|
+
export { startPythonDevService, stopPythonDevService, } from "./dev-engine/pythonDevManager.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtG,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* SWITE - SWISS Development Server
|
|
3
3
|
* Main exports
|
|
4
4
|
*/
|
|
5
|
-
export { SwiteServer } from "./server.js";
|
|
6
|
-
export { SwiteBuilder, build } from "./builder.js";
|
|
7
|
-
export { ModuleResolver } from "./resolver.js";
|
|
8
|
-
export { HMREngine } from "./hmr.js";
|
|
9
|
-
export { defineConfig } from "./config.js";
|
|
10
|
-
export { proxyToPython, initPythonProxy, setProductionMode } from "./proxy/proxyToPython.js";
|
|
11
|
-
export { SwiteProxyError } from "./proxy/SwiteProxyError.js";
|
|
12
|
-
export { loadUserConfig } from "./config-loader.js";
|
|
13
|
-
export { startPythonDevService, stopPythonDevService, } from "./dev/pythonDevManager.js";
|
|
5
|
+
export { SwiteServer } from "./dev-engine/server.js";
|
|
6
|
+
export { SwiteBuilder, build } from "./build-engine/builder.js";
|
|
7
|
+
export { ModuleResolver } from "./resolution/resolver.js";
|
|
8
|
+
export { HMREngine } from "./dev-engine/hmr/hmr.js";
|
|
9
|
+
export { defineConfig } from "./config/config.js";
|
|
10
|
+
export { proxyToPython, initPythonProxy, setProductionMode } from "./adapters/proxy/proxyToPython.js";
|
|
11
|
+
export { SwiteProxyError } from "./adapters/proxy/SwiteProxyError.js";
|
|
12
|
+
export { loadUserConfig } from "./config/config-loader.js";
|
|
13
|
+
export { startPythonDevService, stopPythonDevService, } from "./dev-engine/pythonDevManager.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilation-cache.d.ts","sourceRoot":"","sources":["../../../src/internal/cache/compilation-cache.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC;;OAEG;IACG,GAAG,CACP,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GACvD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgFzB;;OAEG;IACG,GAAG,CACP,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GACvD,OAAO,CAAC,IAAI,CAAC;IAiChB;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI7B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,QAAQ,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAM9C;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -38,10 +38,11 @@ export class CompilationCache {
|
|
|
38
38
|
this.cache.delete(filePath);
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
-
// Check if dependencies changed
|
|
41
|
+
// Check if dependencies changed (order-independent comparison)
|
|
42
42
|
const currentDeps = await getDependencies(entry.compiled);
|
|
43
|
+
const prevSet = new Set(entry.dependencies);
|
|
43
44
|
const depsChanged = currentDeps.length !== entry.dependencies.length ||
|
|
44
|
-
currentDeps.some((dep
|
|
45
|
+
currentDeps.some((dep) => !prevSet.has(dep));
|
|
45
46
|
if (depsChanged) {
|
|
46
47
|
console.log(chalk.yellow(`[Cache] Invalidating ${filePath}: dependencies changed`));
|
|
47
48
|
this.cache.delete(filePath);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-import-map-cli.d.ts","sourceRoot":"","sources":["../../src/internal/generate-import-map-cli.ts"],"names":[],"mappings":""}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Licensed under the MIT License.
|
|
7
7
|
*/
|
|
8
8
|
import { generateImportMap, saveImportMap } from "./generate-import-map.js";
|
|
9
|
-
import { findWorkspaceRoot } from "
|
|
9
|
+
import { findWorkspaceRoot } from "../kernel/workspace.js";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-import-map.d.ts","sourceRoot":"","sources":["../../src/internal/generate-import-map.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;KAC7B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B,OAAO,CAAC,SAAS,CAAC,CAkGpB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAO3B"}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { promises as fs } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
import { ModuleResolver } from "../resolver.js";
|
|
9
|
+
import { ModuleResolver } from "../resolution/resolver.js";
|
|
10
10
|
import chalk from "chalk";
|
|
11
|
-
import { getPackageRegistry } from "
|
|
12
|
-
import { findSwissLibMonorepo } from "
|
|
11
|
+
import { getPackageRegistry } from "../kernel/package-registry.js";
|
|
12
|
+
import { findSwissLibMonorepo } from "../kernel/package-finder.js";
|
|
13
13
|
/**
|
|
14
14
|
* Scan workspace and generate import map
|
|
15
15
|
* This pre-resolves all known packages to eliminate runtime scanning
|
|
@@ -7,7 +7,9 @@ export interface PackageLocation {
|
|
|
7
7
|
type: 'swiss-lib' | 'workspace' | 'node_modules';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Find
|
|
10
|
+
* Find a co-located framework monorepo by scanning sibling directories at each
|
|
11
|
+
* ancestor level for any workspace root (pnpm-workspace.yaml) that also has a
|
|
12
|
+
* packages/ directory. Works for any framework directory name.
|
|
11
13
|
*/
|
|
12
14
|
export declare function findSwissLibMonorepo(startPath: string): Promise<string | null>;
|
|
13
15
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-finder.d.ts","sourceRoot":"","sources":["../../src/kernel/package-finder.ts"],"names":[],"mappings":"AASA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,cAAc,CAAC;CAClD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+BpF;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoDjC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B7E"}
|
|
@@ -6,59 +6,36 @@
|
|
|
6
6
|
import { promises as fs } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
/**
|
|
9
|
-
* Find
|
|
9
|
+
* Find a co-located framework monorepo by scanning sibling directories at each
|
|
10
|
+
* ancestor level for any workspace root (pnpm-workspace.yaml) that also has a
|
|
11
|
+
* packages/ directory. Works for any framework directory name.
|
|
10
12
|
*/
|
|
11
13
|
export async function findSwissLibMonorepo(startPath) {
|
|
12
|
-
let current = startPath;
|
|
13
|
-
for (let i = 0; i < 20; i++) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
// Check if swiss-lib exists and has core package
|
|
20
|
-
if (await fileExists(swissLibPackageJson) || await fileExists(corePackage)) {
|
|
21
|
-
console.log(`[package-finder] Found swiss-lib at: ${swissLibPath}`);
|
|
22
|
-
return swissLibPath;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
// Continue searching
|
|
27
|
-
}
|
|
28
|
-
// Also check for legacy SWISS directory
|
|
29
|
-
const swissPath = path.join(current, "SWISS");
|
|
30
|
-
const swissPackageJson = path.join(swissPath, "package.json");
|
|
31
|
-
const swissCorePackage = path.join(swissPath, "packages", "core", "package.json");
|
|
32
|
-
try {
|
|
33
|
-
if (await fileExists(swissPackageJson) || await fileExists(swissCorePackage)) {
|
|
34
|
-
console.log(`[package-finder] Found legacy SWISS at: ${swissPath}`);
|
|
35
|
-
return swissPath;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// Continue searching
|
|
40
|
-
}
|
|
41
|
-
// Scan immediate subdirectories of `current` for a swiss-lib/ child
|
|
14
|
+
let current = path.resolve(startPath);
|
|
15
|
+
for (let i = 0; i < 20; i++) {
|
|
16
|
+
const parent = path.dirname(current);
|
|
17
|
+
if (parent === current)
|
|
18
|
+
break;
|
|
19
|
+
// Scan siblings of `current` at this parent level
|
|
42
20
|
try {
|
|
43
|
-
const entries = await fs.readdir(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
21
|
+
const entries = await fs.readdir(parent, { withFileTypes: true });
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
if (entry.name === "node_modules")
|
|
24
|
+
continue;
|
|
25
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
26
|
+
continue;
|
|
27
|
+
const sibling = path.join(parent, entry.name);
|
|
28
|
+
if (path.resolve(sibling) === path.resolve(current))
|
|
29
|
+
continue; // skip self
|
|
30
|
+
if (await fileExists(path.join(sibling, "pnpm-workspace.yaml")) &&
|
|
31
|
+
await fileExists(path.join(sibling, "packages"))) {
|
|
32
|
+
return sibling;
|
|
53
33
|
}
|
|
54
34
|
}
|
|
55
35
|
}
|
|
56
36
|
catch {
|
|
57
37
|
// Skip on permission errors
|
|
58
38
|
}
|
|
59
|
-
const parent = path.dirname(current);
|
|
60
|
-
if (parent === current)
|
|
61
|
-
break;
|
|
62
39
|
current = parent;
|
|
63
40
|
}
|
|
64
41
|
return null;
|
|
@@ -82,14 +59,14 @@ export async function findPackage(packageName, startPath, workspaceRoot) {
|
|
|
82
59
|
return { path: workspaceNodeModules, type: 'node_modules' };
|
|
83
60
|
}
|
|
84
61
|
}
|
|
85
|
-
// 3. Check
|
|
86
|
-
if (packageName.startsWith("@
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
if (await fileExists(path.join(
|
|
92
|
-
return { path:
|
|
62
|
+
// 3. Check co-located framework monorepo packages/ for any scoped package
|
|
63
|
+
if (packageName.startsWith("@")) {
|
|
64
|
+
const monorepo = await findSwissLibMonorepo(startPath);
|
|
65
|
+
if (monorepo) {
|
|
66
|
+
const shortName = packageName.split("/")[1];
|
|
67
|
+
const monorepoPackage = path.join(monorepo, "packages", shortName);
|
|
68
|
+
if (await fileExists(path.join(monorepoPackage, "package.json"))) {
|
|
69
|
+
return { path: monorepoPackage, type: 'swiss-lib' };
|
|
93
70
|
}
|
|
94
71
|
}
|
|
95
72
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-registry.d.ts","sourceRoot":"","sources":["../../src/kernel/package-registry.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAgB;IAEjC;;OAEG;IACG,aAAa,CACjB,aAAa,EAAE,MAAM,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,IAAI,CAAC;IAwChB;;OAEG;YACW,aAAa;IAmF3B;;OAEG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAIpD;;OAEG;IACH,cAAc,IAAI,WAAW,EAAE;IAI/B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAW7B;;OAEG;IACH,eAAe,IAAI,MAAM;CAG1B;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/kernel/workspace.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgD5E"}
|
|
@@ -3,7 +3,7 @@ export interface BareImportResolverContext extends UrlResolverContext {
|
|
|
3
3
|
resolveWorkspacePackage: (pkgName: string) => Promise<string | null>;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Resolve bare import specifier (e.g., @
|
|
6
|
+
* Resolve bare import specifier (e.g., @swissjs/core, react, etc.)
|
|
7
7
|
*/
|
|
8
8
|
export declare function resolveBareImport(specifier: string, context: BareImportResolverContext): Promise<string>;
|
|
9
9
|
//# sourceMappingURL=bare-import-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bare-import-resolver.d.ts","sourceRoot":"","sources":["../../src/resolution/bare-import-resolver.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAmC,MAAM,mBAAmB,CAAC;AAI7F,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACtE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAkNjB"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Bare Import Resolver - Resolves bare module specifiers (@
|
|
2
|
+
* Bare Import Resolver - Resolves bare module specifiers (@swissjs/core, etc.)
|
|
3
3
|
* Extracted from resolver.ts for modularity
|
|
4
4
|
*/
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { promises as fs } from "node:fs";
|
|
7
7
|
import chalk from "chalk";
|
|
8
|
-
import { findSwissLibMonorepo } from "../
|
|
9
|
-
import { shouldUseCdnFallback } from "
|
|
8
|
+
import { findSwissLibMonorepo } from "../kernel/package-finder.js";
|
|
9
|
+
import { shouldUseCdnFallback } from "./cdn/cdn-fallback.js";
|
|
10
10
|
import { resolveWorkspacePackage } from "./workspace-package-resolver.js";
|
|
11
11
|
import { toUrl } from "./url-resolver.js";
|
|
12
12
|
/**
|
|
13
|
-
* Resolve bare import specifier (e.g., @
|
|
13
|
+
* Resolve bare import specifier (e.g., @swissjs/core, react, etc.)
|
|
14
14
|
*/
|
|
15
15
|
export async function resolveBareImport(specifier, context) {
|
|
16
|
-
console.log(`[SWITE] resolveBareImport CALLED: ${specifier}`);
|
|
17
16
|
// Extract package name outside the try/catch so fallback logic can reference it.
|
|
18
17
|
// This must stay project-agnostic: works for both scoped and unscoped packages.
|
|
19
18
|
const parts = specifier.split("/");
|
|
@@ -21,7 +20,6 @@ export async function resolveBareImport(specifier, context) {
|
|
|
21
20
|
const pkgName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
22
21
|
const subPath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
23
22
|
try {
|
|
24
|
-
console.log(`[SWITE] resolveBareImport: ${specifier} -> pkgName: ${pkgName}, subPath: ${subPath}`);
|
|
25
23
|
// Find package.json - check multiple node_modules locations
|
|
26
24
|
let pkgDir = null;
|
|
27
25
|
let pkgJsonPath = null;
|
|
@@ -40,7 +38,6 @@ export async function resolveBareImport(specifier, context) {
|
|
|
40
38
|
const swissNodeModules = path.join(swissLib, "node_modules");
|
|
41
39
|
if (await context.fileExists(swissNodeModules)) {
|
|
42
40
|
nodeModulesLocations.push(swissNodeModules);
|
|
43
|
-
console.log(`[SWITE] Added swiss-lib monorepo node_modules for ${pkgName}`);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
// Try each location
|
|
@@ -50,48 +47,20 @@ export async function resolveBareImport(specifier, context) {
|
|
|
50
47
|
if (await context.fileExists(testPkgJsonPath)) {
|
|
51
48
|
pkgDir = testPkgDir;
|
|
52
49
|
pkgJsonPath = testPkgJsonPath;
|
|
53
|
-
console.log(`[SWITE] Found ${pkgName} in ${nodeModulesPath}`);
|
|
54
50
|
break;
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
if (!pkgJsonPath || !pkgDir) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const pkgShortName = pkgName.replace('@kibologic/', '');
|
|
62
|
-
// Try relative path from SWS to swiss-lib
|
|
63
|
-
const potentialPaths = [
|
|
64
|
-
path.join(context.root, '../swiss-lib/packages', pkgShortName),
|
|
65
|
-
path.join(context.root, '../../swiss-lib/packages', pkgShortName),
|
|
66
|
-
path.join(context.root, '../../../swiss-lib/packages', pkgShortName),
|
|
67
|
-
];
|
|
68
|
-
for (const candidatePath of potentialPaths) {
|
|
69
|
-
const candidatePkgJson = path.join(candidatePath, 'package.json');
|
|
70
|
-
if (await context.fileExists(candidatePkgJson)) {
|
|
71
|
-
console.log(`[SWITE] Emergency: Found ${pkgName} at ${candidatePath}`);
|
|
72
|
-
pkgDir = candidatePath;
|
|
73
|
-
pkgJsonPath = candidatePkgJson;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
54
|
+
const workspacePkg = await context.resolveWorkspacePackage(pkgName);
|
|
55
|
+
if (workspacePkg) {
|
|
56
|
+
return await resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, specifier, context);
|
|
77
57
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (workspacePkg) {
|
|
82
|
-
return await resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, specifier, context);
|
|
83
|
-
}
|
|
84
|
-
// Last resort: CDN fallback
|
|
85
|
-
if (!shouldUseCdnFallback(pkgName)) {
|
|
86
|
-
// Scoped packages may be private and are not necessarily available on public npm CDNs.
|
|
87
|
-
console.warn(`[SWITE] Package ${pkgName} not found anywhere. Scoped package detected; CDN fallback is disabled by default.`);
|
|
88
|
-
// Return a same-origin node_modules URL to make failures explicit and allow the
|
|
89
|
-
// node-module handler to try serving it.
|
|
90
|
-
return `/node_modules/${specifier}`;
|
|
91
|
-
}
|
|
92
|
-
console.warn(`[SWITE] Package ${pkgName} not found anywhere, using CDN fallback`);
|
|
93
|
-
return `https://cdn.jsdelivr.net/npm/${specifier}/+esm`;
|
|
58
|
+
if (!shouldUseCdnFallback(pkgName)) {
|
|
59
|
+
console.warn(`[SWITE] Package ${pkgName} not found anywhere. Scoped package detected; CDN fallback is disabled by default.`);
|
|
60
|
+
return `/node_modules/${specifier}`;
|
|
94
61
|
}
|
|
62
|
+
console.warn(`[SWITE] Package ${pkgName} not found anywhere, using CDN fallback`);
|
|
63
|
+
return `https://cdn.jsdelivr.net/npm/${specifier}/+esm`;
|
|
95
64
|
}
|
|
96
65
|
// Continue with normal resolution if we found it
|
|
97
66
|
if (pkgJsonPath && pkgDir) {
|
|
@@ -106,7 +75,6 @@ export async function resolveBareImport(specifier, context) {
|
|
|
106
75
|
realPkgDir = pkgDir;
|
|
107
76
|
}
|
|
108
77
|
const workspacePkg = await context.resolveWorkspacePackage(pkgName);
|
|
109
|
-
console.log(`[SWITE] resolveBareImport (node_modules): workspacePkg=${workspacePkg}, realPkgDir=${realPkgDir}, pkgName=${pkgName}`);
|
|
110
78
|
if (workspacePkg) {
|
|
111
79
|
const normalizedWorkspacePkg = path
|
|
112
80
|
.resolve(workspacePkg)
|
|
@@ -119,7 +87,6 @@ export async function resolveBareImport(specifier, context) {
|
|
|
119
87
|
// If the real path is the workspace package, use workspace resolution
|
|
120
88
|
if (normalizedRealPkgDir === normalizedWorkspacePkg ||
|
|
121
89
|
normalizedRealPkgDir.includes(normalizedWorkspacePkg)) {
|
|
122
|
-
console.log(`[SWITE] resolveBareImport (node_modules): Using workspace resolution for ${pkgName}`);
|
|
123
90
|
return await resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, specifier, context);
|
|
124
91
|
}
|
|
125
92
|
}
|
|
@@ -151,7 +118,6 @@ export async function resolveBareImport(specifier, context) {
|
|
|
151
118
|
.replace("/dist/", "/src/")
|
|
152
119
|
.replace(/\.js$/, ".ts");
|
|
153
120
|
if (await context.fileExists(srcFullPath)) {
|
|
154
|
-
console.log(`[SWITE] resolveBareImport: Using source file instead of dist: ${srcFullPath}`);
|
|
155
121
|
return await toUrl(srcFullPath, context);
|
|
156
122
|
}
|
|
157
123
|
}
|
|
@@ -227,7 +193,6 @@ async function resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, spec
|
|
|
227
193
|
? subPath.replace(/\.(js|ts|ui|uix)$/, "")
|
|
228
194
|
: "";
|
|
229
195
|
let exportKey = subPathWithoutExt ? `./${subPathWithoutExt}` : ".";
|
|
230
|
-
console.log(`[SWITE] resolveBareImport (workspace): pkgName=${pkgName}, subPath=${subPath}, subPathWithoutExt=${subPathWithoutExt}, exportKey=${exportKey}`);
|
|
231
196
|
// Try to find matching export
|
|
232
197
|
if (subPath && !workspacePkgJson.exports[exportKey]) {
|
|
233
198
|
if (subPathWithoutExt) {
|
|
@@ -285,7 +250,6 @@ async function resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, spec
|
|
|
285
250
|
if (normalizedFull.includes("/dist/")) {
|
|
286
251
|
const srcPath = fullPath.replace(/[/\\]dist[/\\]/, path.sep + "src" + path.sep).replace(/\.js$/i, ".ts");
|
|
287
252
|
if (await context.fileExists(srcPath)) {
|
|
288
|
-
console.log(`[SWITE] resolveBareImport (workspace): preferring src over dist: ${srcPath}`);
|
|
289
253
|
return await toUrl(srcPath, context);
|
|
290
254
|
}
|
|
291
255
|
}
|
|
@@ -316,7 +280,6 @@ async function resolveWorkspacePackageEntry(workspacePkg, pkgName, subPath, spec
|
|
|
316
280
|
if (normalizedFull.includes("/dist/")) {
|
|
317
281
|
const srcPath = fullPath.replace(/[/\\]dist[/\\]/, path.sep + "src" + path.sep).replace(/\.js$/i, ".ts");
|
|
318
282
|
if (await context.fileExists(srcPath)) {
|
|
319
|
-
console.log(`[SWITE] resolveBareImport (fallback): preferring src over dist: ${srcPath}`);
|
|
320
283
|
return await toUrl(srcPath, context);
|
|
321
284
|
}
|
|
322
285
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdn-fallback.d.ts","sourceRoot":"","sources":["../../../src/resolution/cdn/cdn-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmBH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAKpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-path-resolver.d.ts","sourceRoot":"","sources":["../../../src/resolution/path/file-path-resolver.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,aAAa,GAAE,MAAM,GAAG,IAAW,GAClC,OAAO,CAAC,MAAM,CAAC,CAsKjB"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { promises as fs } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
import { findWorkspaceRoot } from "
|
|
9
|
-
import { findSwissLibMonorepo } from "
|
|
8
|
+
import { findWorkspaceRoot } from "../../kernel/workspace.js";
|
|
9
|
+
import { findSwissLibMonorepo } from "../../kernel/package-finder.js";
|
|
10
10
|
/**
|
|
11
11
|
* Resolve file path from URL, handling SWISS packages, workspace packages, and app files
|
|
12
12
|
*/
|
|
@@ -54,32 +54,23 @@ export async function resolveFilePath(url, root, workspaceRoot = null) {
|
|
|
54
54
|
}
|
|
55
55
|
return path.join(path.resolve(root), urlPath); // fallback; handler will 404
|
|
56
56
|
}
|
|
57
|
-
//
|
|
57
|
+
// /swiss-packages/ URLs point to files in the co-located framework monorepo's packages/ dir
|
|
58
58
|
if (url.startsWith("/swiss-packages/")) {
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
const relativePath = url.replace(/^\/swiss-packages\//, "");
|
|
64
|
-
const swissPackagesPath = path.join(swissLib, "packages");
|
|
65
|
-
const fullPath = path.join(swissPackagesPath, relativePath);
|
|
59
|
+
const relativePath = url.replace(/^\/swiss-packages\//, "");
|
|
60
|
+
const monorepo = await findSwissLibMonorepo(root);
|
|
61
|
+
if (monorepo) {
|
|
62
|
+
const fullPath = path.join(monorepo, "packages", relativePath);
|
|
66
63
|
try {
|
|
67
64
|
await fs.access(fullPath);
|
|
68
|
-
console.log(`[file-path-resolver] Found swiss-lib package at: ${fullPath}`);
|
|
69
65
|
return fullPath;
|
|
70
66
|
}
|
|
71
67
|
catch {
|
|
72
|
-
|
|
73
|
-
return fullPath; // Return path anyway, will error later if needed
|
|
68
|
+
return fullPath; // Return anyway; handler will 404 if missing
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const fallbackPath = path.join(root, "..", "..", "..", "swiss-lib", "packages", relativePath);
|
|
80
|
-
console.warn(`[file-path-resolver] swiss-lib not found, using fallback: ${fallbackPath}`);
|
|
81
|
-
return fallbackPath;
|
|
82
|
-
}
|
|
71
|
+
// No co-located monorepo found — return a path that will 404 cleanly
|
|
72
|
+
console.warn(`[file-path-resolver] No framework monorepo found for /swiss-packages/${relativePath}`);
|
|
73
|
+
return path.join(root, "node_modules", relativePath);
|
|
83
74
|
}
|
|
84
75
|
// Workspace-level directories: always resolve from workspace root
|
|
85
76
|
// Updated: lib/ now contains all packages (moved from packages/)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralised /swiss-lib/ → /swiss-packages/ path fixup.
|
|
3
|
+
*
|
|
4
|
+
* Root cause: the UiCompiler emits absolute `/swiss-lib/` paths in some code
|
|
5
|
+
* paths (compiler was written against an older directory structure). Until the
|
|
6
|
+
* compiler is fixed at source this single function is the authoritative fixup.
|
|
7
|
+
* Apply it once per compilation, before passing code to the import rewriter.
|
|
8
|
+
*
|
|
9
|
+
* All seven previous fixup locations across ui-handler, uix-handler, and
|
|
10
|
+
* import-rewriter have been removed in favour of this call.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fixSwissLibPaths(code: string): string;
|
|
13
|
+
//# sourceMappingURL=path-fixup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-fixup.d.ts","sourceRoot":"","sources":["../../../src/resolution/path/path-fixup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOrD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralised /swiss-lib/ → /swiss-packages/ path fixup.
|
|
3
|
+
*
|
|
4
|
+
* Root cause: the UiCompiler emits absolute `/swiss-lib/` paths in some code
|
|
5
|
+
* paths (compiler was written against an older directory structure). Until the
|
|
6
|
+
* compiler is fixed at source this single function is the authoritative fixup.
|
|
7
|
+
* Apply it once per compilation, before passing code to the import rewriter.
|
|
8
|
+
*
|
|
9
|
+
* All seven previous fixup locations across ui-handler, uix-handler, and
|
|
10
|
+
* import-rewriter have been removed in favour of this call.
|
|
11
|
+
*/
|
|
12
|
+
export function fixSwissLibPaths(code) {
|
|
13
|
+
if (!code.includes('/swiss-lib/'))
|
|
14
|
+
return code;
|
|
15
|
+
// More-specific pattern first so `/swiss-lib/packages/` doesn't leave a
|
|
16
|
+
// dangling `/swiss-packages/packages/` if the replacement ran twice.
|
|
17
|
+
return code
|
|
18
|
+
.replace(/\/swiss-lib\/packages\//g, '/swiss-packages/')
|
|
19
|
+
.replace(/\/swiss-lib\//g, '/swiss-packages/');
|
|
20
|
+
}
|