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

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.
@@ -61,7 +61,7 @@ const serverAppContextTemplate = (appContext)=>{
61
61
  };
62
62
  const genPluginImportsCode = (plugins, isESM = false)=>plugins.map(([name, options], index)=>{
63
63
  const im = isESM ? `import * as plugin_${index}_ns from '${name}'` : `const plugin_${index}_ns = require('${name}')`;
64
- return `${im};const plugin_${index} = plugin_${index}_ns.default || plugin_${index}_ns`;
64
+ return `${im};const plugin_${index} = typeof plugin_${index}_ns === 'function' ? plugin_${index}_ns : typeof plugin_${index}_ns.default === 'function' ? plugin_${index}_ns.default : plugin_${index}_ns.default?.default`;
65
65
  }).join(';\n');
66
66
  const getPluginsCode = (plugins)=>`[${plugins.map(([, options], index)=>`plugin_${index}(${options ? JSON.stringify(options) : ''})`).join(',')}]`;
67
67
  const getServerConfigPath = (meta)=>`path.join(__dirname, "${utils_namespaceObject.SERVER_DIR}", "${meta}.server")`;
@@ -45,9 +45,11 @@ const external_node_fs_namespaceObject = require("node:fs");
45
45
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
46
46
  const external_node_path_namespaceObject = require("node:path");
47
47
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
48
+ const native_type_checker_namespaceObject = require("@modern-js/app-tools-extensions/native-type-checker");
48
49
  const release_identity_namespaceObject = require("@modern-js/app-tools-extensions/release-identity");
49
50
  const cli_namespaceObject = require("@modern-js/plugin/cli");
50
51
  const core_namespaceObject = require("@rsbuild/core");
52
+ const build_environment_js_namespaceObject = require("./config/build-environment.js");
51
53
  const ultramodernReleaseEnvelope_js_namespaceObject = require("./plugins/ultramodernReleaseEnvelope.js");
52
54
  var ultramodernReleaseEnvelope_js_default = /*#__PURE__*/ __webpack_require__.n(ultramodernReleaseEnvelope_js_namespaceObject);
53
55
  const DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318/v1/logs';
@@ -130,7 +132,12 @@ const createPresetUltramodernConfig = (options = {})=>{
130
132
  } : {}
131
133
  },
