@modern-js/core 2.8.0 → 2.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 2.9.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 88328d914b: chore(core): remove legacy transformPlugin option
8
+
9
+ chore(core): 移除不再使用的 transformPlugin 选项
10
+
11
+ - dd56401486: chore: fix some TODO comments
12
+
13
+ chore: 处理一些标记 TODO 的问题
14
+
15
+ - @modern-js/node-bundle-require@2.9.0
16
+ - @modern-js/plugin@2.9.0
17
+ - @modern-js/utils@2.9.0
18
+
3
19
  ## 2.8.0
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type { ErrorObject } from '@modern-js/utils/ajv';
2
2
  import { InternalPlugins } from '@modern-js/types';
3
- import { TransformPlugin } from './loadPlugins';
4
3
  import { initAppContext } from './context';
5
4
  import type { ToolsType } from './types';
6
5
  export * from './types';
7
6
  export * from '@modern-js/plugin';
8
- export { manager, mountHook, createPlugin, registerHook } from './manager';
7
+ export { manager, createPlugin, registerHook } from './manager';
9
8
  export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, } from './context';
10
9
  declare const initAppDir: (cwd?: string) => Promise<string>;
11
10
  export interface CoreOptions {
@@ -19,7 +18,6 @@ export interface CoreOptions {
19
18
  server?: InternalPlugins;
20
19
  autoLoad?: InternalPlugins;
21
20
  };
22
- transformPlugin?: TransformPlugin;
23
21
  onSchemaError?: (error: ErrorObject) => void;
24
22
  options?: {
25
23
  metaName?: string;
@@ -42,7 +40,6 @@ export declare const mergeOptions: (options?: CoreOptions) => {
42
40
  server?: InternalPlugins | undefined;
43
41
  autoLoad?: InternalPlugins | undefined;
44
42
  } | undefined;
45
- transformPlugin?: TransformPlugin | undefined;
46
43
  onSchemaError?: ((error: ErrorObject) => void) | undefined;
47
44
  options?: {
48
45
  metaName?: string | undefined;
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.initAppContext = exports.initAppDir = exports.cli = exports.mergeOptions = exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = exports.registerHook = exports.createPlugin = exports.mountHook = exports.manager = void 0;
20
+ exports.initAppContext = exports.initAppDir = exports.cli = exports.mergeOptions = exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = exports.registerHook = exports.createPlugin = exports.manager = void 0;
21
21
  const path_1 = __importDefault(require("path"));
22
22
  const utils_1 = require("@modern-js/utils");
23
23
  const utils_2 = require("./utils");
@@ -29,10 +29,8 @@ const manager_1 = require("./manager");
29
29
  const config_1 = require("./config");
30
30
  __exportStar(require("./types"), exports);
31
31
  __exportStar(require("@modern-js/plugin"), exports);
32
- // TODO: remove export after refactor all plugins
33
32
  var manager_2 = require("./manager");
34
33
  Object.defineProperty(exports, "manager", { enumerable: true, get: function () { return manager_2.manager; } });
35
- Object.defineProperty(exports, "mountHook", { enumerable: true, get: function () { return manager_2.mountHook; } });
36
34
  Object.defineProperty(exports, "createPlugin", { enumerable: true, get: function () { return manager_2.createPlugin; } });
37
35
  Object.defineProperty(exports, "registerHook", { enumerable: true, get: function () { return manager_2.registerHook; } });
38
36
  var context_2 = require("./context");
@@ -83,7 +81,6 @@ const createCli = () => {
83
81
  const loaded = await (0, config_1.createLoadedConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
84
82
  const plugins = await (0, loadPlugins_1.loadPlugins)(appDirectory, loaded.config, {
85
83
  internalPlugins: (_c = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _c === void 0 ? void 0 : _c.cli,
86
- transformPlugin: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.transformPlugin,
87
84
  autoLoad: (_d = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _d === void 0 ? void 0 : _d.autoLoad,
88
85
  forceAutoLoadPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.forceAutoLoadPlugins,
89
86
  });
@@ -1,18 +1,15 @@
1
1
  import { InternalPlugins } from '@modern-js/types';
2
2
  import type { CliPlugin, UserConfig, OldPluginConfig, PluginConfig } from './types';
3
- export type TransformPlugin = (plugin: PluginConfig, resolvedConfig: UserConfig, pluginOptions?: any) => PluginConfig;
4
3
  export declare const isOldPluginConfig: (config?: PluginConfig) => config is OldPluginConfig;
5
4
  /**
6
5
  * Load internal plugins which in @modern-js scope and user's custom plugins.
7
6
  * @param appDirectory - Application root directory.
8
7
  * @param userConfig - Resolved user config.
9
8
  * @param options.internalPlugins - Internal plugins.
10
- * @param options.transformPlugin - transform plugin before using it. Used for compatible with legacy jupiter plugins.
11
9
  * @returns Plugin Objects has been required.
12
10
  */
13
11
  export declare const loadPlugins: (appDirectory: string, userConfig: UserConfig, options?: {
14
12
  internalPlugins?: InternalPlugins;
15
13
  autoLoad?: InternalPlugins;
16
- transformPlugin?: TransformPlugin;
17
14
  forceAutoLoadPlugins?: boolean;
18
15
  }) => Promise<CliPlugin<{}, {}, {}, {}>[]>;
@@ -4,7 +4,7 @@ exports.loadPlugins = exports.isOldPluginConfig = void 0;
4
4
  const utils_1 = require("@modern-js/utils");
5
5
  const manager_1 = require("./manager");
6
6
  const debug = (0, utils_1.createDebugger)('load-plugins');
7
- const resolveCliPlugin = async (p, userConfig, appDirectory, transformPlugin) => {
7
+ const resolveCliPlugin = async (p, appDirectory) => {
8
8
  const pkg = typeof p === 'string' ? p : p[0];
9
9
  const pluginOptions = typeof p === 'string' ? undefined : p[1];
10
10
  const path = (0, utils_1.tryResolve)(pkg, appDirectory);
@@ -16,9 +16,6 @@ const resolveCliPlugin = async (p, userConfig, appDirectory, transformPlugin) =>
16
16
  // load esm module
17
17
  ({ default: module } = await (0, utils_1.dynamicImport)(path));
18
18
  }
19
- if (transformPlugin) {
20
- module = transformPlugin(module, userConfig, pluginOptions);
21
- }
22
19
  if (typeof module === 'function') {
23
20
  const result = module(pluginOptions);
24
21
  return (0, manager_1.createPlugin)(result.setup, result);
@@ -35,7 +32,6 @@ exports.isOldPluginConfig = isOldPluginConfig;
35
32
  * @param appDirectory - Application root directory.
36
33
  * @param userConfig - Resolved user config.
37
34
  * @param options.internalPlugins - Internal plugins.
38
- * @param options.transformPlugin - transform plugin before using it. Used for compatible with legacy jupiter plugins.
39
35
  * @returns Plugin Objects has been required.
40
36
  */
41
37
  const loadPlugins = async (appDirectory, userConfig, options = {}) => {
@@ -50,8 +46,7 @@ const loadPlugins = async (appDirectory, userConfig, options = {}) => {
50
46
  : []),
51
47
  ];
52
48
  const loadedPlugins = await Promise.all(plugins.map(plugin => {
53
- const loadedPlugin = resolveCliPlugin(plugin, userConfig, appDirectory, options.transformPlugin);
54
- // server plugins don't support to accept params
49
+ const loadedPlugin = resolveCliPlugin(plugin, appDirectory);
55
50
  debug(`resolve plugin %s: %s`, plugin, loadedPlugin);
56
51
  return loadedPlugin;
57
52
  }));
package/dist/manager.d.ts CHANGED
@@ -108,22 +108,4 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
108
108
  }, void>;
109
109
  beforeExit: import("@modern-js/plugin").AsyncWorkflow<void, void>;
110
110
  addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
111
- }>) => void, mountHook: () => import("@modern-js/plugin").ToRunners<{
112
- config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}, {}, {}, {}>>;
113
- resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
114
- resolved: import("./types").NormalizedConfig<{}, {}, {}, {}>;
115
- }>;
116
- validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
117
- prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
118
- afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
119
- watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
120
- fileChange: import("@modern-js/plugin").AsyncWorkflow<{
121
- filename: string;
122
- eventType: "add" | "unlink" | "change";
123
- }, void>;
124
- commands: import("@modern-js/plugin").AsyncWorkflow<{
125
- program: import("@modern-js/utils").Command;
126
- }, void>;
127
- beforeExit: import("@modern-js/plugin").AsyncWorkflow<void, void>;
128
- addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
129
- }>;
111
+ }>) => void;
package/dist/manager.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mountHook = exports.registerHook = exports.createPlugin = exports.manager = void 0;
3
+ exports.registerHook = exports.createPlugin = exports.manager = void 0;
4
4
  const plugin_1 = require("@modern-js/plugin");
5
5
  const context_1 = require("./context");
6
6
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -24,4 +24,4 @@ const pluginAPI = {
24
24
  useResolvedConfigContext: context_1.useResolvedConfigContext,
25
25
  };
26
26
  exports.manager = (0, plugin_1.createAsyncManager)(baseHooks, pluginAPI);
27
- exports.createPlugin = exports.manager.createPlugin, exports.registerHook = exports.manager.registerHook, exports.mountHook = exports.manager.useRunner;
27
+ exports.createPlugin = exports.manager.createPlugin, exports.registerHook = exports.manager.registerHook;
@@ -6,7 +6,6 @@ const lodash_1 = require("@modern-js/utils/lodash");
6
6
  const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
7
7
  // Do not use the following merge logic for source.designSystem and tools.tailwind(css)
8
8
  if (key === 'designSystem' ||
9
- (key === 'tailwind' && typeof source === 'object') ||
10
9
  (key === 'tailwindcss' && typeof source === 'object') ||
11
10
  key === 'devServer') {
12
11
  return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "modern",
11
11
  "modern.js"
12
12
  ],
13
- "version": "2.8.0",
13
+ "version": "2.9.0",
14
14
  "jsnext:source": "./src/index.ts",
15
15
  "types": "./dist/index.d.ts",
16
16
  "main": "./dist/index.js",
@@ -50,9 +50,9 @@
50
50
  }
51
51
  },
52
52
  "dependencies": {
53
- "@modern-js/node-bundle-require": "2.8.0",
54
- "@modern-js/plugin": "2.8.0",
55
- "@modern-js/utils": "2.8.0"
53
+ "@modern-js/node-bundle-require": "2.9.0",
54
+ "@modern-js/plugin": "2.9.0",
55
+ "@modern-js/utils": "2.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@jest/types": "^27.0.6",
@@ -70,11 +70,11 @@
70
70
  "terser-webpack-plugin": "^5.1.4",
71
71
  "typescript": "^4",
72
72
  "webpack": "^5.75.0",
73
- "@modern-js/builder-shared": "2.8.0",
74
- "@modern-js/babel-preset-app": "2.8.0",
75
- "@modern-js/types": "2.8.0",
76
- "@scripts/jest-config": "2.8.0",
77
- "@scripts/build": "2.8.0"
73
+ "@modern-js/builder-shared": "2.9.0",
74
+ "@modern-js/babel-preset-app": "2.9.0",
75
+ "@modern-js/types": "2.9.0",
76
+ "@scripts/jest-config": "2.9.0",
77
+ "@scripts/build": "2.9.0"
78
78
  },
79
79
  "sideEffects": false,
80
80
  "publishConfig": {