@bleedingdev/modern-js-app-tools 3.9.0-ultramodern.4 → 3.9.0-ultramodern.5

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 (86) hide show
  1. package/dist/cjs/builder/generator/index.js +0 -1
  2. package/dist/cjs/builder/shared/builderPlugins/index.js +4 -11
  3. package/dist/cjs/config/index.js +4 -11
  4. package/dist/cjs/index.js +80 -111
  5. package/dist/cjs/plugins/deploy/platforms/node.js +0 -13
  6. package/dist/cjs/plugins/serverBuild.js +2 -1
  7. package/dist/esm/builder/generator/index.mjs +1 -2
  8. package/dist/esm/builder/shared/builderPlugins/index.mjs +0 -1
  9. package/dist/esm/config/index.mjs +0 -1
  10. package/dist/esm/index.mjs +1 -6
  11. package/dist/esm/plugins/deploy/platforms/node.mjs +0 -13
  12. package/dist/esm/plugins/serverBuild.mjs +2 -1
  13. package/dist/esm-node/builder/generator/index.mjs +1 -2
  14. package/dist/esm-node/builder/shared/builderPlugins/index.mjs +0 -1
  15. package/dist/esm-node/config/index.mjs +0 -1
  16. package/dist/esm-node/index.mjs +1 -6
  17. package/dist/esm-node/plugins/deploy/platforms/node.mjs +0 -13
  18. package/dist/esm-node/plugins/serverBuild.mjs +2 -1
  19. package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -1
  20. package/dist/types/config/index.d.ts +0 -1
  21. package/dist/types/index.d.ts +0 -1
  22. package/dist/types/plugins/deploy/utils/generator.d.ts +1 -1
  23. package/dist/types/types/config/output.d.ts +0 -9
  24. package/dist/types/types/index.d.ts +1 -1
  25. package/dist/types/types/plugin.d.ts +56 -2
  26. package/dist/types/utils/initAppContext.d.ts +3 -2
  27. package/docs/configure/app/bff/effect.md +27 -21
  28. package/docs/guides/advanced-features/bff/data-platform.md +2 -2
  29. package/docs/guides/advanced-features/bff/frameworks.md +27 -20
  30. package/docs/guides/advanced-features/bff/function.md +2 -2
  31. package/docs/guides/advanced-features/bff/operators.md +17 -17
  32. package/docs/guides/get-started/quick-start.md +1 -5
  33. package/docs/guides/get-started/ultramodern.md +1 -1
  34. package/docs/llms.txt +2 -2
  35. package/package.json +14 -30
  36. package/rslib.config.mts +0 -5
  37. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +0 -125
  38. package/dist/cjs/config/build-environment.js +0 -268
  39. package/dist/cjs/config/public.js +0 -46
  40. package/dist/cjs/plugins/backend-federation/codegen.js +0 -256
  41. package/dist/cjs/plugins/backend-federation/config.js +0 -204
  42. package/dist/cjs/plugins/backend-federation/emit.js +0 -150
  43. package/dist/cjs/plugins/backendFederationBuild.js +0 -53
  44. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +0 -62
  45. package/dist/cjs/plugins/deploy/utils/npmAliases.js +0 -226
  46. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +0 -44
  47. package/dist/cjs/presetUltramodern.js +0 -175
  48. package/dist/cjs/types/config/precompress.js +0 -18
  49. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +0 -77
  50. package/dist/esm/config/build-environment.mjs +0 -224
  51. package/dist/esm/config/public.mjs +0 -1
  52. package/dist/esm/plugins/backend-federation/codegen.mjs +0 -205
  53. package/dist/esm/plugins/backend-federation/config.mjs +0 -128
  54. package/dist/esm/plugins/backend-federation/emit.mjs +0 -99
  55. package/dist/esm/plugins/backendFederationBuild.mjs +0 -1
  56. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +0 -1
  57. package/dist/esm/plugins/deploy/utils/npmAliases.mjs +0 -174
  58. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +0 -6
  59. package/dist/esm/presetUltramodern.mjs +0 -119
  60. package/dist/esm/types/config/precompress.mjs +0 -0
  61. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +0 -78
  62. package/dist/esm-node/config/build-environment.mjs +0 -225
  63. package/dist/esm-node/config/public.mjs +0 -2
  64. package/dist/esm-node/plugins/backend-federation/codegen.mjs +0 -206
  65. package/dist/esm-node/plugins/backend-federation/config.mjs +0 -129
  66. package/dist/esm-node/plugins/backend-federation/emit.mjs +0 -100
  67. package/dist/esm-node/plugins/backendFederationBuild.mjs +0 -2
  68. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +0 -2
  69. package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +0 -175
  70. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +0 -7
  71. package/dist/esm-node/presetUltramodern.mjs +0 -120
  72. package/dist/esm-node/types/config/precompress.mjs +0 -1
  73. package/dist/types/builder/shared/builderPlugins/adapterPrecompress.d.ts +0 -3
  74. package/dist/types/config/build-environment.d.ts +0 -22
  75. package/dist/types/config/public.d.ts +0 -2
  76. package/dist/types/plugins/backend-federation/codegen.d.ts +0 -86
  77. package/dist/types/plugins/backend-federation/config.d.ts +0 -103
  78. package/dist/types/plugins/backend-federation/emit.d.ts +0 -13
  79. package/dist/types/plugins/backendFederationBuild.d.ts +0 -2
  80. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +0 -1
  81. package/dist/types/plugins/deploy/utils/npmAliases.d.ts +0 -14
  82. package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +0 -3
  83. package/dist/types/precompress/LICENSE +0 -20
  84. package/dist/types/precompress/index.d.ts +0 -76
  85. package/dist/types/presetUltramodern.d.ts +0 -87
  86. package/dist/types/types/config/precompress.d.ts +0 -19
