From ef0b9b44109e38c0e6c6b3b57a478b56b8dc450c Mon Sep 17 00:00:00 2001 From: Avi Vahl Date: Sun, 21 Apr 2024 16:38:52 +0300 Subject: [PATCH] refactor: improve compat with node16 resolution --- packages/dashboard/src/globals.d.ts | 2 +- packages/engine-cli/src/cli.ts | 2 +- packages/engine-cli/src/engine-build.ts | 9 ++++++++- packages/engine-cli/src/launch-dashboard-server.ts | 2 +- packages/engine-cli/src/start-dev-server.ts | 8 +++++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/dashboard/src/globals.d.ts b/packages/dashboard/src/globals.d.ts index 59d1c0880..18eb21adc 100644 --- a/packages/dashboard/src/globals.d.ts +++ b/packages/dashboard/src/globals.d.ts @@ -1,5 +1,5 @@ declare module '*.st.css' { - export * from '@stylable/runtime/stylesheet.js'; + export * from '@stylable/runtime/stylesheet'; const defaultExport: unknown; export default defaultExport; diff --git a/packages/engine-cli/src/cli.ts b/packages/engine-cli/src/cli.ts index 315a16db4..98c45cc50 100644 --- a/packages/engine-cli/src/cli.ts +++ b/packages/engine-cli/src/cli.ts @@ -14,7 +14,7 @@ async function engine() { }, }); - const { loadEngineConfig, runEngine } = await import('./engine-build'); + const { loadEngineConfig, runEngine } = await import('./engine-build.js'); const engineConfig = await loadEngineConfig(process.cwd(), engineConfigCli.flags.engineConfigFilePath); diff --git a/packages/engine-cli/src/engine-build.ts b/packages/engine-cli/src/engine-build.ts index a95740168..c8a9465eb 100644 --- a/packages/engine-cli/src/engine-build.ts +++ b/packages/engine-cli/src/engine-build.ts @@ -40,6 +40,7 @@ export interface RunEngineOptions { publicConfigsRoute?: string; configLoadingMode?: ConfigLoadingMode; } + export async function runEngine({ verbose = false, clean = true, @@ -60,7 +61,13 @@ export async function runEngine({ writeMetadataFiles = !watch, publicConfigsRoute = 'configs', configLoadingMode = 'require', -}: RunEngineOptions = {}) { +}: RunEngineOptions = {}): Promise<{ + featureEnvironmentsMapping: FeatureEnvironmentMapping; + configMapping: ConfigurationEnvironmentMapping; + devServer?: Awaited>; + esbuildContextWeb?: esbuild.BuildContext; + esbuildContextNode?: esbuild.BuildContext; +}> { const mode: '' | 'development' | 'production' = dev ? 'development' : 'production'; let esbuildContextWeb: esbuild.BuildContext | undefined; let esbuildContextNode: esbuild.BuildContext | undefined; diff --git a/packages/engine-cli/src/launch-dashboard-server.ts b/packages/engine-cli/src/launch-dashboard-server.ts index 60a640fab..7be3d81ae 100644 --- a/packages/engine-cli/src/launch-dashboard-server.ts +++ b/packages/engine-cli/src/launch-dashboard-server.ts @@ -24,7 +24,7 @@ export async function launchDashboardServer( waitForBuildReady?: (cb: () => void) => boolean, buildConditions?: string[], extensions?: string[], -) { +): Promise> { const staticMiddlewares = serveStatic.map(({ route, directoryPath }) => ({ path: route, handlers: express.static(directoryPath), diff --git a/packages/engine-cli/src/start-dev-server.ts b/packages/engine-cli/src/start-dev-server.ts index be47c9d46..387cb8ac5 100644 --- a/packages/engine-cli/src/start-dev-server.ts +++ b/packages/engine-cli/src/start-dev-server.ts @@ -23,7 +23,13 @@ export async function launchServer({ httpServerPort = 3000, socketServerOptions, middlewares = [], -}: LaunchOptions = {}) { +}: LaunchOptions = {}): Promise<{ + close: () => Promise; + port: number; + app: express.Express; + httpServer: import('http').Server; + socketServer: io.Server; +}> { const app = express(); app.use(cors());