@modern-js/app-tools 3.1.0 → 3.1.1

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 (27) hide show
  1. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +1 -1
  2. package/dist/cjs/plugins/deploy/utils/generator.js +4 -3
  3. package/dist/esm/builder/generator/createCopyPattern.mjs +1 -1
  4. package/dist/esm/builder/index.mjs +3 -3
  5. package/dist/esm/builder/shared/loaders/serverModuleLoader.mjs +1 -1
  6. package/dist/esm/index.mjs +9 -8
  7. package/dist/esm/plugins/analyze/index.mjs +2 -2
  8. package/dist/esm/plugins/deploy/index.mjs +1 -1
  9. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +1 -1
  10. package/dist/esm/plugins/deploy/utils/generator.mjs +4 -3
  11. package/dist/esm/plugins/initialize/index.mjs +1 -1
  12. package/dist/esm/plugins/serverBuild.mjs +1 -1
  13. package/dist/esm/plugins/serverRuntime.mjs +1 -1
  14. package/dist/esm-node/builder/generator/createCopyPattern.mjs +1 -1
  15. package/dist/esm-node/builder/index.mjs +3 -3
  16. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.mjs +1 -1
  17. package/dist/esm-node/index.mjs +9 -8
  18. package/dist/esm-node/plugins/analyze/index.mjs +1 -1
  19. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  20. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +1 -1
  21. package/dist/esm-node/plugins/deploy/utils/generator.mjs +4 -3
  22. package/dist/esm-node/plugins/initialize/index.mjs +1 -1
  23. package/dist/esm-node/plugins/serverBuild.mjs +1 -1
  24. package/dist/esm-node/plugins/serverRuntime.mjs +1 -1
  25. package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.cts +2 -1
  26. package/package.json +12 -12
  27. package/{rstest.config.ts → rstest.config.mts} +0 -4
@@ -54,4 +54,4 @@ const handler = async (request, context)=>{
54
54
  if (!requestHandler) await createHandler();
55
55
  return requestHandler(request, context);
56
56
  };
57
- exports.handler = handler;
57
+ module.exports.default = handler;
@@ -46,10 +46,11 @@ const lodash_namespaceObject = require("@modern-js/utils/lodash");
46
46
  const external_index_js_namespaceObject = require("./index.js");
47
47
  const serverAppContextTemplate = (appContext)=>{
48
48
  const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName, bffRuntimeFramework } = appContext;
49
+ const getRelativePathTemplate = (targetDirectory)=>`path.join(__dirname, ${JSON.stringify((0, external_index_js_namespaceObject.normalizePath)(external_node_path_default().relative(appDirectory, targetDirectory)))})`;
49
50
  return {
50
- sharedDirectory: `path.join(__dirname, "${(0, external_index_js_namespaceObject.normalizePath)(external_node_path_default().relative(appDirectory, sharedDirectory))}")`,
51
- apiDirectory: `path.join(__dirname, "${(0, external_index_js_namespaceObject.normalizePath)(external_node_path_default().relative(appDirectory, apiDirectory))}")`,
52
- lambdaDirectory: `path.join(__dirname, "${(0, external_index_js_namespaceObject.normalizePath)(external_node_path_default().relative(appDirectory, lambdaDirectory))}")`,
51
+ sharedDirectory: getRelativePathTemplate(sharedDirectory),
52
+ apiDirectory: getRelativePathTemplate(apiDirectory),
53
+ lambdaDirectory: getRelativePathTemplate(lambdaDirectory),
53
54
  metaName,
54
55
  bffRuntimeFramework: bffRuntimeFramework || 'hono'
55
56
  };
