@modern-js/core 1.12.0 → 1.12.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.
- package/CHANGELOG.md +15 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +15 -2
- package/dist/config/types/index.d.ts +7 -5
- package/dist/pluginAPI.d.ts +3 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b255072f2: fix(core): failed to load user plugins in modern.config.js
|
|
8
|
+
- 7975bfa68: fix(core): incorrect type of tools.terser
|
|
9
|
+
- b7302f781: Export some required types
|
|
10
|
+
- Updated dependencies [63c354ad5]
|
|
11
|
+
- Updated dependencies [073e9ad78]
|
|
12
|
+
- Updated dependencies [b7302f781]
|
|
13
|
+
- Updated dependencies [f4a7d49e1]
|
|
14
|
+
- Updated dependencies [e0e708f83]
|
|
15
|
+
- @modern-js/utils@1.7.8
|
|
16
|
+
- @modern-js/plugin@1.3.8
|
|
17
|
+
|
|
3
18
|
## 1.12.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/config/index.d.ts
CHANGED
|
@@ -8,5 +8,9 @@ export { mergeConfig };
|
|
|
8
8
|
export * from './types';
|
|
9
9
|
export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
|
|
10
10
|
export declare const defineConfig: (config: ConfigParam) => ConfigParam;
|
|
11
|
+
/**
|
|
12
|
+
* Assign the pkg config into the user config.
|
|
13
|
+
*/
|
|
14
|
+
export declare const assignPkgConfig: (userConfig?: UserConfig, pkgConfig?: ConfigParam) => UserConfig & ConfigParam;
|
|
11
15
|
export declare const loadUserConfig: (appDirectory: string, filePath?: string | undefined, packageJsonConfig?: string | undefined) => Promise<LoadedConfig>;
|
|
12
16
|
export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], restartWithExistingPort: number, argv: string[], onSchemaError?: (error: ErrorObject) => void | Promise<void>) => Promise<NormalizedConfig>;
|
package/dist/config/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.resolveConfig = exports.loadUserConfig = exports.defineConfig = exports.addServerConfigToDeps = exports.mergeConfig = exports.defaultsConfig = void 0;
|
|
16
|
+
exports.resolveConfig = exports.loadUserConfig = exports.assignPkgConfig = exports.defineConfig = exports.addServerConfigToDeps = exports.mergeConfig = exports.defaultsConfig = void 0;
|
|
17
17
|
const load_config_1 = require("@modern-js/load-config");
|
|
18
18
|
const utils_1 = require("@modern-js/utils");
|
|
19
19
|
const lodash_1 = require("@modern-js/utils/lodash");
|
|
@@ -37,6 +37,19 @@ const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFil
|
|
|
37
37
|
exports.addServerConfigToDeps = addServerConfigToDeps;
|
|
38
38
|
const defineConfig = (config) => config;
|
|
39
39
|
exports.defineConfig = defineConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Assign the pkg config into the user config.
|
|
42
|
+
*/
|
|
43
|
+
const assignPkgConfig = (userConfig = {}, pkgConfig = {}) => (0, lodash_1.mergeWith)({}, userConfig, pkgConfig, (objValue, srcValue) => {
|
|
44
|
+
// mergeWith can not merge object with symbol, but plugins object contains symbol,
|
|
45
|
+
// so we need to handle it manually.
|
|
46
|
+
if (objValue === undefined && (0, utils_1.isPlainObject)(srcValue)) {
|
|
47
|
+
return { ...srcValue };
|
|
48
|
+
}
|
|
49
|
+
// return undefined to use the default behavior of mergeWith
|
|
50
|
+
return undefined;
|
|
51
|
+
});
|
|
52
|
+
exports.assignPkgConfig = assignPkgConfig;
|
|
40
53
|
const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
41
54
|
const loaded = await (0, load_config_1.loadConfig)(appDirectory, filePath, packageJsonConfig);
|
|
42
55
|
const config = !loaded
|
|
@@ -45,7 +58,7 @@ const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
|
45
58
|
? loaded.config(0)
|
|
46
59
|
: loaded.config);
|
|
47
60
|
return {
|
|
48
|
-
config: (0,
|
|
61
|
+
config: (0, exports.assignPkgConfig)(config, loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig),
|
|
49
62
|
jsConfig: config || {},
|
|
50
63
|
pkgConfig: ((loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
|
51
64
|
filePath: loaded === null || loaded === void 0 ? void 0 : loaded.path,
|
|
@@ -4,7 +4,7 @@ import type { NextFunction, BffProxyOptions } from '@modern-js/types';
|
|
|
4
4
|
import type { MetaOptions, ChainIdentifier } from '@modern-js/utils';
|
|
5
5
|
import type { TransformOptions, PluginItem as BabelPlugin } from '@babel/core';
|
|
6
6
|
import type webpack from 'webpack';
|
|
7
|
-
import type { RuleSetRule, Configuration as WebpackConfiguration } from 'webpack';
|
|
7
|
+
import type { RuleSetRule, Configuration as WebpackConfiguration, WebpackPluginInstance } from 'webpack';
|
|
8
8
|
import type WebpackChain from '@modern-js/utils/webpack-chain';
|
|
9
9
|
import type autoprefixer from 'autoprefixer';
|
|
10
10
|
import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
|
|
@@ -19,7 +19,9 @@ import type { ElectronConfig } from './electron';
|
|
|
19
19
|
import type { PostCSSLoaderOptions } from './postcss';
|
|
20
20
|
import type { TsLoaderOptions } from './ts-loader';
|
|
21
21
|
declare type AutoprefixerOptions = autoprefixer.Options;
|
|
22
|
-
declare type TerserOptions = BasePluginOptions &
|
|
22
|
+
declare type TerserOptions = BasePluginOptions & {
|
|
23
|
+
terserOptions?: Partial<RawTerserOptions>;
|
|
24
|
+
};
|
|
23
25
|
export type { TestConfig, JestConfig, UnbundleConfig, SassConfig, SassLoaderOptions, LessConfig, LessLoaderOptions, SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, TransformOptions, AutoprefixerOptions, TerserOptions, };
|
|
24
26
|
export interface SourceConfig {
|
|
25
27
|
entries?: Record<string, string | {
|
|
@@ -160,9 +162,9 @@ export declare type WebpackConfigUtils = {
|
|
|
160
162
|
env: string;
|
|
161
163
|
name: string;
|
|
162
164
|
webpack: typeof webpack;
|
|
163
|
-
addRules: (rules: RuleSetRule[]) => void;
|
|
164
|
-
prependPlugins: (plugins:
|
|
165
|
-
appendPlugins: (plugins:
|
|
165
|
+
addRules: (rules: RuleSetRule | RuleSetRule[]) => void;
|
|
166
|
+
prependPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
|
|
167
|
+
appendPlugins: (plugins: WebpackPluginInstance | WebpackPluginInstance[]) => void;
|
|
166
168
|
removePlugin: (pluginName: string) => void;
|
|
167
169
|
/**
|
|
168
170
|
* @deprecated please use `tools.webpackChain` instead.
|
package/dist/pluginAPI.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import type { CommonAPI } from '@modern-js/plugin';
|
|
|
2
2
|
import type { CliHooks } from './manager';
|
|
3
3
|
import { AppContext, ConfigContext, useAppContext, useConfigContext, ResolvedConfigContext, useResolvedConfigContext } from './context';
|
|
4
4
|
export declare const pluginAPI: {
|
|
5
|
-
setAppContext: (value: import("@modern-js/types
|
|
6
|
-
useAppContext: () => import("@modern-js/types
|
|
5
|
+
setAppContext: (value: import("@modern-js/types").IAppContext) => void;
|
|
6
|
+
useAppContext: () => import("@modern-js/types").IAppContext;
|
|
7
7
|
useConfigContext: () => import("./config").UserConfig;
|
|
8
8
|
useResolvedConfigContext: () => import(".").NormalizedConfig;
|
|
9
9
|
};
|
|
10
|
+
export type { IAppContext } from '@modern-js/types';
|
|
10
11
|
/** all apis for cli plugin */
|
|
11
12
|
export declare type PluginAPI = typeof pluginAPI & CommonAPI<CliHooks>;
|
|
12
13
|
export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.12.
|
|
14
|
+
"version": "1.12.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"main": "./dist/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@modern-js/load-config": "^1.3.4",
|
|
43
|
-
"@modern-js/plugin": "^1.3.
|
|
44
|
-
"@modern-js/utils": "^1.7.
|
|
43
|
+
"@modern-js/plugin": "^1.3.8",
|
|
44
|
+
"@modern-js/utils": "^1.7.8"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@jest/types": "^27.0.6",
|