@modern-js/plugin 3.0.0-alpha.1 → 3.0.0

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 (76) hide show
  1. package/dist/cjs/cli/run/config/loadConfig.js +10 -10
  2. package/dist/esm/cli/api.mjs +1 -1
  3. package/dist/esm/cli/context.mjs +1 -1
  4. package/dist/esm/cli/hooks.mjs +1 -1
  5. package/dist/esm/cli/index.mjs +6 -6
  6. package/dist/esm/cli/run/config/createLoadedConfig.mjs +2 -2
  7. package/dist/esm/cli/run/config/createResolvedConfig.mjs +1 -1
  8. package/dist/esm/cli/run/config/loadConfig.mjs +12 -11
  9. package/dist/esm/cli/run/create.mjs +9 -9
  10. package/dist/esm/cli/run/index.mjs +5 -5
  11. package/dist/esm/cli/run/run.mjs +1 -1
  12. package/dist/esm/index.mjs +2 -2
  13. package/dist/esm/runtime/context.mjs +1 -1
  14. package/dist/esm/runtime/hooks.mjs +1 -1
  15. package/dist/esm/runtime/index.mjs +4 -4
  16. package/dist/esm/runtime/run/create.mjs +3 -3
  17. package/dist/esm/runtime/run/index.mjs +1 -1
  18. package/dist/esm/server/context.mjs +1 -1
  19. package/dist/esm/server/hooks.mjs +1 -1
  20. package/dist/esm/server/index.mjs +4 -4
  21. package/dist/esm/server/run/create.mjs +3 -3
  22. package/dist/esm/server/run/index.mjs +1 -1
  23. package/dist/esm-node/cli/api.mjs +1 -0
  24. package/dist/esm-node/cli/context.mjs +1 -0
  25. package/dist/esm-node/cli/hooks.mjs +1 -0
  26. package/dist/esm-node/cli/index.mjs +1 -0
  27. package/dist/esm-node/cli/run/config/createLoadedConfig.mjs +1 -0
  28. package/dist/esm-node/cli/run/config/createResolvedConfig.mjs +1 -0
  29. package/dist/esm-node/cli/run/config/loadConfig.mjs +15 -11
  30. package/dist/esm-node/cli/run/create.mjs +1 -0
  31. package/dist/esm-node/cli/run/index.mjs +1 -0
  32. package/dist/esm-node/cli/run/run.mjs +1 -0
  33. package/dist/esm-node/cli/run/types.mjs +1 -0
  34. package/dist/esm-node/cli/run/utils/checkIsDuplicationPlugin.mjs +1 -0
  35. package/dist/esm-node/cli/run/utils/commander.mjs +1 -0
  36. package/dist/esm-node/cli/run/utils/createFileWatcher.mjs +1 -0
  37. package/dist/esm-node/cli/run/utils/debug.mjs +1 -0
  38. package/dist/esm-node/cli/run/utils/initAppDir.mjs +1 -0
  39. package/dist/esm-node/cli/run/utils/mergeConfig.mjs +1 -0
  40. package/dist/esm-node/hooks.mjs +1 -0
  41. package/dist/esm-node/index.mjs +1 -0
  42. package/dist/esm-node/manager.mjs +1 -0
  43. package/dist/esm-node/runtime/api.mjs +1 -0
  44. package/dist/esm-node/runtime/context.mjs +1 -0
  45. package/dist/esm-node/runtime/hooks.mjs +1 -0
  46. package/dist/esm-node/runtime/index.mjs +1 -0
  47. package/dist/esm-node/runtime/run/create.mjs +1 -0
  48. package/dist/esm-node/runtime/run/index.mjs +1 -0
  49. package/dist/esm-node/runtime/run/types.mjs +1 -0
  50. package/dist/esm-node/server/api.mjs +1 -0
  51. package/dist/esm-node/server/context.mjs +1 -0
  52. package/dist/esm-node/server/hooks.mjs +1 -0
  53. package/dist/esm-node/server/index.mjs +1 -0
  54. package/dist/esm-node/server/run/create.mjs +1 -0
  55. package/dist/esm-node/server/run/index.mjs +1 -0
  56. package/dist/esm-node/server/run/types.mjs +1 -0
  57. package/dist/esm-node/types/cli/api.mjs +1 -0
  58. package/dist/esm-node/types/cli/context.mjs +1 -0
  59. package/dist/esm-node/types/cli/hooks.mjs +1 -0
  60. package/dist/esm-node/types/cli/index.mjs +1 -0
  61. package/dist/esm-node/types/cli/plugin.mjs +1 -0
  62. package/dist/esm-node/types/hooks.mjs +1 -0
  63. package/dist/esm-node/types/index.mjs +1 -0
  64. package/dist/esm-node/types/plugin.mjs +1 -0
  65. package/dist/esm-node/types/runtime/api.mjs +1 -0
  66. package/dist/esm-node/types/runtime/context.mjs +1 -0
  67. package/dist/esm-node/types/runtime/hooks.mjs +1 -0
  68. package/dist/esm-node/types/runtime/index.mjs +1 -0
  69. package/dist/esm-node/types/runtime/plugin.mjs +1 -0
  70. package/dist/esm-node/types/server/api.mjs +1 -0
  71. package/dist/esm-node/types/server/context.mjs +1 -0
  72. package/dist/esm-node/types/server/hooks.mjs +1 -0
  73. package/dist/esm-node/types/server/index.mjs +1 -0
  74. package/dist/esm-node/types/server/plugin.mjs +1 -0
  75. package/dist/esm-node/types/utils.mjs +1 -0
  76. package/package.json +24 -25