@@ -7,7 +7,7 @@ const info = (file)=>({
7
7
  function createPublicPattern(appContext, config, chain) {
8
8
  const { publicDir } = createCopyInfo(appContext, config);
9
9
  return {
10
- info,
10
+ info: info,
11
11
  from: '**/*',
12
12
  to: 'public',
13
13
  context: publicDir,
@@ -1,7 +1,7 @@
1
- import { parseRspackConfig } from "@modern-js/builder";
2
- import { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./shared/builderPlugins/index.mjs";
3
1
  async function createBuilderGenerator() {
4
2
  const { createRspackBuilderForModern } = await import("./builder-rspack/index.mjs");
5
3
  return createRspackBuilderForModern;
6
4
  }
7
- export { builderPluginAdapterBasic, builderPluginAdapterHooks, createBuilderGenerator, parseRspackConfig };
5
+ export { parseRspackConfig } from "@modern-js/builder";
6
+ export { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./shared/builderPlugins/index.mjs";
7
+ export { createBuilderGenerator };
@@ -2,4 +2,4 @@ function loader() {
2
2
  return "module.exports = {}";
3
3
  }
4
4
  const serverModuleLoader = loader;
5
- export { serverModuleLoader as default };
5
+ export default serverModuleLoader;
@@ -1,3 +1,5 @@
1
+ export * from "./defineConfig.mjs";
2
+ export * from "./types/index.mjs";
1
3
  import path from "path";
2
4
  import { castArray } from "@modern-js/builder";
3
5
  import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
@@ -15,13 +17,6 @@ import serverRuntime from "./plugins/serverRuntime.mjs";
15
17
  import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
16
18
  import { initAppContext } from "./utils/initAppContext.mjs";
17
19
  import { restart } from "./utils/restart.mjs";
18
- import { defineConfig } from "./defineConfig.mjs";
19
- import { dev } from "./commands/dev.mjs";
20
- import { serve } from "./commands/serve.mjs";
21
- import { resolveModernRsbuildConfig } from "./rsbuild.mjs";
22
- import { mergeConfig } from "@modern-js/plugin/cli";
23
- export * from "./defineConfig.mjs";
24
- export * from "./types/index.mjs";
25
20
  const appTools = ()=>({
26
21
  name: '@modern-js/app-tools',
27
22
  usePlugins: [
@@ -120,4 +115,10 @@ const appTools = ()=>({
120
115
  }
121
116
  });
122
117
  const src = appTools;
123
- export { appTools, src as default, defineConfig, dev, generateWatchFiles, initAppContext, mergeConfig, resolveModernRsbuildConfig, serve };
118
+ export { defineConfig } from "./defineConfig.mjs";
119
+ export { dev } from "./commands/dev.mjs";
120
+ export { serve } from "./commands/serve.mjs";
121
+ export { resolveModernRsbuildConfig } from "./rsbuild.mjs";
122
+ export { mergeConfig } from "@modern-js/plugin/cli";
123
+ export default src;
124
+ export { appTools, generateWatchFiles, initAppContext };
@@ -174,7 +174,7 @@ const analyze = ()=>({
174
174
  const getFlattenedPlugins = async (pluginOptions)=>{
175
175
  let plugins = pluginOptions;
176
176
  do plugins = (await Promise.all(plugins)).flat(1 / 0);
177
- while (plugins.some((v)=>isPromise(v)));
177
+ while (plugins.some((v)=>isPromise(v)))
178
178
  return plugins;
179
179
  };
180
180
  if (resolvedConfig.builderPlugins) {
@@ -200,4 +200,4 @@ const analyze = ()=>({
200
200
  });
201
201
  }
202
202
  });
203
- export { analyze as default };
203
+ export default analyze;
@@ -40,4 +40,4 @@ const deploy = ()=>({
40
40
  });
41
41
  }
42
42
  });
43
- export { deploy as default };
43
+ export default deploy;
@@ -54,4 +54,4 @@ const handler = async (request, context)=>{
54
54
  if (!requestHandler) await createHandler();
55
55
  return requestHandler(request, context);
56
56
  };
57
- exports.handler = handler;
57
+ module.exports.default = handler;
@@ -4,10 +4,11 @@ import { merge } from "@modern-js/utils/lodash";
4
4
  import { normalizePath } from "./index.mjs";
5
5
  const serverAppContextTemplate = (appContext)=>{
6
6
  const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName, bffRuntimeFramework } = appContext;
7
+ const getRelativePathTemplate = (targetDirectory)=>`path.join(__dirname, ${JSON.stringify(normalizePath(node_path.relative(appDirectory, targetDirectory)))})`;
7
8
  return {
8
- sharedDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, sharedDirectory))}")`,
9
- apiDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, apiDirectory))}")`,
10
- lambdaDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, lambdaDirectory))}")`,
9
+ sharedDirectory: getRelativePathTemplate(sharedDirectory),
10
+ apiDirectory: getRelativePathTemplate(apiDirectory),
11
+ lambdaDirectory: getRelativePathTemplate(lambdaDirectory),
11
12
  metaName,
