@r01al/mfe-workforce-common-server
v1.2.1
Published
Shared Module Federation build configuration and production servers for Workforce micro-frontends.
Maintainers
Readme
@r01al/mfe-workforce-common-server
The Node and build-side platform library for the Workforce micro-frontends.
@r01al/mfe-workforce-common-server/build exports reusable Webpack 5 Module Federation configuration factories:
import { createHostConfig, createRemoteConfig } from '@r01al/mfe-workforce-common-server/build';Remote applications can opt into a development-only standalone page while keeping their production build limited to the federated remote:
createRemoteConfig({
name: 'calendar',
appDirectory: process.cwd(),
port: 3004,
exposes: { './Calendar': './src/Calendar' },
standalone: {
entry: './src/dev.ts',
title: 'Calendar development',
},
}, environment, argv);The standalone entry and generated HTML are included only in development mode.
Webpack Dev Server serves files from the application's public directory and
falls back to the standalone page for browser-history routes.
The entry must use an asynchronous bootstrap so Module Federation can initialize shared dependencies before React renders:
import('./dev-bootstrap');Host builds receive their default remote URLs through the compile-time __MFE_DEFAULT_REMOTES__ browser constant. The host loads and initializes each remote container on demand; createHostConfig intentionally does not register static host remotes, preventing Webpack share-scope startup from downloading every remoteEntry.js.
@r01al/mfe-workforce-common-server/runtime exports production Express hosting with compression, CORS, cache policy, health endpoints, and shell history fallback:
import { serveRemote, serveShell } from '@r01al/mfe-workforce-common-server/runtime';Development
npm ci
npm run typecheck
npm run build
npm run packagenpm run package creates a publishable tarball under artifacts/ after typechecking, building, and validating the public outputs.
Publishing
For releases:
- Update the version with
npm version patch,npm version minor, ornpm version major. - Push the commit and tag with
git push --follow-tags. - Create and publish a GitHub Release using the
v<version>tag. - The
publish.ymlworkflow validates the tag and publishes the package to npm with provenance.
For a manual public release from an authenticated workstation:
npm run package
npm publish --access publicThe prepack lifecycle validates the package again immediately before publication.
For the first publication, add an npm granular access token as the NPM_TOKEN GitHub Actions repository secret. The token must be allowed to publish public packages and bypass publishing 2FA. After the package exists on npm, the workflow can be registered as an npm Trusted Publisher and the long-lived token can be removed.
Breaking runtime or build-contract changes require a new major version.
