@equinor/fusion-framework-dev-server

中文文档
2.3.4发布于 2026/11/12ISCTypeScriptES Module近 30 天下载 9189

Package for running a development server for fusion-framework

原始使用文档
文档目录8 节
  1. Choose your entry point
  2. Quick start
  3. Send app telemetry to a local OTLP collector
  4. Mock APIs locally
  5. Learn in order
  6. Public API
  7. Requirements and boundaries
  8. License

@equinor/fusion-framework-dev-server

Development server primitives for Fusion Framework applications. The package combines Vite, React Fast Refresh, SPA environment injection, Fusion service discovery, and local API proxying.

[!TIP] Most application developers should start with ffc app dev. Use this package directly when you are building framework tooling, a custom development command, or a Vite integration that needs control over server creation.

Choose your entry point

GoalStart here
Run a Fusion application locallyffc app dev from @equinor/fusion-framework-cli
Create and start a configured Vite servercreateDevServer(options, overrides?)
Generate Vite configuration without starting a servercreateDevServerConfig(options, overrides?)
Customize service discovery proxy routesprocessServices(data, args)
Develop against local OpenAPI mocks@equinor/fusion-framework-cli-plugin-mock-server

Quick start

pnpm add -D @equinor/fusion-framework-dev-server vite
import { createDevServer } from '@equinor/fusion-framework-dev-server';

const server = await createDevServer({
  spa: {
    templateEnv: {
      portal: { id: 'my-portal' },
      title: 'My application',
      serviceDiscovery: {
        url: 'https://service-discovery.example.com',
        scopes: ['api://example.com/user_impersonation'],
      },
      msal: {
        clientId: 'client-id',
        tenantId: 'tenant-id',
        redirectUri: '/authentication/login-callback',
        requiresAuth: 'true',
      },
    },
  },
  api: { serviceDiscoveryUrl: 'https://service-discovery.example.com' },
});

await server.listen();
server.printUrls();

The browser receives spa.templateEnv. The Node development server uses api.serviceDiscoveryUrl to fetch service definitions and create same-origin proxy routes. These two URLs often point to the same endpoint, but they serve different consumers.

Continue with Getting started for the complete mental model.

Send app telemetry to a local OTLP collector

From your application repository, set the environment variable when starting the dev server:

FUSION_DEV_SERVER_OTLP_ENDPOINT=http://localhost:4318 pnpm exec ffc app dev

No app code or DevServerOptions changes are needed. The telemetry module's OtlpAdapter uses the standard OpenTelemetry OTLP/HTTP log exporter through a same-origin dev-server route. App records include fusion.app.key and source: app; shell records use source: framework.

Browser fetch/XHR spans are also exported. W3C traceparent and tracestate headers connect requests to instrumented backends, and logs emitted under an active span carry its trace/span IDs. The same collector URL configures /v1/logs and /v1/traces.

An app's explicitly configured telemetry adapters take precedence, so its records are not also exported by the dev-server fallback. An unset variable leaves telemetry unchanged, and production builds never enable this integration. Collector failures are reported once in the dev-server terminal without breaking the app.

See OTLP environment configuration for the endpoint contract and boundaries.

Mock APIs locally

Install the optional mock-server plugin when a backend is unavailable, unstable, or needs deterministic responses:

pnpm add -D @equinor/fusion-framework-cli-plugin-mock-server
ffc mock-server ./mocks --port 4010

[!IMPORTANT] ffc mock-server is a standalone foreground process. Installing the plugin does not start it with ffc app dev; the developer or test runner owns its lifecycle.

The plugin adds typed mockServer settings to DevServerOptions only when its types are imported, keeping this base package independent of optional mocking tools.

See Develop with mock services for normal development overlays, isolated --mock mode, direct-only services, and executable <name>.mock.ts modules. To verify an app's help button opens the right article, see Test help articles locally. To check the analytics an app tracks, see Test analytics locally.

Learn in order

  1. Getting started explains the server lifecycle and smallest useful setup.
  2. Configure the dev server covers SPA environment, API proxying, and logging.
  3. Develop with mock services shows the recommended optional mocking workflow.
  4. Advanced usage covers service processing, routes, Vite overrides, and extension interfaces.
  5. Troubleshooting maps common symptoms to the responsible configuration.

Public API

  • createDevServer creates a configured ViteDevServer. Call listen() yourself.
  • createDevServerConfig returns a Vite UserConfig for another tool to consume.
  • processServices rewrites discovered service URIs through the local proxy and returns routes.
  • DevServerOptions<TEnv> configures SPA injection, API discovery, and logging. It is an interface so optional plugins can augment it.
  • FusionService describes a backend using key, uri, name, and optional OAuth scopes.

Requirements and boundaries

  • Vite 7 or 8 is required as a peer dependency.
  • api.serviceDiscoveryUrl is required by the low-level API.
  • Every request the dev server proxies upstream (service discovery and API routes) carries X-Fusion-Dev-Server-Name and X-Fusion-Dev-Server-Version, so upstream telemetry can tell local development traffic apart. Add more with api.headers; ffc adds X-Fusion-Mock: true|false.
  • The package configures development; it does not build or publish applications.
  • Mock-server installation and process lifecycle are optional and external to this package.

License

ISC

版本与发布记录

@equinor/fusion-framework-dev-server 共发布 94 个版本,首次发布于 2025/05/27;过去 12 个月发布了 65 个版本。

版本发布日期距今
2.3.4latest2026/11/121 天前
2.3.4-next.0next2026/11/112 天前
2.3.32026/11/112 天前
2.3.3-next.22026/10/2915 天前
2.3.3-next.12026/10/2816 天前
2.3.3-next.02026/10/2816 天前

其他发布通道:cli-search-index → 1.1.13-cli-search-index.0,msal-v5 → 1.1.21-msal-v5.1,trusted-publishing-20261015 → 2.3.2-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85a,next → 2.3.4-next.0。

关于 @equinor/fusion-framework-dev-server 的常见问题

@equinor/fusion-framework-dev-server 是什么?

Package for running a development server for fusion-framework

如何安装 @equinor/fusion-framework-dev-server?

在项目目录运行 npm install @equinor/fusion-framework-dev-server,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vite(^7.0.0 || ^8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@equinor/fusion-framework-dev-server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@equinor/fusion-framework-dev-server 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@equinor/fusion-framework-dev-server 可以商用吗?

@equinor/fusion-framework-dev-server 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equinor/fusion-framework-dev-server 的下载量有多少?

根据 npm 官方下载统计,@equinor/fusion-framework-dev-server 在 2026/10/14 – 2026/11/12 这 30 天内被下载 9,189 次,日均约 306 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equinor/fusion-framework-dev-server 还在维护吗?

最新版本 2.3.4 发布于 2026/11/12(1 天前);至今共发布 94 个版本,其中过去 12 个月发布了 65 个;首次发布于 2025/05/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。