12
13
  bffRuntimeFramework: bffRuntimeFramework || 'hono'
13
14
  };
@@ -56,4 +56,4 @@ async function getServerPort(config) {
56
56
  if (isDev() && isDevCommand()) return getPort(Number(process.env.PORT) || prodPort);
57
57
  return prodPort;
58
58
  }
59
- export { initialize as default };
59
+ export default initialize;
@@ -43,4 +43,4 @@ const serverBuild = ()=>({
43
43
  });
44
44
  }
45
45
  });
46
- export { serverBuild as default };
46
+ export default serverBuild;
@@ -12,4 +12,4 @@ const serverRuntime = ()=>({
12
12
  }));
13
13
  }
14
14
  });
15
- export { serverRuntime as default };
15
+ export default serverRuntime;
@@ -8,7 +8,7 @@ const info = (file)=>({
8
8
  function createPublicPattern(appContext, config, chain) {
9
9
  const { publicDir } = createCopyInfo(appContext, config);
10
10
  return {
11
- info,
11
+ info: info,
12
12
  from: '**/*',
13
13
  to: 'public',
14
14
  context: publicDir,
@@ -1,8 +1,8 @@
1
1
  import "node:module";
2
- import { parseRspackConfig } from "@modern-js/builder";
3
- import { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./shared/builderPlugins/index.mjs";
4
2
  async function createBuilderGenerator() {
5
3
  const { createRspackBuilderForModern } = await import("./builder-rspack/index.mjs");
6
4
  return createRspackBuilderForModern;
7
5
  }
8
- export { builderPluginAdapterBasic, builderPluginAdapterHooks, createBuilderGenerator, parseRspackConfig };
6
+ export { parseRspackConfig } from "@modern-js/builder";
7
+ export { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./shared/builderPlugins/index.mjs";
8
+ export { createBuilderGenerator };
@@ -3,4 +3,4 @@ function loader() {
3
3
  return "module.exports = {}";
4
4
  }
5
5
  const serverModuleLoader = loader;
6
- export { serverModuleLoader as default };
6
+ export default serverModuleLoader;
@@ -1,5 +1,7 @@
1
1
  import __rslib_shim_module__ from "node:module";
2
2
  const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
3
+ export * from "./defineConfig.mjs";
4
+ export * from "./types/index.mjs";
3
5
  import path from "path";
4
6
  import { castArray } from "@modern-js/builder";
5
7
  import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
@@ -17,13 +19,6 @@ import serverRuntime from "./plugins/serverRuntime.mjs";
17
19
  import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
18
20
  import { initAppContext } from "./utils/initAppContext.mjs";
19
21
  import { restart } from "./utils/restart.mjs";
20
- import { defineConfig } from "./defineConfig.mjs";
21
- import { dev } from "./commands/dev.mjs";
22
- import { serve } from "./commands/serve.mjs";
23
- import { resolveModernRsbuildConfig } from "./rsbuild.mjs";
24
- import { mergeConfig } from "@modern-js/plugin/cli";
25
- export * from "./defineConfig.mjs";
26
- export * from "./types/index.mjs";
27
22
  const appTools = ()=>({
28
23
  name: '@modern-js/app-tools',
29
24
  usePlugins: [
@@ -122,4 +117,10 @@ const appTools = ()=>({
122
117
  }
123
118
  });
124
119
  const src = appTools;
125
- export { appTools, src as default, defineConfig, dev, generateWatchFiles, initAppContext, mergeConfig, resolveModernRsbuildConfig, serve };
120
+ export { defineConfig } from "./defineConfig.mjs";
121
+ export { dev } from "./commands/dev.mjs";
122
+ export { serve } from "./commands/serve.mjs";
123
+ export { resolveModernRsbuildConfig } from "./rsbuild.mjs";
124
+ export { mergeConfig } from "@modern-js/plugin/cli";
125
+ export default src;
126
+ export { appTools, generateWatchFiles, initAppContext };
@@ -201,4 +201,4 @@ const analyze = ()=>({
201
201
  });
202
202
  }
203
203
  });
204
- export { analyze as default };
204
+ export default analyze;
@@ -41,4 +41,4 @@ const deploy = ()=>({
41
41
  });
42
42
  }
43
43
  });
44
- export { deploy as default };
44
+ export default deploy;
@@ -54,4 +54,4 @@ const handler = async (request, context)=>{
54
54
  if (!requestHandler) await createHandler();
55
55
  return requestHandler(request, context);
56
56
  };
57
- exports.handler = handler;
57
+ module.exports.default = handler;
@@ -5,10 +5,11 @@ import { merge } from "@modern-js/utils/lodash";
5
5
  import { normalizePath } from "./index.mjs";
6
6
  const serverAppContextTemplate = (appContext)=>{
7
7
  const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName, bffRuntimeFramework } = appContext;
8
+ const getRelativePathTemplate = (targetDirectory)=>`path.join(__dirname, ${JSON.stringify(normalizePath(node_path.relative(appDirectory, targetDirectory)))})`;
8
9
  return {
9
- sharedDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, sharedDirectory))}")`,
10
- apiDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, apiDirectory))}")`,
11
- lambdaDirectory: `path.join(__dirname, "${normalizePath(node_path.relative(appDirectory, lambdaDirectory))}")`,
10
+ sharedDirectory: getRelativePathTemplate(sharedDirectory),
11
+ apiDirectory: getRelativePathTemplate(apiDirectory),
12
+ lambdaDirectory: getRelativePathTemplate(lambdaDirectory),
12
13
  metaName,