package/docs/llms.txt CHANGED
@@ -47,7 +47,7 @@
47
47
  - [Deploy Application](/guides/basic-features/deploy.md): Currently, Modern.js offers two deployment way: You can host your application in a container that includes a Node.js environment on your own, which provides flexibility for the deployment of the application.You can also deploy your application through a platform. Currently, Modern.js officially supports deployment on Netlify, Vercel, and Github pages.
48
48
  - [BFF](/guides/advanced-features/bff.md): BFF (Backends for Frontends) is an architectural pattern primarily used to address issues of data aggregation in front-end and back-end collaboration. Under the BFF architecture, front-end applications do not communicate directly with backend services. Instead, they interact with backend services through a dedicated BFF middleware layer, custom-made for the front end. The main problems it tries to solve include: Aggregation, mapping, clipping, and proxying of lower-level APIs according to their own business needs.Cache data for some specific scenarios to improve performance and thus improve user experience.Quickly development of new products based on existing interfaces.Interface with third-party systems, such as login authentication. Modern.js officially supported the BFF and provided the Integrated BFF to further strengthen the BFF's capabilities, mainly including the following capabilities: Quick development and debugging go live, running, building, and deploying BFF code in the same project.Minimal pure function call, directly import BFF function on the front end, and can be automatically converted into HTTP request when called.No private protocol, follow RESTful API specification, all BFF interfaces are standardized.Full TypeScript support.Meet user preferences and support multi-frame extension writing.
49
49
  - [Basic Usage](/guides/advanced-features/bff/function.md): In a Modern.js application, developers can define API files under the api/lambda directory and export API functions from these files. In the frontend code, these API functions can be directly invoked by importing the file, which initiates the API requests. This invocation method is called unified invocation, where developers do not need to write glue code for the frontend and backend separately, thereby ensuring type safety across both.