@@ -42,7 +42,6 @@ const external_path_namespaceObject = require("path");
42
42
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
43
43
  const utils_namespaceObject = require("@modern-js/utils");
44
44
  const external_jiti_namespaceObject = require("jiti");
45
- var external_jiti_default = /*#__PURE__*/ __webpack_require__.n(external_jiti_namespaceObject);
46
45
  const getConfigFilePath = (appDirectory, configFilePath)=>{
47
46
  if (external_path_default().isAbsolute(configFilePath)) return configFilePath;
48
47
  return external_path_default().resolve(appDirectory, configFilePath);
@@ -59,15 +58,16 @@ const clearFilesOverTime = async (targetDir, overtime)=>{
59
58
  }
60
59
  } catch (err) {}
61
60
  };
62
- function loadConfigContent(configFile) {
63
- const _require = external_jiti_default()(__filename, {
64
- esmResolve: true,
61
+ async function loadConfigContent(configFile) {
62
+ const jitiFrom = __filename;
63
+ const jiti = (0, external_jiti_namespaceObject.createJiti)(jitiFrom, {
65
64
  requireCache: false,
66
65
  interopDefault: true
67
66
  });
68
67
  if (!utils_namespaceObject.fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
69
68
  try {
70
- const config = _require(configFile);
69
+ let config;
70
+ config = jiti(configFile);
71
71
  return config.default || config;
72
72
  } catch (e) {
73
73
  if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
@@ -75,23 +75,23 @@ function loadConfigContent(configFile) {
75
75
  }
76
76
  }
77
77
  const loadTypeScriptFile = (filePath)=>{
78
- const _require = external_jiti_default()(__filename, {
79
- esmResolve: true,
78
+ const jiti = (0, external_jiti_namespaceObject.createJiti)(__filename, {
80
79
  requireCache: false,
81
80
  interopDefault: true
82
81
  });
83
82
  if (!utils_namespaceObject.fs.existsSync(filePath)) throw new Error(`TypeScript file does not exist: ${filePath}`);
84
83
  try {
85
- return _require(filePath);
84
+ return jiti(filePath);
86
85
  } catch (e) {
87
86
  if (e instanceof Error) e.message = `Get Error while loading TypeScript file: ${filePath}, please check it and retry.\n${e.message || ''}`;
88
87
  throw e;
89
88
  }
90
89
  };
91
90
  const loadConfig = async (appDirectory, configFile)=>{
92
- const packageName = require(external_path_default().resolve(appDirectory, './package.json')).name;
91
+ const pkg = await (0, utils_namespaceObject.compatibleRequire)(external_path_default().resolve(appDirectory, './package.json'));
92
+ const packageName = pkg.name;
93
93
  let config;
94
- if (configFile) config = loadConfigContent(configFile);
94
+ if (configFile) config = await loadConfigContent(configFile);
95
95
  return {
96
96
  packageName,
97
97
  configFile,
@@ -1,5 +1,5 @@
1
1
  import { assign as lodash_assign } from "@modern-js/utils/lodash";
2
- import { debug } from "./run/utils/debug";
2
+ import { debug } from "./run/utils/debug.mjs";
3
3
  function initPluginAPI({ context, pluginManager }) {
4
4
  const { hooks, extendsHooks, plugins } = context;
5
5
  function getAppContext() {
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { initHooks } from "./hooks";
2
+ import { initHooks } from "./hooks.mjs";
3
3
  function initAppContext(params) {
4
4
  const { appDirectory, srcDir = 'src', distDir = 'dist' } = params;
5
5
  return {
@@ -1,4 +1,4 @@
1
- import { createAsyncHook, createCollectAsyncHook } from "../hooks";
1
+ import { createAsyncHook, createCollectAsyncHook } from "../hooks.mjs";
2
2
  function initHooks() {
3
3
  return {
4
4
  config: createCollectAsyncHook(),
@@ -1,7 +1,7 @@
1
- import { initPluginAPI } from "./api";
2
- import { createContext, initAppContext } from "./context";
3
- import { initHooks } from "./hooks";
4
- import { cli, createCli, createLoadedConfig, initAppDir } from "./run";
5
- import { createStorybookOptions } from "./run/create";
6
- import { mergeConfig } from "./run/utils/mergeConfig";
1
+ import { initPluginAPI } from "./api.mjs";
2
+ import { createContext, initAppContext } from "./context.mjs";
3
+ import { initHooks } from "./hooks.mjs";
4
+ import { cli, createCli, createLoadedConfig, initAppDir } from "./run/index.mjs";
5
+ import { createStorybookOptions } from "./run/create.mjs";
6
+ import { mergeConfig } from "./run/utils/mergeConfig.mjs";
7
7
  export { cli, createCli, createContext, createLoadedConfig, createStorybookOptions, initAppContext, initAppDir, initHooks, initPluginAPI, mergeConfig };
@@ -1,6 +1,6 @@
1
1
  import { CONFIG_FILE_EXTENSIONS, chalk, fs, getCommand, getNodeEnv, isDevCommand, logger } from "@modern-js/utils";
2
- import { mergeConfig } from "../utils/mergeConfig";
3
- import { getConfigFilePath, loadConfig } from "./loadConfig";
2
+ import { mergeConfig } from "../utils/mergeConfig.mjs";
3
+ import { getConfigFilePath, loadConfig } from "./loadConfig.mjs";
4
4
  async function getConfigObject(config) {
5
5
  if ('function' == typeof config) return await config({
6
6
  env: getNodeEnv(),
@@ -1,5 +1,5 @@
1
1
  import { createDebugger } from "@modern-js/utils";
2
- import { mergeConfig } from "../utils/mergeConfig";
2
+ import { mergeConfig } from "../utils/mergeConfig.mjs";
3
3
  const debug = createDebugger('resolve-config');
4
4
  const createResolveConfig = async (loaded, configs)=>{
5
5
  const { config: userConfig } = loaded;
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
- import { fs, globby } from "@modern-js/utils";
3
- import jiti from "jiti";
2
+ import { compatibleRequire, fs, globby } from "@modern-js/utils";
3
+ import { createJiti } from "jiti";
4
4
  const getConfigFilePath = (appDirectory, configFilePath)=>{
5
5
  if (path.isAbsolute(configFilePath)) return configFilePath;
6
6
  return path.resolve(appDirectory, configFilePath);
@@ -17,15 +17,16 @@ const clearFilesOverTime = async (targetDir, overtime)=>{
17
17
  }
18
18
  } catch (err) {}
19
19
  };
20
- function loadConfigContent(configFile) {
21
- const _require = jiti(__filename, {
22
- esmResolve: true,
20
+ async function loadConfigContent(configFile) {
21
+ const jitiFrom = import.meta.url;
22
+ const jiti = createJiti(jitiFrom, {
23
23
  requireCache: false,
24
24
  interopDefault: true
25
25
  });
26
26
  if (!fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
27
27
  try {
28
- const config = _require(configFile);
28
+ let config;
29
+ config = await jiti.import(configFile, {});
29
30
  return config.default || config;
30
31
  } catch (e) {
31
32
  if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
@@ -33,23 +34,23 @@ function loadConfigContent(configFile) {
33
34
  }
34
35
  }
35
36
  const loadTypeScriptFile = (filePath)=>{
36
- const _require = jiti(__filename, {
37
- esmResolve: true,
37
+ const jiti = createJiti(__filename, {
38
38
  requireCache: false,
39
39
  interopDefault: true
40
40
  });
41
41
  if (!fs.existsSync(filePath)) throw new Error(`TypeScript file does not exist: ${filePath}`);
42
42
  try {
43
- return _require(filePath);
43
+ return jiti(filePath);
44
44
  } catch (e) {
45
45
  if (e instanceof Error) e.message = `Get Error while loading TypeScript file: ${filePath}, please check it and retry.\n${e.message || ''}`;
46
46
  throw e;
47
47
  }
48
48
  };
49
49
  const loadConfig = async (appDirectory, configFile)=>{
50
- const packageName = require(path.resolve(appDirectory, './package.json')).name;
50
+ const pkg = await compatibleRequire(path.resolve(appDirectory, './package.json'));
51
+ const packageName = pkg.name;
51
52
  let config;
52
- if (configFile) config = loadConfigContent(configFile);
53
+ if (configFile) config = await loadConfigContent(configFile);
53
54
  return {
54
55
  packageName,
55
56
  configFile,
@@ -1,15 +1,15 @@
1
1
  import { createDebugger, logger } from "@modern-js/utils";
2
2
  import { program } from "@modern-js/utils/commander";
3
3
  import { loadEnv } from "@rsbuild/core";
4
- import { createPluginManager } from "../../manager";
5
- import { initPluginAPI } from "../api";
6
- import { createContext, initAppContext } from "../context";
7
- import { createLoadedConfig } from "./config/createLoadedConfig";
8
- import { createResolveConfig } from "./config/createResolvedConfig";
9
- import { checkIsDuplicationPlugin } from "./utils/checkIsDuplicationPlugin";
10
- import { initCommandsMap, setProgramVersion } from "./utils/commander";
11
- import { createFileWatcher } from "./utils/createFileWatcher";
12
- import { initAppDir } from "./utils/initAppDir";
4
+ import { createPluginManager } from "../../manager.mjs";
5
+ import { initPluginAPI } from "../api.mjs";
6
+ import { createContext, initAppContext } from "../context.mjs";
7
+ import { createLoadedConfig } from "./config/createLoadedConfig.mjs";
8
+ import { createResolveConfig } from "./config/createResolvedConfig.mjs";
9
+ import { checkIsDuplicationPlugin } from "./utils/checkIsDuplicationPlugin.mjs";
10
+ import { initCommandsMap, setProgramVersion } from "./utils/commander.mjs";
11
+ import { createFileWatcher } from "./utils/createFileWatcher.mjs";
12
+ import { initAppDir } from "./utils/initAppDir.mjs";
13
13
  const debug = createDebugger('plugin');
14
14
  const createCli = ()=>{
15
15
  let initOptions;
@@ -1,7 +1,7 @@
1
- import { createCli } from "./create";
2
- import { createLoadedConfig } from "./config/createLoadedConfig";
3
- import { initAppDir } from "./utils/initAppDir";
4
- import { loadTypeScriptFile } from "./config/loadConfig";
5
- import { run } from "./run";
1
+ import { createCli } from "./create.mjs";
2
+ import { createLoadedConfig } from "./config/createLoadedConfig.mjs";
3
+ import { initAppDir } from "./utils/initAppDir.mjs";
4
+ import { loadTypeScriptFile } from "./config/loadConfig.mjs";
5
+ import { run } from "./run.mjs";
6
6
  const cli = createCli();
7
7
  export { cli, createCli, createLoadedConfig, initAppDir, loadTypeScriptFile, run };
@@ -1,5 +1,5 @@
1
1
  import { logger } from "@modern-js/utils";
2
- import { cli } from ".";
2
+ import { cli } from "./index.mjs";
3
3
  const run = async (options)=>{
4
4
  const { initialLog, version, cwd, configFile, ...params } = options;
5
5
  if (initialLog) logger.greet(` ${initialLog}\n`);
@@ -1,3 +1,3 @@
1
- import { createPluginManager } from "./manager";
2
- import { createAsyncHook, createAsyncInterruptHook, createAsyncPipelineHook, createCollectAsyncHook, createCollectSyncHook, createSyncHook } from "./hooks";
1
+ import { createPluginManager } from "./manager.mjs";
2
+ import { createAsyncHook, createAsyncInterruptHook, createAsyncPipelineHook, createCollectAsyncHook, createCollectSyncHook, createSyncHook } from "./hooks.mjs";
3
3
  export { createAsyncHook, createAsyncInterruptHook, createAsyncPipelineHook, createCollectAsyncHook, createCollectSyncHook, createPluginManager, createSyncHook };
@@ -1,4 +1,4 @@
1
- import { initHooks } from "./hooks";
1
+ import { initHooks } from "./hooks.mjs";
2
2
  function initRuntimeContext() {
3
3
  return {};
4
4
  }
@@ -1,4 +1,4 @@
1
- import { createAsyncInterruptHook, createCollectSyncHook, createSyncHook } from "../hooks";
1
+ import { createAsyncInterruptHook, createCollectSyncHook, createSyncHook } from "../hooks.mjs";
2
2
  function initHooks() {
3
3
  return {
4
4
  onBeforeRender: createAsyncInterruptHook(),
@@ -1,5 +1,5 @@
1
- import { initPluginAPI } from "./api";
2
- import { createRuntimeContext, initRuntimeContext } from "./context";
3
- import { initHooks } from "./hooks";
4
- import { runtime } from "./run";
1
+ import { initPluginAPI } from "./api.mjs";
2
+ import { createRuntimeContext, initRuntimeContext } from "./context.mjs";
3
+ import { initHooks } from "./hooks.mjs";
4
+ import { runtime } from "./run/index.mjs";
5
5
  export { createRuntimeContext, initHooks, initPluginAPI, initRuntimeContext, runtime };
@@ -1,7 +1,7 @@
1
1
  import { merge } from "@modern-js/runtime-utils/merge";
2
- import { createPluginManager } from "../../manager";
3
- import { initPluginAPI } from "../../runtime/api";
4
- import { createRuntimeContext, initRuntimeContext } from "../../runtime/context";
2
+ import { createPluginManager } from "../../manager.mjs";
3
+ import { initPluginAPI } from "../api.mjs";
4
+ import { createRuntimeContext, initRuntimeContext } from "../context.mjs";
5
5
  const createRuntime = ()=>{
6
6
  let initOptions;
7
7
  const pluginManager = createPluginManager();
@@ -1,3 +1,3 @@
1
- import { createRuntime } from "./create";
1
+ import { createRuntime } from "./create.mjs";
2
2
  const runtime = createRuntime();
3
3
  export { runtime };
@@ -1,4 +1,4 @@
1
- import { initHooks } from "./hooks";
1
+ import { initHooks } from "./hooks.mjs";
2
2
  function initServerContext(params) {
3
3
  const { options, plugins } = params;
4
4
  return {
@@ -1,4 +1,4 @@
1
- import { createAsyncHook } from "../hooks";
1
+ import { createAsyncHook } from "../hooks.mjs";
2
2
  function initHooks() {
3
3
  return {
4
4
  modifyConfig: createAsyncHook(),
@@ -1,5 +1,5 @@
1
- import { initPluginAPI } from "./api";
2
- import { createServerContext, initServerContext } from "./context";
3
- import { initHooks } from "./hooks";
4
- import { createServer, server } from "./run";
1
+ import { initPluginAPI } from "./api.mjs";
2
+ import { createServerContext, initServerContext } from "./context.mjs";
3
+ import { initHooks } from "./hooks.mjs";
4
+ import { createServer, server } from "./run/index.mjs";
5
5
  export { createServer, createServerContext, initHooks, initPluginAPI, initServerContext, server };
@@ -1,6 +1,6 @@
1
- import { createPluginManager } from "../../manager";
2
- import { initPluginAPI } from "../../server/api";
3
- import { createServerContext, initServerContext } from "../../server/context";
1
+ import { createPluginManager } from "../../manager.mjs";
2
+ import { initPluginAPI } from "../api.mjs";
3
+ import { createServerContext, initServerContext } from "../context.mjs";
4
4
  const createServer = ()=>{
5
5
  let initOptions;
6
6
  const pluginManager = createPluginManager();
@@ -1,3 +1,3 @@
1
- import { createServer } from "./create";
1
+ import { createServer } from "./create.mjs";
2
2
  const server = createServer();
3
3
  export { createServer, server };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { assign as lodash_assign } from "@modern-js/utils/lodash";
2
3
  import { debug } from "./run/utils/debug.mjs";
3
4
  function initPluginAPI({ context, pluginManager }) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { initHooks } from "./hooks.mjs";
3
4
  function initAppContext(params) {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createAsyncHook, createCollectAsyncHook } from "../hooks.mjs";
2
3
  function initHooks() {
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { initPluginAPI } from "./api.mjs";
2
3
  import { createContext, initAppContext } from "./context.mjs";
3
4
  import { initHooks } from "./hooks.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { CONFIG_FILE_EXTENSIONS, chalk, fs, getCommand, getNodeEnv, isDevCommand, logger } from "@modern-js/utils";
2
3
  import { mergeConfig } from "../utils/mergeConfig.mjs";
3
4
  import { getConfigFilePath, loadConfig } from "./loadConfig.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createDebugger } from "@modern-js/utils";
2
3
  import { mergeConfig } from "../utils/mergeConfig.mjs";
3
4
  const debug = createDebugger('resolve-config');
@@ -1,6 +1,9 @@
1
+ import "node:module";
2
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
1
3
  import path from "path";
2
- import { fs, globby } from "@modern-js/utils";
3
- import jiti from "jiti";
4
+ import { compatibleRequire, fs, globby } from "@modern-js/utils";
5
+ import { createJiti } from "jiti";
6
+ var loadConfig_filename = __rspack_fileURLToPath(import.meta.url);
4
7
  const getConfigFilePath = (appDirectory, configFilePath)=>{
5
8
  if (path.isAbsolute(configFilePath)) return configFilePath;
6
9
  return path.resolve(appDirectory, configFilePath);
@@ -17,15 +20,16 @@ const clearFilesOverTime = async (targetDir, overtime)=>{
17
20
  }
18
21
  } catch (err) {}
19
22
  };
20
- function loadConfigContent(configFile) {
21
- const _require = jiti(__filename, {
22
- esmResolve: true,
23
+ async function loadConfigContent(configFile) {
24
+ const jitiFrom = import.meta.url;
25
+ const jiti = createJiti(jitiFrom, {
23
26
  requireCache: false,
24
27
  interopDefault: true
25
28
  });
26
29
  if (!fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
27
30
  try {
28
- const config = _require(configFile);
31
+ let config;
32
+ config = await jiti.import(configFile, {});
29
33
  return config.default || config;
30
34
  } catch (e) {
31
35
  if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
@@ -33,23 +37,23 @@ function loadConfigContent(configFile) {
33
37
  }
34
38
  }
35
39
  const loadTypeScriptFile = (filePath)=>{
36
- const _require = jiti(__filename, {
37
- esmResolve: true,
40
+ const jiti = createJiti(loadConfig_filename, {
38
41
  requireCache: false,
39
42
  interopDefault: true
40
43
  });
41
44
  if (!fs.existsSync(filePath)) throw new Error(`TypeScript file does not exist: ${filePath}`);
42
45
  try {
43
- return _require(filePath);
46
+ return jiti(filePath);
44
47
  } catch (e) {
45
48
  if (e instanceof Error) e.message = `Get Error while loading TypeScript file: ${filePath}, please check it and retry.\n${e.message || ''}`;
46
49
  throw e;
47
50
  }
48
51
  };
49
52
  const loadConfig = async (appDirectory, configFile)=>{
50
- const packageName = require(path.resolve(appDirectory, './package.json')).name;
53
+ const pkg = await compatibleRequire(path.resolve(appDirectory, './package.json'));
54
+ const packageName = pkg.name;
51
55
  let config;
52
- if (configFile) config = loadConfigContent(configFile);
56
+ if (configFile) config = await loadConfigContent(configFile);
53
57
  return {
54
58
  packageName,
55
59
  configFile,
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createDebugger, logger } from "@modern-js/utils";
2
3
  import { program } from "@modern-js/utils/commander";
3
4
  import { loadEnv } from "@rsbuild/core";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createCli } from "./create.mjs";
2
3
  import { createLoadedConfig } from "./config/createLoadedConfig.mjs";
3
4
  import { initAppDir } from "./utils/initAppDir.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { logger } from "@modern-js/utils";
2
3
  import { cli } from "./index.mjs";
3
4
  const run = async (options)=>{
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { logger } from "@modern-js/utils";
2
3
  function checkIsDuplicationPlugin(plugins) {
3
4
  const set = new Set();
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { program } from "@modern-js/utils";
2
3
  const setProgramVersion = (version = 'unknown')=>{
3
4
  const name = process.argv[1];
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import crypto_0 from "crypto";
2
3
  import { readFileSync } from "fs";
3
4
  import { join, resolve } from "path";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createDebugger } from "@modern-js/utils";
2
3
  const debug = createDebugger('plugin');
3
4
  export { debug };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import path from "path";
2
3
  import { pkgUp } from "@modern-js/utils";
3
4
  const initAppDir = async (currentDir)=>{
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { ensureArray, isOverriddenConfigKey } from "@modern-js/utils";
2
3
  import { isEqual, isFunction, mergeWith } from "@modern-js/utils/lodash";
3
4
  const mergeConfig = (configs)=>mergeWith({}, ...configs, (target, source, key)=>{
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  function createAsyncInterruptHook() {
2
3
  const callbacks = [];
3
4
  const tap = (cb)=>{
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createPluginManager } from "./manager.mjs";
2
3
  import { createAsyncHook, createAsyncInterruptHook, createAsyncPipelineHook, createCollectAsyncHook, createCollectSyncHook, createSyncHook } from "./hooks.mjs";
3
4
  export { createAsyncHook, createAsyncInterruptHook, createAsyncPipelineHook, createCollectAsyncHook, createCollectSyncHook, createPluginManager, createSyncHook };
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  const isFunction = (obj)=>'function' == typeof obj;
2
3
  function validatePlugin(plugin) {
3
4
  const type = typeof plugin;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { merge } from "@modern-js/runtime-utils/merge";
2
3
  function initPluginAPI({ context, plugins }) {
3
4
  const { hooks, extendsHooks } = context;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { initHooks } from "./hooks.mjs";
2
3
  function initRuntimeContext() {
3
4
  return {};
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createAsyncInterruptHook, createCollectSyncHook, createSyncHook } from "../hooks.mjs";
2
3
  function initHooks() {
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { initPluginAPI } from "./api.mjs";
2
3
  import { createRuntimeContext, initRuntimeContext } from "./context.mjs";
3
4
  import { initHooks } from "./hooks.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { merge } from "@modern-js/runtime-utils/merge";
2
3
  import { createPluginManager } from "../../manager.mjs";
3
4
  import { initPluginAPI } from "../api.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createRuntime } from "./create.mjs";
2
3
  const runtime = createRuntime();
3
4
  export { runtime };
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createDebugger } from "@modern-js/utils";
2
3
  import { assign as lodash_assign } from "@modern-js/utils/lodash";
3
4
  const debug = createDebugger('plugin-server-v2');
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { initHooks } from "./hooks.mjs";
2
3
  function initServerContext(params) {
3
4
  const { options, plugins } = params;
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createAsyncHook } from "../hooks.mjs";
2
3
  function initHooks() {
3
4
  return {
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { initPluginAPI } from "./api.mjs";
2
3
  import { createServerContext, initServerContext } from "./context.mjs";
3
4
  import { initHooks } from "./hooks.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createPluginManager } from "../../manager.mjs";
2
3
  import { initPluginAPI } from "../api.mjs";
3
4
  import { createServerContext, initServerContext } from "../context.mjs";
@@ -1,3 +1,4 @@
1
+ import "node:module";
1
2
  import { createServer } from "./create.mjs";
2
3
  const server = createServer();
3
4
  export { createServer, server };
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1 @@
1
+ import "node:module";
package/package.json CHANGED
@@ -15,52 +15,51 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.0-alpha.1",
19
- "jsnext:source": "./src/index.ts",
18
+ "version": "3.0.0",
20
19
  "types": "./dist/types/index.d.ts",
21
20
  "main": "./dist/cjs/index.js",
22
- "module": "./dist/esm-node/index.mjs",
23
21
  "exports": {
24
22
  ".": {
25
23
  "types": "./dist/types/index.d.ts",
24
+ "modern:source": "./src/index.ts",
26
25
  "node": {
27
- "modern:source": "./src/index.ts",
28
- "jsnext:source": "./src/index.ts",
29
- "import": "./dist/esm/index.mjs",
26
+ "module": "./dist/esm/index.mjs",
27
+ "import": "./dist/esm-node/index.mjs",
30
28
  "require": "./dist/cjs/index.js"
31
29
  },
32
30
  "default": "./dist/esm/index.mjs"
33
31
  },
34
32
  "./run": {
35
33
  "types": "./dist/types/cli/run/index.d.ts",
36
- "jsnext:source": "./src/cli/run/index.ts",
34
+ "modern:source": "./src/cli/run/index.ts",
35
+ "node": {
36
+ "import": "./dist/esm-node/cli/run/index.mjs",
37
+ "require": "./dist/cjs/cli/run/index.js"
38
+ },
37
39
  "default": "./dist/cjs/cli/run/index.js"
38
40
  },
39
41
  "./cli": {
40
42
  "types": "./dist/types/cli/index.d.ts",
41
43
  "modern:source": "./src/cli/index.ts",
42
- "jsnext:source": "./src/cli/index.ts",
44
+ "node": {
45
+ "import": "./dist/esm-node/cli/index.mjs",
46
+ "require": "./dist/cjs/cli/index.js"
47
+ },
43
48
  "default": "./dist/cjs/cli/index.js"
44
49
  },
45
50
  "./runtime": {
46
51
  "types": "./dist/types/runtime/index.d.ts",
47
52
  "modern:source": "./src/runtime/index.tsx",
48
- "jsnext:source": "./src/runtime/index.tsx",
49
- "node": {
50
- "import": "./dist/esm/runtime/index.mjs",
51
- "require": "./dist/cjs/runtime/index.js"
52
- },
53
53
  "default": "./dist/esm/runtime/index.mjs"
54
54
  },
55
55
  "./server": {
56
56
  "types": "./dist/types/server/index.d.ts",
57
57
  "modern:source": "./src/server/index.ts",
58
- "jsnext:source": "./src/server/index.ts",
59
58
  "node": {
60
- "require": "./dist/cjs/server/index.js",
61
- "default": "./dist/cjs/server/index.js"
59
+ "import": "./dist/esm-node/server/index.mjs",
60
+ "require": "./dist/cjs/server/index.js"
62
61
  },
63
- "default": "./dist/esm/server/index.mjs"
62
+ "default": "./dist/cjs/server/index.js"
64
63
  }
65
64
  },
66
65
  "typesVersions": {
@@ -83,19 +82,19 @@
83
82
  }
84
83
  },
85
84
  "dependencies": {
85
+ "@rsbuild/core": "2.0.0-beta.1",
86
86
  "@swc/helpers": "^0.5.17",
87
- "jiti": "1.21.7",
88
- "@rsbuild/core": "1.7.1",
89
- "@modern-js/runtime-utils": "3.0.0-alpha.1",
90
- "@modern-js/utils": "3.0.0-alpha.1",
91
- "@modern-js/types": "3.0.0-alpha.1"
87
+ "jiti": "^2.6.1",
88
+ "@modern-js/runtime-utils": "3.0.0",
89
+ "@modern-js/types": "3.0.0",
90
+ "@modern-js/utils": "3.0.0"
92
91
  },
93
92
  "devDependencies": {
93
+ "@rslib/core": "0.19.4",
94
94
  "@types/node": "^20",
95
- "@types/react": "^19.2.7",
96
- "@rslib/core": "0.19.1",
95
+ "@types/react": "^19.2.10",
97
96
  "typescript": "^5",
98
- "@modern-js/builder": "3.0.0-alpha.1",
97
+ "@modern-js/builder": "3.0.0",
99
98
  "@modern-js/rslib": "2.68.10"
100
99
  },
101
100
  "sideEffects": false,