@modern-js/core 2.58.0 → 2.58.2

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.
@@ -1,2 +1,2 @@
1
- import { UserConfig } from '../types';
1
+ import type { UserConfig } from '../types';
2
2
  export declare function createDefaultConfig(): UserConfig;
@@ -1,4 +1,4 @@
1
- import { LoadedConfig, UserConfig } from '../types';
1
+ import type { LoadedConfig, UserConfig } from '../types';
2
2
  /**
3
3
  * Assign the pkg config into the user config.
4
4
  */
package/dist/context.js CHANGED
@@ -59,6 +59,7 @@ const initAppContext = ({ appDirectory, plugins, configFile, runtimeConfigFile,
59
59
  ip: import_utils.address.ip(),
60
60
  port: 0,
61
61
  packageName: require(import_path.default.resolve(appDirectory, "./package.json")).name,
62
+ moduleType: require(import_path.default.resolve(appDirectory, "./package.json")).type || "commonjs",
62
63
  srcDirectory: import_path.default.resolve(appDirectory, srcDir),
63
64
  apiDirectory: import_path.default.resolve(appDirectory, apiDir),
64
65
  lambdaDirectory: import_path.default.resolve(appDirectory, apiDir, "lambda"),
@@ -1,4 +1,4 @@
1
- import { InternalPlugins } from '@modern-js/types';
1
+ import type { InternalPlugins } from '@modern-js/types';
2
2
  import type { CliPlugin, UserConfig, OldPluginConfig, PluginConfig } from './types';
3
3
  export declare const isOldPluginConfig: (config?: PluginConfig) => config is OldPluginConfig;
4
4
  /**
@@ -31,7 +31,7 @@ const resolveCliPlugin = async (p, appDirectory) => {
31
31
  const path = (0, import_utils.tryResolve)(pkg, appDirectory);
32
32
  let module2;
33
33
  try {
34
- module2 = (0, import_utils.compatRequire)(path);
34
+ module2 = await (0, import_utils.compatibleRequire)(path);
35
35
  } catch (e) {
36
36
  ({ default: module2 } = await (0, import_utils.dynamicImport)(path));
37
37
  }
package/dist/manager.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BasePluginAPI } from './types';
1
+ import type { BasePluginAPI } from './types';
2
2
  export declare const manager: import("@modern-js/plugin").AsyncManager<{
3
3
  beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
4
4
  config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
package/dist/nodeApi.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CoreOptions } from '.';
1
+ import { type CoreOptions } from '.';
2
2
  export declare const dev: (options?: CoreOptions, commandOptions?: string[]) => void;
3
3
  export declare const build: (options?: CoreOptions, commandOptions?: string[]) => void;
4
4
  export declare const deploy: (options?: CoreOptions, commandOptions?: string[]) => void;
package/dist/runBin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { CoreOptions } from '.';
2
+ import { type CoreOptions } from '.';
3
3
  export declare const run: (otherCoreOptions?: CoreOptions, options?: {
4
4
  override?: boolean | ((coreOptions: CoreOptions) => Promise<CoreOptions> | CoreOptions) | undefined;
5
5
  }) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { PluginConfig } from '../plugin';
1
+ import type { PluginConfig } from '../plugin';
2
2
  export type UserConfig<Extends extends {
3
3
  hooks?: ExtendHooks;
4
4
  userConfig?: ExtendUserConfig;
@@ -1,4 +1,4 @@
1
- import { Entrypoint, ServerRoute, HtmlTemplates, HtmlPartials, ServerPlugin } from '@modern-js/types';
1
+ import type { Entrypoint, ServerRoute, HtmlTemplates, HtmlPartials, ServerPlugin } from '@modern-js/types';
2
2
  import type { UniBuilderInstance, UniBuilderWebpackInstance } from '@modern-js/uni-builder';
3
3
  export type ToolsType = 'app-tools' | 'module-tools' | 'monorepo-tools';
4
4
  export interface IAppContext {
@@ -34,6 +34,8 @@ export interface IAppContext {
34
34
  port?: number;
35
35
  /** Name of the current project's package.json */
36
36
  packageName: string;
37
+ /** Type field of package.json */
38
+ moduleType: 'module' | 'commonjs';
37
39
  /** Currently registered plugins */
38
40
  plugins: any[];
39
41
  /** Information for entry points */
@@ -1,4 +1,4 @@
1
- import { Workflow, ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
1
+ import type { Workflow, ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
2
2
  import type { Command } from '@modern-js/utils';
3
3
  import type { UserConfig, NormalizedConfig } from './config';
4
4
  export type BaseHooks<Extends extends {
@@ -1,6 +1,6 @@
1
- import { AsyncSetup, PluginOptions } from '@modern-js/plugin';
2
- import { BaseHooks } from './hooks';
3
- import { BasePluginAPI } from './pluginAPI';
1
+ import type { AsyncSetup, PluginOptions } from '@modern-js/plugin';
2
+ import type { BaseHooks } from './hooks';
3
+ import type { BasePluginAPI } from './pluginAPI';
4
4
  export type { InternalPlugins } from '@modern-js/types';
5
5
  /** Plugin options of a cli plugin. */
6
6
  export type CliPlugin<Extends extends {
@@ -1,6 +1,6 @@
1
- import { CommonAPI } from '@modern-js/plugin';
1
+ import type { CommonAPI } from '@modern-js/plugin';
2
2
  import type { setAppContext, useAppContext, useResolvedConfigContext, useConfigContext } from '../context';
3
- import { BaseHooks } from './hooks';
3
+ import type { BaseHooks } from './hooks';
4
4
  export type BasePluginAPI<Extends extends {
5
5
  hooks?: ExtendHooks;
6
6
  userConfig?: ExtendUserConfig;
@@ -1,4 +1,4 @@
1
- import { program, Command } from '@modern-js/utils';
1
+ import { program, type Command } from '@modern-js/utils';
2
2
  export declare function initCommandsMap(): void;
3
3
  export type { Command };
4
4
  export { program };
@@ -1 +1 @@
1
- export declare const initAppDir: (cwd?: string) => Promise<string>;
1
+ export declare const initAppDir: (currentDir?: string) => Promise<string>;
@@ -33,10 +33,8 @@ __export(initAppDir_exports, {
33
33
  module.exports = __toCommonJS(initAppDir_exports);
34
34
  var import_path = __toESM(require("path"));
35
35
  var import_utils = require("@modern-js/utils");
36
- const initAppDir = async (cwd) => {
37
- if (!cwd) {
38
- cwd = process.cwd();
39
- }
36
+ const initAppDir = async (currentDir) => {
37
+ const cwd = currentDir || process.cwd();
40
38
  const pkg = await (0, import_utils.pkgUp)({
41
39
  cwd
42
40
  });
@@ -1,2 +1,2 @@
1
- import { UserConfig, NormalizedConfig } from '../types';
1
+ import type { UserConfig, NormalizedConfig } from '../types';
2
2
  export declare const mergeConfig: <ExtendConfig extends Record<string, any>>(configs: (UserConfig<ExtendConfig> | NormalizedConfig<ExtendConfig>)[]) => NormalizedConfig<ExtendConfig>;
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "modern",
15
15
  "modern.js"
16
16
  ],
17
- "version": "2.58.0",
17
+ "version": "2.58.2",
18
18
  "jsnext:source": "./src/index.ts",
19
19
  "types": "./dist/index.d.ts",
20
20
  "main": "./dist/index.js",
@@ -71,20 +71,20 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@swc/helpers": "0.5.3",
74
- "@modern-js/node-bundle-require": "2.58.0",
75
- "@modern-js/utils": "2.58.0",
76
- "@modern-js/plugin": "2.58.0"
74
+ "@modern-js/node-bundle-require": "2.58.2",
75
+ "@modern-js/plugin": "2.58.2",
76
+ "@modern-js/utils": "2.58.2"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@types/jest": "^29",
80
80
  "@types/node": "^14",
81
- "tsm": "2.3.0",
82
81
  "jest": "^29",
82
+ "tsm": "2.3.0",
83
83
  "typescript": "^5",
84
- "@modern-js/uni-builder": "2.58.0",
85
- "@modern-js/types": "2.58.0",
86
- "@scripts/build": "2.58.0",
87
- "@scripts/jest-config": "2.58.0"
84
+ "@modern-js/types": "2.58.2",
85
+ "@scripts/build": "2.58.2",
86
+ "@modern-js/uni-builder": "2.58.2",
87
+ "@scripts/jest-config": "2.58.2"
88
88
  },
89
89
  "sideEffects": false,
90
90
  "publishConfig": {