@modern-js/app-tools 2.54.2-alpha.3 → 2.54.3-alpha.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.
@@ -35,7 +35,7 @@ const build = async (api, options) => {
35
35
  let resolvedConfig = api.useResolvedConfigContext();
36
36
  const appContext = api.useAppContext();
37
37
  const hookRunners = api.useHookRunners();
38
- await (0, import_loadPlugins.loadServerPlugins)(api, appContext.appDirectory);
38
+ await (0, import_loadPlugins.loadServerPlugins)(api, appContext.appDirectory, appContext.metaName);
39
39
  await (0, import_register.registerCompiler)(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
40
40
  const { apiOnly } = appContext;
41
41
  if (apiOnly) {
@@ -24,7 +24,8 @@ module.exports = __toCommonJS(deploy_exports);
24
24
  var import_loadPlugins = require("../utils/loadPlugins");
25
25
  const deploy = async (api, options) => {
26
26
  const hookRunners = api.useHookRunners();
27
- await (0, import_loadPlugins.getServerPlugins)(api);
27
+ const { metaName } = api.useAppContext();
28
+ await (0, import_loadPlugins.getServerPlugins)(api, metaName);
28
29
  await hookRunners.beforeDeploy(options);
29
30
  await hookRunners.deploy(options);
30
31
  await hookRunners.afterDeploy(options);
@@ -70,7 +70,7 @@ const dev = async (api, options, devServerOptions = {}) => {
70
70
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
71
71
  }
72
72
  await (0, import_routes.generateRoutes)(appContext);
73
- const pluginInstances = await (0, import_loadPlugins.loadServerPlugins)(api, appDirectory);
73
+ const pluginInstances = await (0, import_loadPlugins.loadServerPlugins)(api, appDirectory, metaName);
74
74
  const serverOptions = {
75
75
  metaName,
76
76
  dev: {
@@ -50,7 +50,7 @@ const start = async (api) => {
50
50
  }
51
51
  const meta = (0, import_utils.getMeta)(metaName);
52
52
  const serverConfigPath = import_path.default.resolve(distDirectory, import_utils.SERVER_DIR, `${meta}.server`);
53
- const pluginInstances = await (0, import_loadPlugins.loadServerPlugins)(api, appDirectory);
53
+ const pluginInstances = await (0, import_loadPlugins.loadServerPlugins)(api, appDirectory, metaName);
54
54
  const app = await (0, import_prod_server.createProdServer)({
55
55
  metaName,
56
56
  pwd: distDirectory,
@@ -136,7 +136,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
136
136
  tracedFile.pkgName = pkgName;
137
137
  tracedFile.pkgVersion = pkgJSON.version;
138
138
  const shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
139
- if (tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath) {
139
+ if (tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.pkgJSON.version === tracedFile.pkgVersion) {
140
140
  if (shouldCopyWholePackage) {
141
141
  const allFiles = await (0, import_utils2.readDirRecursive)(tracedFile.pkgPath);
142
142
  tracedPackageVersion.files.push(...allFiles);
@@ -141,8 +141,7 @@ const findPackageParents = (pkg, version, tracedFiles) => {
141
141
  const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
142
142
  return await (0, import_nft.nodeFileTrace)(entryFiles, {
143
143
  base,
144
- processCwd: serverRootDir,
145
- cache: /* @__PURE__ */ Object.create(null)
144
+ processCwd: serverRootDir
146
145
  });
147
146
  };
148
147
  const resolveTracedPath = async (base, p) => import_utils.fs.realpath(import_path.default.resolve(base, p));
@@ -23,19 +23,20 @@ __export(loadPlugins_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(loadPlugins_exports);
25
25
  var import_prod_server = require("@modern-js/prod-server");
26
- async function getServerPlugins(api) {
26
+ async function getServerPlugins(api, metaName = "modern-js") {
27
27
  const runner = api.useHookRunners();
28
28
  const { plugins } = await runner._internalServerPlugins({
29
29
  plugins: []
30
30
  });
31
+ const filtedPlugins = plugins.filter((plugin) => plugin.name.includes(metaName));
31
32
  api.setAppContext({
32
33
  ...api.useAppContext(),
33
- serverPlugins: plugins
34
+ serverPlugins: filtedPlugins
34
35
  });
35
- return plugins;
36
+ return filtedPlugins;
36
37
  }
37
- async function loadServerPlugins(api, appDirectory) {
38
- const plugins = await getServerPlugins(api);
38
+ async function loadServerPlugins(api, appDirectory, metaName) {
39
+ const plugins = await getServerPlugins(api, metaName);
39
40
  const instances = (0, import_prod_server.loadServerPlugins)(plugins, appDirectory);
40
41
  return instances;
41
42
  }
@@ -22,7 +22,7 @@ var build = function() {
22
22
  hookRunners = api.useHookRunners();
23
23
  return [
24
24
  4,
25
- loadServerPlugins(api, appContext.appDirectory)
25
+ loadServerPlugins(api, appContext.appDirectory, appContext.metaName)
26
26
  ];
27
27
  case 1:
28
28
  _state.sent();
@@ -3,14 +3,15 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { getServerPlugins } from "../utils/loadPlugins";
4
4
  var deploy = function() {
5
5
  var _ref = _async_to_generator(function(api, options) {
6
- var hookRunners;
6
+ var hookRunners, metaName;
7
7
  return _ts_generator(this, function(_state) {
8
8
  switch (_state.label) {
9
9
  case 0:
10
10
  hookRunners = api.useHookRunners();
11
+ metaName = api.useAppContext().metaName;
11
12
  return [
12
13
  4,
13
- getServerPlugins(api)
14
+ getServerPlugins(api, metaName)
14
15
  ];
15
16
  case 1:
16
17
  _state.sent();
@@ -68,7 +68,7 @@ var dev = function() {
68
68
  _state.sent();
69
69
  return [
70
70
  4,
71
- loadServerPlugins(api, appDirectory)
71
+ loadServerPlugins(api, appDirectory, metaName)
72
72
  ];
73
73
  case 5:
74
74
  pluginInstances = _state.sent();
@@ -31,7 +31,7 @@ var start = function() {
31
31
  serverConfigPath = path.resolve(distDirectory, SERVER_DIR, "".concat(meta, ".server"));
32
32
  return [
33
33
  4,
34
- loadServerPlugins(api, appDirectory)
34
+ loadServerPlugins(api, appDirectory, metaName)
35
35
  ];
36
36
  case 2:
37
37
  pluginInstances = _state.sent();
@@ -224,7 +224,7 @@ var handleDependencies = function() {
224
224
  tracedFile.pkgName = pkgName;
225
225
  tracedFile.pkgVersion = pkgJSON.version;
226
226
  shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
227
- if (!(tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath))
227
+ if (!(tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.pkgJSON.version === tracedFile.pkgVersion))
228
228
  return [
229
229
  3,
230
230
  9
@@ -346,8 +346,7 @@ var traceFiles = function() {
346
346
  4,
347
347
  nodeFileTrace(entryFiles, {
348
348
  base,
349
- processCwd: serverRootDir,
350
- cache: /* @__PURE__ */ Object.create(null)
349
+ processCwd: serverRootDir
351
350
  })
352
351
  ];
353
352
  case 1:
@@ -8,10 +8,12 @@ function getServerPlugins(api) {
8
8
  }
9
9
  function _getServerPlugins() {
10
10
  _getServerPlugins = _async_to_generator(function(api) {
11
- var runner, plugins;
11
+ var metaName, runner, plugins, filtedPlugins;
12
+ var _arguments = arguments;
12
13
  return _ts_generator(this, function(_state) {
13
14
  switch (_state.label) {
14
15
  case 0:
16
+ metaName = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "modern-js";
15
17
  runner = api.useHookRunners();
16
18
  return [
17
19
  4,
@@ -21,30 +23,33 @@ function _getServerPlugins() {
21
23
  ];
22
24
  case 1:
23
25
  plugins = _state.sent().plugins;
26
+ filtedPlugins = plugins.filter(function(plugin) {
27
+ return plugin.name.includes(metaName);
28
+ });
24
29
  api.setAppContext(_object_spread_props(_object_spread({}, api.useAppContext()), {
25
- serverPlugins: plugins
30
+ serverPlugins: filtedPlugins
26
31
  }));
27
32
  return [
28
33
  2,
29
- plugins
34
+ filtedPlugins
30
35
  ];
31
36
  }
32
37
  });
33
38
  });
34
39
  return _getServerPlugins.apply(this, arguments);
35
40
  }
36
- function loadServerPlugins(api, appDirectory) {
41
+ function loadServerPlugins(api, appDirectory, metaName) {
37
42
  return _loadServerPlugins.apply(this, arguments);
38
43
  }
39
44
  function _loadServerPlugins() {
40
- _loadServerPlugins = _async_to_generator(function(api, appDirectory) {
45
+ _loadServerPlugins = _async_to_generator(function(api, appDirectory, metaName) {
41
46
  var plugins, instances;
42
47
  return _ts_generator(this, function(_state) {
43
48
  switch (_state.label) {
44
49
  case 0:
45
50
  return [
46
51
  4,
47
- getServerPlugins(api)
52
+ getServerPlugins(api, metaName)
48
53
  ];
49
54
  case 1:
50
55
  plugins = _state.sent();
@@ -12,7 +12,7 @@ const build = async (api, options) => {
12
12
  let resolvedConfig = api.useResolvedConfigContext();
13
13
  const appContext = api.useAppContext();
14
14
  const hookRunners = api.useHookRunners();
15
- await loadServerPlugins(api, appContext.appDirectory);
15
+ await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
16
16
  await registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
17
17
  const { apiOnly } = appContext;
18
18
  if (apiOnly) {
@@ -1,7 +1,8 @@
1
1
  import { getServerPlugins } from "../utils/loadPlugins";
2
2
  const deploy = async (api, options) => {
3
3
  const hookRunners = api.useHookRunners();
4
- await getServerPlugins(api);
4
+ const { metaName } = api.useAppContext();
5
+ await getServerPlugins(api, metaName);
5
6
  await hookRunners.beforeDeploy(options);
6
7
  await hookRunners.deploy(options);
7
8
  await hookRunners.afterDeploy(options);
@@ -37,7 +37,7 @@ const dev = async (api, options, devServerOptions = {}) => {
37
37
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
38
38
  }
39
39
  await generateRoutes(appContext);
40
- const pluginInstances = await loadServerPlugins(api, appDirectory);
40
+ const pluginInstances = await loadServerPlugins(api, appDirectory, metaName);
41
41
  const serverOptions = {
42
42
  metaName,
43
43
  dev: {
@@ -17,7 +17,7 @@ const start = async (api) => {
17
17
  }
18
18
  const meta = getMeta(metaName);
19
19
  const serverConfigPath = path.resolve(distDirectory, SERVER_DIR, `${meta}.server`);
20
- const pluginInstances = await loadServerPlugins(api, appDirectory);
20
+ const pluginInstances = await loadServerPlugins(api, appDirectory, metaName);
21
21
  const app = await createProdServer({
22
22
  metaName,
23
23
  pwd: distDirectory,
@@ -103,7 +103,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
103
103
  tracedFile.pkgName = pkgName;
104
104
  tracedFile.pkgVersion = pkgJSON.version;
105
105
  const shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
106
- if (tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath) {
106
+ if (tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.pkgJSON.version === tracedFile.pkgVersion) {
107
107
  if (shouldCopyWholePackage) {
108
108
  const allFiles = await readDirRecursive(tracedFile.pkgPath);
109
109
  tracedPackageVersion.files.push(...allFiles);
@@ -101,8 +101,7 @@ const findPackageParents = (pkg, version, tracedFiles) => {
101
101
  const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
102
102
  return await nodeFileTrace(entryFiles, {
103
103
  base,
104
- processCwd: serverRootDir,
105
- cache: /* @__PURE__ */ Object.create(null)
104
+ processCwd: serverRootDir
106
105
  });
107
106
  };
108
107
  const resolveTracedPath = async (base, p) => fse.realpath(path.resolve(base, p));
@@ -1,17 +1,18 @@
1
1
  import { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
2
- async function getServerPlugins(api) {
2
+ async function getServerPlugins(api, metaName = "modern-js") {
3
3
  const runner = api.useHookRunners();
4
4
  const { plugins } = await runner._internalServerPlugins({
5
5
  plugins: []
6
6
  });
7
+ const filtedPlugins = plugins.filter((plugin) => plugin.name.includes(metaName));
7
8
  api.setAppContext({
8
9
  ...api.useAppContext(),
9
- serverPlugins: plugins
10
+ serverPlugins: filtedPlugins
10
11
  });
11
- return plugins;
12
+ return filtedPlugins;
12
13
  }
13
- async function loadServerPlugins(api, appDirectory) {
14
- const plugins = await getServerPlugins(api);
14
+ async function loadServerPlugins(api, appDirectory, metaName) {
15
+ const plugins = await getServerPlugins(api, metaName);
15
16
  const instances = loadServerPluginInstances(plugins, appDirectory);
16
17
  return instances;
17
18
  }
@@ -1,5 +1,5 @@
1
1
  import { ServerPlugin as ServerPluginInstance } from '@modern-js/server-core';
2
2
  import { ServerPlugin } from '@modern-js/types';
3
3
  import { AppTools, PluginAPI } from '../types';
4
- export declare function getServerPlugins(api: PluginAPI<AppTools<'shared'>>): Promise<ServerPlugin[]>;
5
- export declare function loadServerPlugins(api: PluginAPI<AppTools<'shared'>>, appDirectory: string): Promise<ServerPluginInstance[]>;
4
+ export declare function getServerPlugins(api: PluginAPI<AppTools<'shared'>>, metaName?: string): Promise<ServerPlugin[]>;
5
+ export declare function loadServerPlugins(api: PluginAPI<AppTools<'shared'>>, appDirectory: string, metaName: string): Promise<ServerPluginInstance[]>;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.54.2-alpha.3",
18
+ "version": "2.54.3-alpha.4",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -88,20 +88,20 @@
88
88
  "mlly": "^1.6.1",
89
89
  "pkg-types": "^1.1.0",
90
90
  "std-env": "^3.7.0",
91
- "@modern-js/core": "2.54.1",
92
- "@modern-js/plugin-data-loader": "2.54.1",
93
- "@modern-js/plugin-i18n": "2.54.1",
94
- "@modern-js/plugin-lint": "2.54.1",
95
- "@modern-js/rsbuild-plugin-esbuild": "2.54.1",
96
- "@modern-js/prod-server": "2.54.1",
97
- "@modern-js/server": "2.54.1",
98
- "@modern-js/server-core": "2.54.1",
99
- "@modern-js/server-utils": "2.54.1",
100
- "@modern-js/node-bundle-require": "2.54.1",
101
- "@modern-js/plugin": "2.54.1",
102
- "@modern-js/uni-builder": "2.54.1",
103
- "@modern-js/types": "2.54.1",
104
- "@modern-js/utils": "2.54.1"
91
+ "@modern-js/node-bundle-require": "2.54.2",
92
+ "@modern-js/core": "2.54.2",
93
+ "@modern-js/plugin": "2.54.2",
94
+ "@modern-js/plugin-data-loader": "2.54.2",
95
+ "@modern-js/plugin-i18n": "2.54.2",
96
+ "@modern-js/plugin-lint": "2.54.2",
97
+ "@modern-js/prod-server": "2.54.2",
98
+ "@modern-js/server": "2.54.2",
99
+ "@modern-js/server-utils": "2.54.2",
100
+ "@modern-js/rsbuild-plugin-esbuild": "2.54.2",
101
+ "@modern-js/server-core": "2.54.2",
102
+ "@modern-js/uni-builder": "2.54.2",
103
+ "@modern-js/types": "2.54.2",
104
+ "@modern-js/utils": "2.54.2"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@rsbuild/plugin-swc": "0.7.9",
@@ -113,8 +113,8 @@
113
113
  "tsconfig-paths": "^4.2.0",
114
114
  "typescript": "^5",
115
115
  "webpack": "^5.92.0",
116
- "@scripts/build": "2.54.1",
117
- "@scripts/jest-config": "2.54.1"
116
+ "@scripts/build": "2.54.2",
117
+ "@scripts/jest-config": "2.54.2"
118
118
  },
119
119
  "sideEffects": false,
120
120
  "publishConfig": {