@module-federation/treeshake-server 0.0.0-chore-bump-node-22-20260710161714

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.
Files changed (65) hide show
  1. package/README.md +65 -0
  2. package/bin/treeshake-server.js +35 -0
  3. package/dist/876.mjs +940 -0
  4. package/dist/adapters/createAdapterDeps.d.ts +10 -0
  5. package/dist/adapters/local/adapter.d.ts +10 -0
  6. package/dist/adapters/local/index.d.ts +3 -0
  7. package/dist/adapters/local/localObjectStore.d.ts +12 -0
  8. package/dist/adapters/registry.d.ts +7 -0
  9. package/dist/adapters/types.d.ts +70 -0
  10. package/dist/app.d.ts +18 -0
  11. package/dist/cli/ossEnv.d.ts +18 -0
  12. package/dist/domain/build/constant.d.ts +1 -0
  13. package/dist/domain/build/normalize-config.d.ts +22 -0
  14. package/dist/domain/build/retrieve-global-name.d.ts +1 -0
  15. package/dist/domain/build/schema.d.ts +31 -0
  16. package/dist/domain/upload/constant.d.ts +2 -0
  17. package/dist/domain/upload/retrieve-cdn-path.d.ts +4 -0
  18. package/dist/frontend/adapter/index.d.ts +13 -0
  19. package/dist/frontend/adapter/index.js +132 -0
  20. package/dist/frontend/adapter/index.mjs +83 -0
  21. package/dist/frontend/favicon.ico +0 -0
  22. package/dist/frontend/index.html +1 -0
  23. package/dist/frontend/static/css/index.513418ff5d.css +1 -0
  24. package/dist/frontend/static/js/637.b47e0403af.js +2 -0
  25. package/dist/frontend/static/js/637.b47e0403af.js.LICENSE.txt +16 -0
  26. package/dist/frontend/static/js/async/427.dbb8b74259.js +2 -0
  27. package/dist/frontend/static/js/async/427.dbb8b74259.js.LICENSE.txt +6 -0
  28. package/dist/frontend/static/js/async/503.7bd056737e.js +12 -0
  29. package/dist/frontend/static/js/async/503.7bd056737e.js.LICENSE.txt +6 -0
  30. package/dist/frontend/static/js/async/515.1b7f26d7ec.js +2 -0
  31. package/dist/frontend/static/js/index.ace3fa3d0e.js +88 -0
  32. package/dist/frontend/static/js/lib-react.7c43a84261.js +2 -0
  33. package/dist/frontend/static/js/lib-react.7c43a84261.js.LICENSE.txt +39 -0
  34. package/dist/frontend/static/js/lib-router.5077a93d5a.js +4 -0
  35. package/dist/frontend/static/js/lib-router.5077a93d5a.js.LICENSE.txt +10 -0
  36. package/dist/http/env.d.ts +10 -0
  37. package/dist/http/middlewares/di.middleware.d.ts +4 -0
  38. package/dist/http/middlewares/logger.middleware.d.ts +3 -0
  39. package/dist/http/routes/build.d.ts +3 -0
  40. package/dist/http/routes/index.d.ts +2 -0
  41. package/dist/http/routes/maintenance.d.ts +3 -0
  42. package/dist/http/routes/static.d.ts +5 -0
  43. package/dist/index.d.ts +10 -0
  44. package/dist/index.js +1015 -0
  45. package/dist/index.mjs +1 -0
  46. package/dist/infra/logger.d.ts +6 -0
  47. package/dist/nodeServer.d.ts +7 -0
  48. package/dist/ports/objectStore.d.ts +1 -0
  49. package/dist/ports/projectPublisher.d.ts +1 -0
  50. package/dist/server.d.ts +2 -0
  51. package/dist/server.js +1144 -0
  52. package/dist/server.mjs +170 -0
  53. package/dist/services/buildService.d.ts +8 -0
  54. package/dist/services/cacheService.d.ts +15 -0
  55. package/dist/services/pnpmMaintenance.d.ts +4 -0
  56. package/dist/services/uploadService.d.ts +36 -0
  57. package/dist/template/re-shake-share/Collect.js +115 -0
  58. package/dist/template/re-shake-share/EmitManifest.js +49 -0
  59. package/dist/template/re-shake-share/index.ts +1 -0
  60. package/dist/template/re-shake-share/package.json +23 -0
  61. package/dist/template/re-shake-share/rspack.config.ts +33 -0
  62. package/dist/utils/runCommand.d.ts +20 -0
  63. package/dist/utils/runtimeEnv.d.ts +3 -0
  64. package/dist/utils/uploadSdk.d.ts +10 -0
  65. package/package.json +68 -0
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Treeshake Server
2
+
3
+ An adapter-driven build service for shared treeshaking. The CLI runs in **local filesystem mode only** and embeds the treeshake UI automatically. When importing the package, you can register your own adapters, middlewares, and optional frontend UI.
4
+
5
+ ## CLI (embedded UI, local-only)
6
+
7
+ ```bash
8
+ pnpm --filter @module-federation/treeshake-server dev
9
+ # or
10
+ pnpm --filter @module-federation/treeshake-server start
11
+ ```
12
+
13
+ Defaults:
14
+
15
+ - API: `http://localhost:3000/tree-shaking-shared`
16
+ - UI: `http://localhost:3000/tree-shaking`
17
+ - Storage: local filesystem (`LOCAL_STORE_DIR`, default `./log/static`)
18
+
19
+ The CLI **ignores** `ADAPTER_ID` and always uses the local filesystem adapter.
20
+
21
+ ### Frontend env overrides (CLI)
22
+
23
+ The CLI always embeds the UI. You can only override where it is served from:
24
+
25
+ - `TREESHAKE_FRONTEND_DIST=/path/to/dist`
26
+ - `TREESHAKE_FRONTEND_BASE_PATH=/tree-shaking`
27
+ - `TREESHAKE_FRONTEND_SPA_FALLBACK=0`
28
+
29
+ ## Library usage (custom adapters + middlewares)
30
+
31
+ ```ts
32
+ import { createAdapterRegistry, createAdapterDeps, createApp, createServer, LocalAdapter } from '@module-federation/treeshake-server';
33
+ import { createTreeshakeFrontendAdapter } from '@module-federation/treeshake-frontend/adapter';
34
+
35
+ const registry = createAdapterRegistry([
36
+ new LocalAdapter(),
37
+ // new MyCustomAdapter(),
38
+ ]);
39
+
40
+ const deps = await createAdapterDeps({
41
+ registry,
42
+ adapterId: 'local', // or your custom adapter id
43
+ });
44
+
45
+ const app = createApp(deps, {
46
+ appExtensions: [
47
+ (appInstance) => {
48
+ appInstance.use('*', async (c, next) => {
49
+ c.res.headers.set('x-treeshake', 'true');
50
+ await next();
51
+ });
52
+ },
53
+ ],
54
+ frontendAdapters: [
55
+ createTreeshakeFrontendAdapter({
56
+ basePath: '/tree-shaking',
57
+ distDir: '/path/to/treeshake-frontend/dist',
58
+ }),
59
+ ],
60
+ });
61
+
62
+ createServer({ app, port: 3000, hostname: '0.0.0.0' });
63
+ ```
64
+
65
+ In library mode you control the adapter registry, middleware, and frontend embedding.
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper entry for the CLI.
4
+ *
5
+ * pnpm creates workspace bins during install. If the target is a build artifact
6
+ * (e.g. dist/server.js) and the package hasn't been built yet, install fails
7
+ * with ENOENT. This wrapper keeps installs clean, and still runs the built
8
+ * server when it's available.
9
+ */
10
+
11
+ const path = require('path');
12
+
13
+ const entry = path.join(__dirname, '..', 'dist', 'server.js');
14
+
15
+ try {
16
+ // eslint-disable-next-line import/no-dynamic-require, global-require
17
+ require(entry);
18
+ } catch (err) {
19
+ // If dist hasn't been built yet, show a helpful message and exit.
20
+ if (err && (err.code === 'MODULE_NOT_FOUND' || err.code === 'ENOENT')) {
21
+ // eslint-disable-next-line no-console
22
+ console.error(
23
+ [
24
+ 'treeshake-server: missing build output at dist/server.js.',
25
+ '',
26
+ 'Run:',
27
+ ' pnpm exec turbo run build --filter=@module-federation/treeshake-server',
28
+ '',
29
+ ].join('\n'),
30
+ );
31
+ process.exit(1);
32
+ }
33
+
34
+ throw err;
35
+ }