13
14
  bffRuntimeFramework: bffRuntimeFramework || 'hono'
14
15
  };
@@ -57,4 +57,4 @@ async function getServerPort(config) {
57
57
  if (isDev() && isDevCommand()) return getPort(Number(process.env.PORT) || prodPort);
58
58
  return prodPort;
59
59
  }
60
- export { initialize as default };
60
+ export default initialize;
@@ -44,4 +44,4 @@ const serverBuild = ()=>({
44
44
  });
45
45
  }
46
46
  });
47
- export { serverBuild as default };
47
+ export default serverBuild;
@@ -13,4 +13,4 @@ const serverRuntime = ()=>({
13
13
  }));
14
14
  }
15
15
  });
16
- export { serverRuntime as default };
16
+ export default serverRuntime;
@@ -1 +1,2 @@
1
- export function handler(request: any, context: any): Promise<any>;
1
+ export default handler;
2
+ declare function handler(request: any, context: any): Promise<any>;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.1.0",
18
+ "version": "3.1.1",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "exports": {
@@ -94,19 +94,19 @@
94
94
  "ndepe": "^0.1.13",
95
95
  "pkg-types": "^1.3.1",
96
96
  "std-env": "^3.10.0",
97
- "@modern-js/builder": "3.1.0",
98
- "@modern-js/i18n-utils": "3.1.0",
99
- "@modern-js/plugin": "3.1.0",
100
- "@modern-js/plugin-data-loader": "3.1.0",
101
- "@modern-js/prod-server": "3.1.0",
102
- "@modern-js/server": "3.1.0",
103
- "@modern-js/server-utils": "3.1.0",
104
- "@modern-js/server-core": "3.1.0",
105
- "@modern-js/types": "3.1.0",
106
- "@modern-js/utils": "3.1.0"
97
+ "@modern-js/builder": "3.1.1",
98
+ "@modern-js/i18n-utils": "3.1.1",
99
+ "@modern-js/plugin": "3.1.1",
100
+ "@modern-js/plugin-data-loader": "3.1.1",
101
+ "@modern-js/prod-server": "3.1.1",
102
+ "@modern-js/server": "3.1.1",
103
+ "@modern-js/server-utils": "3.1.1",
104
+ "@modern-js/server-core": "3.1.1",
105
+ "@modern-js/utils": "3.1.1",
106
+ "@modern-js/types": "3.1.1"
107
107
  },
108
108
  "devDependencies": {
109
- "@rslib/core": "0.19.6",
109
+ "@rslib/core": "0.20.0",
110
110
  "@types/babel__traverse": "7.28.0",
111
111
  "@types/node": "^20",
112
112
  "ts-node": "^10.9.2",
@@ -7,10 +7,6 @@ export default withTestPreset({
7
7
  globals: true,
8
8
  tools: {
9
9
  rspack: {
10
- optimization: {
11
- // Disable tree shaking to avoid issues with rstest mocking '@modern-js/utils'.
12
- providedExports: false,
13
- },
14
10
  module: {
15
11
  parser: {
16
12
  javascript: {