132
134
  tools: {
133
- bundlerChain: setReactRouterBridgeSafeAliases,
135
+ bundlerChain: (chain, utils)=>{
136
+ setReactRouterBridgeSafeAliases(chain, utils);
137
+ (0, native_type_checker_namespaceObject.configureUltramodernTypeChecker)(chain, utils.CHAIN_ID.PLUGIN.TS_CHECKER, (from)=>(0, build_environment_js_namespaceObject.resolveEffectTsgoCompiler)({
138
+ from
139
+ }));
140
+ },
134
141
  lightningcssLoader: true,
135
142
  ...bundledReleaseIdentity ? {
136
143
  rspack: (config)=>{
@@ -15,7 +15,7 @@ const serverAppContextTemplate = (appContext)=>{
15
15
  };
16
16
  const genPluginImportsCode = (plugins, isESM = false)=>plugins.map(([name, options], index)=>{
17
17
  const im = isESM ? `import * as plugin_${index}_ns from '${name}'` : `const plugin_${index}_ns = require('${name}')`;
18
- return `${im};const plugin_${index} = plugin_${index}_ns.default || plugin_${index}_ns`;
18
+ return `${im};const plugin_${index} = typeof plugin_${index}_ns === 'function' ? plugin_${index}_ns : typeof plugin_${index}_ns.default === 'function' ? plugin_${index}_ns.default : plugin_${index}_ns.default?.default`;
19
19
  }).join(';\n');
20
20
  const getPluginsCode = (plugins)=>`[${plugins.map(([, options], index)=>`plugin_${index}(${options ? JSON.stringify(options) : ''})`).join(',')}]`;
21
21
  const getServerConfigPath = (meta)=>`path.join(__dirname, "${SERVER_DIR}", "${meta}.server")`;
@@ -1,8 +1,10 @@
1
1
  import node_fs from "node:fs";
2
2
  import node_path from "node:path";
3
+ import { configureUltramodernTypeChecker } from "@modern-js/app-tools-extensions/native-type-checker";
3
4
  import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensions/release-identity";
4
5
  import { mergeConfig } from "@modern-js/plugin/cli";
5
6
  import { rspack } from "@rsbuild/core";
7
+ import { resolveEffectTsgoCompiler } from "./config/build-environment.mjs";
6
8
  const DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318/v1/logs';
7
9
  const DEFAULT_VICTORIA_METRICS_ENDPOINT = 'http://127.0.0.1:8428/api/v1/import/prometheus';
8
10
  const resolveReactRouterPackageDir = (appDirectory)=>{
@@ -83,7 +85,12 @@ const createPresetUltramodernConfig = (options = {})=>{
83
85
  } : {}
84
86
  },
85
87
  tools: {
86
- bundlerChain: setReactRouterBridgeSafeAliases,
88
+ bundlerChain: (chain, utils)=>{
89
+ setReactRouterBridgeSafeAliases(chain, utils);
90
+ configureUltramodernTypeChecker(chain, utils.CHAIN_ID.PLUGIN.TS_CHECKER, (from)=>resolveEffectTsgoCompiler({
91
+ from
92
+ }));
93
+ },
87
94
  lightningcssLoader: true,
88
95
  ...bundledReleaseIdentity ? {
89
96
  rspack: (config)=>{
@@ -16,7 +16,7 @@ const serverAppContextTemplate = (appContext)=>{
16
16
  };
17
17
  const genPluginImportsCode = (plugins, isESM = false)=>plugins.map(([name, options], index)=>{
18
18
  const im = isESM ? `import * as plugin_${index}_ns from '${name}'` : `const plugin_${index}_ns = require('${name}')`;
19
- return `${im};const plugin_${index} = plugin_${index}_ns.default || plugin_${index}_ns`;
19
+ return `${im};const plugin_${index} = typeof plugin_${index}_ns === 'function' ? plugin_${index}_ns : typeof plugin_${index}_ns.default === 'function' ? plugin_${index}_ns.default : plugin_${index}_ns.default?.default`;
20
20
  }).join(';\n');
21
21
  const getPluginsCode = (plugins)=>`[${plugins.map(([, options], index)=>`plugin_${index}(${options ? JSON.stringify(options) : ''})`).join(',')}]`;
22
22
  const getServerConfigPath = (meta)=>`path.join(__dirname, "${SERVER_DIR}", "${meta}.server")`;
@@ -1,9 +1,11 @@
1
1
  import "node:module";
2
2
  import node_fs from "node:fs";
3
3
  import node_path from "node:path";
4
+ import { configureUltramodernTypeChecker } from "@modern-js/app-tools-extensions/native-type-checker";
4
5
  import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensions/release-identity";
5
6
  import { mergeConfig } from "@modern-js/plugin/cli";
6
7
  import { rspack } from "@rsbuild/core";
8
+ import { resolveEffectTsgoCompiler } from "./config/build-environment.mjs";
7
9
  const DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318/v1/logs';
8
10
  const DEFAULT_VICTORIA_METRICS_ENDPOINT = 'http://127.0.0.1:8428/api/v1/import/prometheus';
9
11
  const resolveReactRouterPackageDir = (appDirectory)=>{
@@ -84,7 +86,12 @@ const createPresetUltramodernConfig = (options = {})=>{
84
86
  } : {}
85
87
  },
86
88
  tools: {
87
- bundlerChain: setReactRouterBridgeSafeAliases,
89
+ bundlerChain: (chain, utils)=>{
90
+ setReactRouterBridgeSafeAliases(chain, utils);
91
+ configureUltramodernTypeChecker(chain, utils.CHAIN_ID.PLUGIN.TS_CHECKER, (from)=>resolveEffectTsgoCompiler({
92
+ from
93
+ }));
94
+ },
88
95
  lightningcssLoader: true,
89
96
  ...bundledReleaseIdentity ? {
90
97
  rspack: (config)=>{
@@ -0,0 +1,20 @@
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ type BasePluginOptions<T> = {
2
+ /**
3
+ * include all assets that pass test assertion
4
+ */
5
+ test?: Rules | undefined;
6
+ /**
7
+ * include all assets matching any of these conditions
8
+ */
9
+ include?: Rules | undefined;
10
+ /**
11
+ * exclude all assets matching any of these conditions
12
+ */
13
+ exclude?: Rules | undefined;
14
+ /**
15
+ * only assets bigger than this size are processed, in bytes
16
+ */
17
+ threshold?: number | undefined;
18
+ /**
19
+ * only assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`)
20
+ */
21
+ minRatio?: number | undefined;
22
+ /**
23
+ * whether to delete the original assets or not
24
+ */
25
+ deleteOriginalAssets?: DeleteOriginalAssets | undefined;
26
+ /**
27
+ * the target asset filename
28
+ */
29
+ filename?: Filename | undefined;
30
+ };
31
+ type Rules = Rule[] | Rule;
32
+ type Rule = RegExp | string;
33
+ type DeleteOriginalAssets =
34
+ | boolean
35
+ | "keep-source-map"
36
+ | ((name: string) => boolean);
37
+ type Filename = string | ((fileData: PathData) => string);
38
+ type PathData = import('@rsbuild/core').Rspack.PathData;
39
+ type DefinedDefaultAlgorithmAndOptions<T> = T extends ZlibOptions
40
+ ? {
41
+ algorithm?: string | AlgorithmFunction<T> | undefined;
42
+ compressionOptions?: CompressionOptions<T> | undefined;
43
+ }
44
+ : {
45
+ algorithm: string | AlgorithmFunction<T>;
46
+ compressionOptions?: CompressionOptions<T> | undefined;
47
+ };
48
+ type ZlibOptions = import("zlib").ZlibOptions;
49
+ type AlgorithmFunction<T> = (
50
+ input: Buffer,
51
+ options: CompressionOptions<T>,
52
+ callback: (
53
+ error: Error | null | undefined,
54
+ result:
55
+ | WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>
56
+ | Uint8Array
57
+ | ReadonlyArray<number>
58
+ | WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>
59
+ | WithImplicitCoercion<string>
60
+ | {
61
+ [Symbol.toPrimitive](hint: "string"): string;
62
+ },
63
+ ) => void,
64
+ ) => any;
65
+ type CompressionOptions<T> = InferDefaultType<T>;
66
+ type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
67
+ type CustomOptions = {
68
+ [key: string]: EXPECTED_ANY;
69
+ };
70
+ type EXPECTED_ANY = any;
71
+ type WithImplicitCoercion<T> =
72
+ | T
73
+ | {
74
+ valueOf(): T;
75
+ };
76
+ export type CompressionPluginOptions = BasePluginOptions<ZlibOptions> & DefinedDefaultAlgorithmAndOptions<ZlibOptions>;
@@ -1,5 +1,4 @@
1
- import type CompressionPlugin from 'compression-webpack-plugin';
2
- type CompressionPluginOptions = NonNullable<ConstructorParameters<typeof CompressionPlugin>[0]>;
1
+ import type { CompressionPluginOptions } from '../../precompress/index.js';
3
2
  export type PrecompressCodecOptions = boolean | CompressionPluginOptions;
4
3
  export interface PrecompressConfig {
5
4
  /**
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.2",
20
+ "version": "3.9.0-ultramodern.4",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -134,18 +134,18 @@
134
134
  "@babel/traverse": "^8.0.4",
135
135
  "@babel/types": "^8.0.4",
136
136
  "@loadable/component": "5.16.7",
137
- "@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.2",
138
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.2",
139
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.9.0-ultramodern.2",
140
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.2",
141
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.2",
142
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.2",
143
- "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.2",
144
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.2",
145
- "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.2",
146
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.2",
147
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.2",
148
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.2",
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",
149
149
  "@rsbuild/core": "2.2.3",
150
150
  "@swc/core": "1.16.2",
151
151
  "@swc/helpers": "^0.5.23",
package/rslib.config.mts CHANGED
@@ -1,5 +1,6 @@
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';
3
4
 
4
5
  const APP_TOOLS_CODE_ENTRY_GLOBS = [
5
6
  './src/**/*.{js,jsx,ts,tsx,mts,cts}',
@@ -8,6 +9,10 @@ const APP_TOOLS_CODE_ENTRY_GLOBS = [
8
9
 
9
10
  export default defineConfig({
10
11
  ...rslibConfig,
12
+ plugins: [
13
+ ...(rslibConfig.plugins ?? []),
14
+ publicDeclarationsPlugin('app-tools'),
15
+ ],
11
16
  lib: rslibConfig.lib?.map(libConfig => {
12
17
  return {
13
18
  ...libConfig,