50
- - [Runtime Framework](/guides/advanced-features/bff/frameworks.md): Modern.js supports two BFF runtime frameworks: effect (default): use Effect HttpApi runtime from api/index.hono: use file-convention BFF handlers from api/lambda/**. effect and hono are strict runtime modes. There is no automatic fallback between them. ::::info Generated UltraModern workspaces use strict Effect APIs: author HTTP APIs in shared/api.ts and api/index.ts, not Hono/file-convention handlers. ::::
50
+ - [Runtime Framework](/guides/advanced-features/bff/frameworks.md): Modern.js and the UltraModern BFF extension provide two runtime frameworks: hono is the native plugin default and uses file-convention handlers from api/lambda/**.effect is the UltraModern extension default and uses Effect HttpApi from api/index. effect and hono are strict runtime modes. There is no automatic fallback between them. ::::info Generated UltraModern workspaces use strict Effect APIs: author HTTP APIs in shared/api.ts and api/index.ts, not Hono/file-convention handlers. ::::
51
51
  - [Data Platform](/guides/advanced-features/bff/data-platform.md): Modern.js Effect API runtime now supports a request-envelope based data platform contract for safer and more predictable data orchestration in complex applications such as Module Federation and micro frontends.
52
52
  - [Creating Extensible BFF Functions](/guides/advanced-features/bff/operators.md): The previous section showed how to export a simple BFF function in a file. In more complex scenarios, each BFF function may need to do independent type validation, pre-logic, etc. Therefore, Modern.js exposes Api, which supports creating BFF functions through this API. BFF functions created in this way can be easily extended with functionality.
53
53
  - [Extend BFF Server](/guides/advanced-features/bff/extend-server.md): In some applications, developers may want to handle all BFF functions uniformly, such as authentication, logging, data processing, etc. Modern.js allows users to freely extend the BFF Server through Middleware method.
@@ -111,7 +111,7 @@
111
111
  - [watchFiles](/configure/app/dev/watch-files.md): Type: Default: undefined Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
112
112
  - [writeToDisk](/configure/app/dev/write-to-disk.md): Type: boolean | ((filename: string) => boolean)Default: (file) => !file.includes('.hot-update.') Controls whether the build output from development mode is written to disk.
113
113
  - [crossProject](/configure/app/bff/cross-project.md): Type: booleanDefault: false This configuration is used to enable BFF cross-project invocation functionality. When enabled, the current project can be used as a BFF producer, generating an SDK that can be directly called by other projects. For detailed configuration and usage of BFF cross-project invocation, please refer to the BFF Cross-Project Invocation Guide.
114
- - [effect](/configure/app/bff/effect.md): Type: Default: {} bff.effect is only effective when bff.runtimeFramework is set to 'effect'. Generated UltraModern workspaces use this runtime as the only generated HTTP API path. The API contract lives at shared/api.ts, the server runtime lives at api/index.ts, clients live under src/api/*-client.ts, and generated checks reject api/effect, api/lambda, shared/effect, src/effect, Hono server imports, raw request handlers, manual request parsing, and manual Response construction in API modules. For Effect v4, TypeScript should use export-map aware module resolution.
114
+ - [effect](/configure/app/bff/effect.md): Type: Default: {} bff.effect is only effective when bff.runtimeFramework is set to 'effect'. Use bffPlugin from @modern-js/plugin-bff-build-extensions to register the Effect runtime. It composes the native BFF plugin. Install @modern-js/bff-effect and @modern-js/plugin-bff-extensions from the same framework cohort as application production dependencies, so the adapter remains available after development dependencies are removed. The build plugin can be a development dependency. See the runtime configuration example. Native @modern-js/plugin-bff/server exports Hono APIs. For Node Effect APIs, import framework helpers such as defineEffectBff from @modern-js/bff-effect/effect and namespaces from the corresponding effect/* modules. Worker handlers and worker request context use @modern-js/bff-effect/effect-edge. Generated UltraModern workspaces use this runtime as the only generated HTTP API path. The API contract lives at shared/api.ts, the server runtime lives at api/index.ts, clients live under src/api/*-client.ts, and generated checks reject api/effect, api/lambda, shared/effect, src/effect, Hono server imports, raw request handlers, manual request parsing, and manual Response construction in API modules. For Effect v4, TypeScript should use export-map aware module resolution.
115
115
  - [prefix](/configure/app/bff/prefix.md): Type: stringDefault: /api By default, the prefix for accessing routes in the BFF API directory is /api, as shown in the following directory structure: The route corresponding to api/hello.ts when accessed is localhost:8080/api/hello. This configuration option can modify the default route prefix: The corresponding route for api/hello.ts when accessed is localhost:8080/api-demo/hello.
116
116
  - [runtimeFramework](/configure/app/bff/runtime-framework.md): Type: 'hono' | 'effect'Default: 'effect' Controls which runtime framework Modern.js uses for BFF routing. Set to 'effect' to run BFF only from api/index (Effect HttpApi runtime).Set to 'hono' to run BFF only from file-convention handlers under api/lambda/**. There is no implicit fallback between runtimes. Choose one runtime mode per app. Generated UltraModern apps use strict Effect APIs by default and set bff.effect.strictEffectApproach: true; hono and api/lambda/** are not valid generated UltraModern HTTP API paths.
117
117
  - [appIcon](/configure/app/html/app-icon.md): Type: Default: undefined Set the web application icons to display when added to the home screen of a mobile device: Generate the web app manifest file and its icons field.Generate the apple-touch-icon and manifest tags in the HTML file.
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.4",
20
+ "version": "3.9.0-ultramodern.5",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -37,12 +37,6 @@
37
37
  },
38
38
  "default": "./dist/cjs/builder/index.js"
39
39
  },
40
- "./config": {
41
- "types": "./dist/types/config/public.d.ts",
42
- "import": "./dist/esm-node/config/public.mjs",
43
- "require": "./dist/cjs/config/public.js",
44
- "default": "./dist/cjs/config/public.js"
45
- },
46
40
  "./cli": {
47
41
  "types": "./dist/types/index.d.ts",
48
42
  "node": {
@@ -59,12 +53,6 @@
59
53
  },
60
54
  "default": "./dist/cjs/run/index.js"
61
55
  },
62
- "./cloudflare-output-verifier": {
63
- "types": "./dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts",
64
- "import": "./dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs",
65
- "require": "./dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js",
66
- "default": "./dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js"
67
- },
68
56
  "./types": {
69
57
  "types": "./lib/types.d.ts",
70
58
  "default": "./lib/types.d.ts"
@@ -91,9 +79,6 @@
91
79
  "builder": [
92
80
  "./dist/types/builder/index.d.ts"
93
81
  ],
94
- "config": [
95
- "./dist/types/config/public.d.ts"
96
- ],
97
82
  "bundle-docs": [
98
83
  "./dist/types/bundleDocs.d.ts"
99
84
  ]
@@ -134,18 +119,18 @@
134
119
  "@babel/traverse": "^8.0.4",
135
120
  "@babel/types": "^8.0.4",
136
121
  "@loadable/component": "5.16.7",
137
- "@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.4",
138
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.4",
139
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.9.0-ultramodern.4",
140
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.4",
141
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.4",
142
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.4",
143
- "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.4",
144
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.4",
145
- "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.4",
146
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.4",
147
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.4",
148
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.4",
122
+ "@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.5",
123
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.5",
124
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.9.0-ultramodern.5",
125
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.5",
126
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.5",
127
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.5",
128
+ "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.5",
129
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.5",
130
+ "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.5",
131
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.5",
132
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.5",
133
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.5",
149
134
  "@rsbuild/core": "2.2.3",
150
135
  "@swc/core": "1.16.2",
151
136
  "@swc/helpers": "^0.5.23",
@@ -173,8 +158,7 @@
173
158
  },
174
159
  "scripts": {
175
160
  "dev": "rslib build --watch",
176
- "build": "rslib build && pnpm run verify:public-surface && node ./bin/modern-bundle-docs.js",
177
- "verify:public-surface": "node ./tests/config/verify-public-surface.mjs",
161
+ "build": "rslib build && node ./bin/modern-bundle-docs.js",
178
162
  "test": "rstest"
179
163
  }
180
164
  }
package/rslib.config.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { rslibConfig } from '@modern-js/rslib';
2
2
  import { defineConfig } from '@rslib/core';
3
- import { publicDeclarationsPlugin } from '../../../scripts/prebundle/ultramodern/public-declarations.mjs';
4
3
 
5
4
  const APP_TOOLS_CODE_ENTRY_GLOBS = [
6
5
  './src/**/*.{js,jsx,ts,tsx,mts,cts}',
@@ -9,10 +8,6 @@ const APP_TOOLS_CODE_ENTRY_GLOBS = [
9
8
 
10
9
  export default defineConfig({
11
10
  ...rslibConfig,
12
- plugins: [
13
- ...(rslibConfig.plugins ?? []),
14
- publicDeclarationsPlugin('app-tools'),
15
- ],
16
11
  lib: rslibConfig.lib?.map(libConfig => {
17
12
  return {
18
13
  ...libConfig,
@@ -1,125 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, getters, values)=>{
14
- var define = (defs, kind)=>{
15
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
- enumerable: true,
17
- [kind]: defs[key]
18
- });
19
- };
20
- define(getters, "get");
21
- define(values, "value");
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- (()=>{
28
- __webpack_require__.r = (exports1)=>{
29
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
- value: 'Module'
31
- });
32
- Object.defineProperty(exports1, '__esModule', {
33
- value: true
34
- });
35
- };
36
- })();
37
- var __webpack_exports__ = {};
38
- __webpack_require__.r(__webpack_exports__);
39
- __webpack_require__.d(__webpack_exports__, {
40
- builderPluginAdapterPrecompress: ()=>builderPluginAdapterPrecompress
41
- });
42
- const external_node_zlib_namespaceObject = require("node:zlib");
43
- const external_compression_webpack_plugin_namespaceObject = require("compression-webpack-plugin");
44
- var external_compression_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_compression_webpack_plugin_namespaceObject);
45
- const DEFAULT_PRECOMPRESS_TEST = /\.(js|mjs|cjs|css|html|svg|json|map)$/i;
46
- const DEFAULT_PRECOMPRESS_THRESHOLD = 10240;
47
- const DEFAULT_PRECOMPRESS_MIN_RATIO = 0.8;
48
- const createDefaultGzipOptions = ()=>({
49
- algorithm: 'gzip',
50
- filename: '[path][base].gz',
51
- test: DEFAULT_PRECOMPRESS_TEST,
52
- threshold: DEFAULT_PRECOMPRESS_THRESHOLD,
53
- minRatio: DEFAULT_PRECOMPRESS_MIN_RATIO,
54
- compressionOptions: {
55
- level: 6
56
- }
57
- });
58
- const createDefaultBrotliOptions = ()=>({
59
- algorithm: 'brotliCompress',
60
- filename: '[path][base].br',
61
- test: DEFAULT_PRECOMPRESS_TEST,
62
- threshold: DEFAULT_PRECOMPRESS_THRESHOLD,
63
- minRatio: DEFAULT_PRECOMPRESS_MIN_RATIO,
64
- compressionOptions: {
65
- params: {
66
- [external_node_zlib_namespaceObject.constants.BROTLI_PARAM_QUALITY]: 9
67
- }
68
- }
69
- });
70
- const mergeCompressionOptions = (base, next)=>{
71
- const merged = {
72
- ...base,
73
- ...next
74
- };
75
- if (base.compressionOptions || next.compressionOptions) {
76
- const baseCompressionOptions = base.compressionOptions;
77
- const nextCompressionOptions = next.compressionOptions;
78
- const mergedCompressionOptions = {
79
- ...baseCompressionOptions,
80
- ...nextCompressionOptions
81
- };
82
- if (baseCompressionOptions?.params || nextCompressionOptions?.params) mergedCompressionOptions.params = {
83
- ...baseCompressionOptions?.params,
84
- ...nextCompressionOptions?.params
85
- };
86
- merged.compressionOptions = mergedCompressionOptions;
87
- }
88
- return merged;
89
- };
90
- const resolveCodecOptions = (codecConfig, createDefaultOptions)=>{
91
- if (false === codecConfig) return null;
92
- if (void 0 === codecConfig || true === codecConfig) return createDefaultOptions();
93
- return mergeCompressionOptions(createDefaultOptions(), codecConfig);
94
- };
95
- const resolvePrecompressConfig = (normalizedConfig)=>{
96
- const precompress = normalizedConfig.output.precompress;
97
- if (false === precompress || void 0 === precompress) return false;
98
- if (true === precompress) return {};
99
- return precompress;
100
- };
101
- const builderPluginAdapterPrecompress = (options)=>({
102
- name: 'builder-plugin-adapter-modern-precompress',
103
- setup (api) {
104
- api.modifyBundlerChain((chain, { isProd, target })=>{
105
- if (!isProd || 'web' !== target) return;
106
- const precompressConfig = resolvePrecompressConfig(options.normalizedConfig);
107
- if (false === precompressConfig) return;
108
- const gzipOptions = resolveCodecOptions(precompressConfig.gzip, createDefaultGzipOptions);
109
- if (gzipOptions) chain.plugin('modern-precompress-gzip').use(external_compression_webpack_plugin_default(), [
110
- gzipOptions
111
- ]);
112
- const brotliOptions = resolveCodecOptions(precompressConfig.brotli, createDefaultBrotliOptions);
113
- if (brotliOptions) chain.plugin('modern-precompress-brotli').use(external_compression_webpack_plugin_default(), [
114
- brotliOptions
115
- ]);
116
- });
117
- }
118
- });
119
- exports.builderPluginAdapterPrecompress = __webpack_exports__.builderPluginAdapterPrecompress;
120
- for(var __rspack_i in __webpack_exports__)if (-1 === [
121
- "builderPluginAdapterPrecompress"
122
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
123
- Object.defineProperty(exports, '__esModule', {
124
- value: true
125
- });
@@ -1,268 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- getBuildConfigEnvironment: ()=>getBuildConfigEnvironment,
32
- resolveEffectTsgoCompiler: ()=>resolveEffectTsgoCompiler,
33
- withBuildConfigEnvironment: ()=>withBuildConfigEnvironment
34
- });
35
- const external_node_child_process_namespaceObject = require("node:child_process");
36
- const external_node_crypto_namespaceObject = require("node:crypto");
37
- const external_node_fs_namespaceObject = require("node:fs");
38
- const external_node_module_namespaceObject = require("node:module");
39
- const external_node_os_namespaceObject = require("node:os");
40
- const external_node_path_namespaceObject = require("node:path");
41
- const EFFECT_TSGO_PACKAGE = '@effect/tsgo';
42
- const EFFECT_TSGO_BIN = 'effect-tsgo';
43
- const EFFECT_TSGO_RESOLUTION_ERROR = 'Unable to resolve the Effect TS-Go compiler. Install "@effect/tsgo" and a native TypeScript backend for this build config, or set EFFECT_TSGO_BIN.';
44
- const executableEffectTsgoCompilers = new Map();
45
- const BUILD_CONFIG_ENVIRONMENT_PLUGIN = 'ModernJsBuildConfigEnvironmentLeasePlugin';
46
- const ENVIRONMENT_LEASE_REGISTRY_KEY = Symbol.for('@modern-js/app-tools/build-config-environment-lease-registry/v1');
47
- const ENVIRONMENT_LEASE_REGISTRY_BRAND = Symbol.for('@modern-js/app-tools/build-config-environment-lease-registry-brand/v1');
48
- const LIFECYCLE_HOOK_NAMES = [
49
- 'run',
50
- 'watchRun',
51
- 'afterDone',
52
- 'failed',
53
- 'shutdown',
54
- 'watchClose'
55
- ];
56
- function restoreEnvironment(name, value) {
57
- if (void 0 === value) delete process.env[name];
58
- else process.env[name] = value;
59
- }
60
- function createEnvironmentLeaseRegistry() {
61
- const environmentLeases = new Map();
62
- return Object.freeze({
63
- acquire (name, value) {
64
- let lease = environmentLeases.get(name);
65
- if (lease) {
66
- if (lease.value !== value) throw new Error(`Build config environment "${name}" already has an active lease for a different value.`);
67
- if (process.env[name] !== lease.value) throw new Error(`Build config environment lease for "${name}" lost ownership before another lease was acquired.`);
68
- } else {
69
- lease = {
70
- originalValue: process.env[name],
71
- owners: new Set(),
72
- value
73
- };
74
- process.env[name] = value;
75
- environmentLeases.set(name, lease);
76
- }
77
- const owner = Symbol(name);
78
- lease.owners.add(owner);
79
- let released = false;
80
- return ()=>{
81
- if (released) return;
82
- if (environmentLeases.get(name) !== lease || !lease.owners.has(owner)) throw new Error(`Build config environment lease for "${name}" cannot be restored because its ownership record was lost.`);
83
- released = true;
84
- const lostOwnership = process.env[name] !== lease.value;
85
- lease.owners.delete(owner);
86
- if (0 === lease.owners.size) {
87
- environmentLeases.delete(name);
88
- restoreEnvironment(name, lease.originalValue);
89
- } else if (lostOwnership) process.env[name] = lease.value;
90
- if (lostOwnership) throw new Error(`Build config environment lease for "${name}" lost ownership before restoration.`);
91
- };
92
- },
93
- brand: ENVIRONMENT_LEASE_REGISTRY_BRAND
94
- });
95
- }
96
- function getEnvironmentLeaseRegistry() {
97
- const descriptor = Object.getOwnPropertyDescriptor(process, ENVIRONMENT_LEASE_REGISTRY_KEY);
98
- if (descriptor) {
99
- const registry = descriptor.value;
100
- if (descriptor.configurable || descriptor.enumerable || descriptor.writable || registry?.brand !== ENVIRONMENT_LEASE_REGISTRY_BRAND || 'function' != typeof registry.acquire) throw new Error('The process-global build config environment lease registry is occupied by an incompatible value.');
101
- return registry;
102
- }
103
- const registry = createEnvironmentLeaseRegistry();
104
- Object.defineProperty(process, ENVIRONMENT_LEASE_REGISTRY_KEY, {
105
- configurable: false,
106
- enumerable: false,
107
- value: registry,
108
- writable: false
109
- });
110
- return registry;
111
- }
112
- function acquireEnvironmentLease(name, value) {
113
- return getEnvironmentLeaseRegistry().acquire(name, value);
114
- }
115
- function releaseAfterFailure(release, originalError) {
116
- try {
117
- release();
118
- } catch (restorationError) {
119
- throw new AggregateError([
120
- originalError,
121
- restorationError
122
- ], 'Build config environment setup and restoration both failed.');
123
- }
124
- throw originalError;
125
- }
126
- class BuildConfigEnvironmentLeasePlugin {
127
- apply(compiler) {
128
- const hooks = compiler.hooks;
129
- try {
130
- const lifecycleHooks = {};
131
- for (const hookName of LIFECYCLE_HOOK_NAMES){
132
- const hook = hooks[hookName];
133
- if (!hook || 'function' != typeof hook.tap) throw new Error(`Rspack does not expose the "${hookName}" lifecycle hook required to restore build config environment leases.`);
134
- lifecycleHooks[hookName] = hook;
135
- }
136
- let mode = 'pending';
137
- const modeTap = {
138
- name: BUILD_CONFIG_ENVIRONMENT_PLUGIN,
139
- stage: Number.MIN_SAFE_INTEGER
140
- };
141
- const releaseTap = {
142
- name: BUILD_CONFIG_ENVIRONMENT_PLUGIN,
143
- stage: Number.MAX_SAFE_INTEGER
144
- };
145
- const releaseAfterOneShot = ()=>{
146
- if ('watch' !== mode && true !== compiler.watchMode) this.release();
147
- };
148
- lifecycleHooks.run.tap(modeTap, ()=>{
149
- mode = 'run';
150
- });
151
- lifecycleHooks.watchRun.tap(modeTap, ()=>{
152
- mode = 'watch';
153
- });
154
- lifecycleHooks.afterDone.tap(releaseTap, releaseAfterOneShot);
155
- lifecycleHooks.failed.tap(releaseTap, releaseAfterOneShot);
156
- lifecycleHooks.shutdown.tap(releaseTap, this.release);
157
- lifecycleHooks.watchClose.tap(releaseTap, this.release);
158
- } catch (error) {
159
- releaseAfterFailure(this.release, error);
160
- }
161
- }
162
- constructor(release){
163
- this.release = release;
164
- }
165
- }
166
- function resolveEffectTsgoCli(from) {
167
- const projectRequire = (0, external_node_module_namespaceObject.createRequire)(from);
168
- const packageJsonPath = projectRequire.resolve(`${EFFECT_TSGO_PACKAGE}/package.json`);
169
- const packageJson = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(packageJsonPath, 'utf-8'));
170
- const bin = 'string' == typeof packageJson.bin ? packageJson.bin : packageJson.bin?.[EFFECT_TSGO_BIN];
171
- if (!bin) throw new Error(EFFECT_TSGO_RESOLUTION_ERROR);
172
- return (0, external_node_path_namespaceObject.resolve)((0, external_node_path_namespaceObject.dirname)(packageJsonPath), bin);
173
- }
174
- function resolveExecutableEffectTsgoCompiler(compilerPath) {
175
- if ('win32' === process.platform) return compilerPath;
176
- const sourcePath = (0, external_node_fs_namespaceObject.realpathSync)(compilerPath);
177
- const source = (0, external_node_fs_namespaceObject.lstatSync)(sourcePath);
178
- if (!source.isFile()) throw new Error(EFFECT_TSGO_RESOLUTION_ERROR);
179
- try {
180
- (0, external_node_fs_namespaceObject.accessSync)(sourcePath, external_node_fs_namespaceObject.constants.X_OK);
181
- return compilerPath;
182
- } catch {}
183
- const cachedCompiler = executableEffectTsgoCompilers.get(sourcePath);
184
- if (cachedCompiler) try {
185
- (0, external_node_fs_namespaceObject.accessSync)(cachedCompiler, external_node_fs_namespaceObject.constants.X_OK);
186
- return cachedCompiler;
187
- } catch {
188
- executableEffectTsgoCompilers.delete(sourcePath);
189
- }
190
- const compilerBytes = (0, external_node_fs_namespaceObject.readFileSync)(sourcePath);
191
- const compilerDigest = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(compilerBytes).digest('hex');
192
- const compilerDirectory = (0, external_node_path_namespaceObject.join)((0, external_node_os_namespaceObject.tmpdir)(), 'modern-js', 'effect-tsgo', compilerDigest);
193
- (0, external_node_fs_namespaceObject.mkdirSync)(compilerDirectory, {
194
- recursive: true,
195
- mode: 448
196
- });
197
- const executableCompiler = (0, external_node_path_namespaceObject.join)(compilerDirectory, (0, external_node_path_namespaceObject.basename)(sourcePath));
198
- try {
199
- (0, external_node_fs_namespaceObject.accessSync)(executableCompiler, external_node_fs_namespaceObject.constants.X_OK);
200
- } catch {
201
- const temporaryCompiler = (0, external_node_path_namespaceObject.join)(compilerDirectory, `.${(0, external_node_path_namespaceObject.basename)(sourcePath)}.${process.pid}.tmp`);
202
- (0, external_node_fs_namespaceObject.rmSync)(temporaryCompiler, {
203
- force: true
204
- });
205
- try {
206
- (0, external_node_fs_namespaceObject.writeFileSync)(temporaryCompiler, compilerBytes, {
207
- flag: 'wx',
208
- mode: 448
209
- });
210
- (0, external_node_fs_namespaceObject.chmodSync)(temporaryCompiler, 448);
211
- (0, external_node_fs_namespaceObject.renameSync)(temporaryCompiler, executableCompiler);
212
- } finally{
213
- (0, external_node_fs_namespaceObject.rmSync)(temporaryCompiler, {
214
- force: true
215
- });
216
- }
217
- }
218
- (0, external_node_fs_namespaceObject.accessSync)(executableCompiler, external_node_fs_namespaceObject.constants.X_OK);
219
- executableEffectTsgoCompilers.set(sourcePath, executableCompiler);
220
- return executableCompiler;
221
- }
222
- function getBuildConfigEnvironment(name) {
223
- return process.env[name];
224
- }
225
- function withBuildConfigEnvironment(name, value, setup) {
226
- return async (config, ...args)=>{
227
- const release = acquireEnvironmentLease(name, value);
228
- try {
229
- const configured = await setup(config, ...args) ?? config;
230
- configured.plugins = [
231
- ...configured.plugins ?? [],
232
- new BuildConfigEnvironmentLeasePlugin(release)
233
- ];
234
- return configured;
235
- } catch (error) {
236
- releaseAfterFailure(release, error);
237
- }
238
- };
239
- }
240
- function resolveEffectTsgoCompiler(options) {
241
- const configuredCompiler = getBuildConfigEnvironment('EFFECT_TSGO_BIN')?.trim();
242
- if (configuredCompiler) try {
243
- return resolveExecutableEffectTsgoCompiler(configuredCompiler);
244
- } catch {
245
- throw new Error(EFFECT_TSGO_RESOLUTION_ERROR);
246
- }
247
- try {
248
- const compiler = (0, external_node_child_process_namespaceObject.execFileSync)(process.execPath, [
249
- resolveEffectTsgoCli(options.from),
250
- 'get-exe-path'
251
- ], {
252
- encoding: 'utf-8'
253
- }).trim();
254
- if (compiler) return resolveExecutableEffectTsgoCompiler(compiler);
255
- } catch {}
256
- throw new Error(EFFECT_TSGO_RESOLUTION_ERROR);
257
- }
258
- exports.getBuildConfigEnvironment = __webpack_exports__.getBuildConfigEnvironment;
259
- exports.resolveEffectTsgoCompiler = __webpack_exports__.resolveEffectTsgoCompiler;
260
- exports.withBuildConfigEnvironment = __webpack_exports__.withBuildConfigEnvironment;
261
- for(var __rspack_i in __webpack_exports__)if (-1 === [
262
- "getBuildConfigEnvironment",
263
- "resolveEffectTsgoCompiler",
264
- "withBuildConfigEnvironment"
265
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
266
- Object.defineProperty(exports, '__esModule', {
267
- value: true
268
- });
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- getBuildConfigEnvironment: ()=>external_build_environment_js_namespaceObject.getBuildConfigEnvironment,
32
- resolveEffectTsgoCompiler: ()=>external_build_environment_js_namespaceObject.resolveEffectTsgoCompiler,
33
- withBuildConfigEnvironment: ()=>external_build_environment_js_namespaceObject.withBuildConfigEnvironment
34
- });
35
- const external_build_environment_js_namespaceObject = require("./build-environment.js");
36
- exports.getBuildConfigEnvironment = __webpack_exports__.getBuildConfigEnvironment;
37
- exports.resolveEffectTsgoCompiler = __webpack_exports__.resolveEffectTsgoCompiler;
38
- exports.withBuildConfigEnvironment = __webpack_exports__.withBuildConfigEnvironment;
39
- for(var __rspack_i in __webpack_exports__)if (-1 === [
40
- "getBuildConfigEnvironment",
41
- "resolveEffectTsgoCompiler",
42
- "withBuildConfigEnvironment"
43
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
- Object.defineProperty(exports, '__esModule', {
45
- value: true
46
- });