@modern-js/core 1.6.0 → 1.6.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 +10 -0
- package/dist/js/modern/config/index.js +2 -1
- package/dist/js/modern/config/types/index.js +0 -0
- package/dist/js/modern/config/types/less.js +0 -0
- package/dist/js/modern/config/types/sass.js +0 -0
- package/dist/js/modern/config/types/ssg.js +0 -0
- package/dist/js/modern/config/types/test.js +0 -0
- package/dist/js/modern/config/types/unbundle.js +0 -0
- package/dist/js/modern/initWatcher.js +1 -0
- package/dist/js/node/config/index.js +22 -1
- package/dist/js/node/config/types/index.js +0 -0
- package/dist/js/node/config/types/less.js +0 -0
- package/dist/js/node/config/types/sass.js +0 -0
- package/dist/js/node/config/types/ssg.js +0 -0
- package/dist/js/node/config/types/test.js +0 -0
- package/dist/js/node/config/types/unbundle.js +0 -0
- package/dist/js/node/initWatcher.js +1 -0
- package/dist/types/config/index.d.ts +3 -140
- package/dist/types/config/types/index.d.ts +231 -0
- package/dist/types/config/types/less.d.ts +10 -0
- package/dist/types/config/types/sass.d.ts +8 -0
- package/dist/types/config/types/ssg.d.ts +13 -0
- package/dist/types/config/types/test.d.ts +15 -0
- package/dist/types/config/types/unbundle.d.ts +28 -0
- package/jest.config.js +0 -1
- package/package.json +12 -7
- package/tests/config.test.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef28a4e6: fix: module-tools build error
|
|
8
|
+
- 132f7b53: feat: move config declarations to @modern-js/core
|
|
9
|
+
- 9d4a005b: fix: config babel via tools.babel
|
|
10
|
+
- Updated dependencies [132f7b53]
|
|
11
|
+
- @modern-js/utils@1.3.7
|
|
12
|
+
|
|
3
13
|
## 1.6.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -19,6 +19,7 @@ import { patchSchema } from "./schema";
|
|
|
19
19
|
const debug = createDebugger('resolve-config');
|
|
20
20
|
export { defaults as defaultsConfig };
|
|
21
21
|
export { mergeConfig };
|
|
22
|
+
export * from "./types";
|
|
22
23
|
export const defineConfig = config => config;
|
|
23
24
|
export const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
24
25
|
const loaded = await loadConfig(appDirectory, filePath, packageJsonConfig);
|
|
@@ -42,7 +43,7 @@ const showAdditionalPropertiesError = error => {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
/* eslint-disable
|
|
46
|
+
/* eslint-disable max-statements, max-params */
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
export const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -17,6 +17,7 @@ export const initWatcher = async (loaded, appDirectory, configDir, hooksRunner,
|
|
|
17
17
|
debug(`watched: %o`, watched);
|
|
18
18
|
const watcher = chokidar.watch(watched, {
|
|
19
19
|
cwd: appDirectory,
|
|
20
|
+
ignoreInitial: true,
|
|
20
21
|
ignorePermissionErrors: true,
|
|
21
22
|
ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
|
|
22
23
|
});
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
defineConfig: true,
|
|
8
|
+
loadUserConfig: true,
|
|
9
|
+
resolveConfig: true,
|
|
10
|
+
defaultsConfig: true,
|
|
11
|
+
mergeConfig: true
|
|
12
|
+
};
|
|
6
13
|
Object.defineProperty(exports, "defaultsConfig", {
|
|
7
14
|
enumerable: true,
|
|
8
15
|
get: function () {
|
|
@@ -42,6 +49,20 @@ var _mergeConfig = require("./mergeConfig");
|
|
|
42
49
|
|
|
43
50
|
var _schema = require("./schema");
|
|
44
51
|
|
|
52
|
+
var _types = require("./types");
|
|
53
|
+
|
|
54
|
+
Object.keys(_types).forEach(function (key) {
|
|
55
|
+
if (key === "default" || key === "__esModule") return;
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
57
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
58
|
+
Object.defineProperty(exports, key, {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return _types[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
45
66
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
46
67
|
|
|
47
68
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -80,7 +101,7 @@ const showAdditionalPropertiesError = error => {
|
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
103
|
};
|
|
83
|
-
/* eslint-disable
|
|
104
|
+
/* eslint-disable max-statements, max-params */
|
|
84
105
|
|
|
85
106
|
|
|
86
107
|
const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -35,6 +35,7 @@ const initWatcher = async (loaded, appDirectory, configDir, hooksRunner, argv) =
|
|
|
35
35
|
|
|
36
36
|
const watcher = _chokidar.default.watch(watched, {
|
|
37
37
|
cwd: appDirectory,
|
|
38
|
+
ignoreInitial: true,
|
|
38
39
|
ignorePermissionErrors: true,
|
|
39
40
|
ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
|
|
40
41
|
});
|
|
@@ -1,148 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import http from 'http';
|
|
3
1
|
import { ErrorObject } from 'ajv';
|
|
4
|
-
import { MetaOptions } from '@modern-js/utils';
|
|
5
|
-
import type { NextFunction, ProxyOptions } from '@modern-js/types';
|
|
6
|
-
import { PluginConfig } from '../loadPlugins';
|
|
7
2
|
import { defaults } from './defaults';
|
|
8
3
|
import { mergeConfig, NormalizedConfig } from './mergeConfig';
|
|
9
4
|
import { PluginValidateSchema } from './schema';
|
|
5
|
+
import type { UserConfig, ConfigParam, LoadedConfig } from './types';
|
|
10
6
|
export { defaults as defaultsConfig };
|
|
11
7
|
export { mergeConfig };
|
|
12
|
-
|
|
13
|
-
entries?: Record<string, string | {
|
|
14
|
-
entry: string;
|
|
15
|
-
enableFileSystemRoutes?: boolean;
|
|
16
|
-
disableMount?: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
disableDefaultEntries?: boolean;
|
|
19
|
-
entriesDir?: string;
|
|
20
|
-
configDir?: string;
|
|
21
|
-
apiDir?: string;
|
|
22
|
-
envVars?: Array<string>;
|
|
23
|
-
globalVars?: Record<string, string>;
|
|
24
|
-
alias?: Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>);
|
|
25
|
-
moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
|
|
26
|
-
include?: Array<string | RegExp>;
|
|
27
|
-
}
|
|
28
|
-
interface OutputConfig {
|
|
29
|
-
assetPrefix?: string;
|
|
30
|
-
htmlPath?: string;
|
|
31
|
-
jsPath?: string;
|
|
32
|
-
cssPath?: string;
|
|
33
|
-
mediaPath?: string;
|
|
34
|
-
path?: string;
|
|
35
|
-
title?: string;
|
|
36
|
-
titleByEntries?: Record<string, string>;
|
|
37
|
-
meta?: MetaOptions;
|
|
38
|
-
metaByEntries?: Record<string, MetaOptions>;
|
|
39
|
-
inject?: 'body' | 'head' | boolean;
|
|
40
|
-
injectByEntries?: Record<string, 'body' | 'head' | boolean>;
|
|
41
|
-
mountId?: string;
|
|
42
|
-
favicon?: string;
|
|
43
|
-
faviconByEntries?: Record<string, string | undefined>;
|
|
44
|
-
copy?: Array<Record<string, unknown> & {
|
|
45
|
-
from: string;
|
|
46
|
-
}>;
|
|
47
|
-
scriptExt?: Record<string, unknown>;
|
|
48
|
-
disableTsChecker?: boolean;
|
|
49
|
-
disableHtmlFolder?: boolean;
|
|
50
|
-
disableCssModuleExtension?: boolean;
|
|
51
|
-
disableCssExtract?: boolean;
|
|
52
|
-
enableCssModuleTSDeclaration?: boolean;
|
|
53
|
-
disableMinimize?: boolean;
|
|
54
|
-
enableInlineStyles?: boolean;
|
|
55
|
-
enableInlineScripts?: boolean;
|
|
56
|
-
disableSourceMap?: boolean;
|
|
57
|
-
disableInlineRuntimeChunk?: boolean;
|
|
58
|
-
disableAssetsCache?: boolean;
|
|
59
|
-
enableLatestDecorators?: boolean;
|
|
60
|
-
polyfill?: 'off' | 'usage' | 'entry' | 'ua';
|
|
61
|
-
dataUriLimit?: number;
|
|
62
|
-
templateParameters?: Record<string, unknown>;
|
|
63
|
-
templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
|
|
64
|
-
cssModuleLocalIdentName?: string;
|
|
65
|
-
enableModernMode?: boolean;
|
|
66
|
-
federation?: boolean;
|
|
67
|
-
disableNodePolyfill?: boolean;
|
|
68
|
-
enableTsLoader?: boolean;
|
|
69
|
-
}
|
|
70
|
-
interface ServerConfig {
|
|
71
|
-
routes?: Record<string, string | string[] | {
|
|
72
|
-
route: string | string[];
|
|
73
|
-
disableSpa?: boolean;
|
|
74
|
-
}>;
|
|
75
|
-
publicRoutes?: {
|
|
76
|
-
[filepath: string]: string;
|
|
77
|
-
};
|
|
78
|
-
ssr?: boolean | Record<string, unknown>;
|
|
79
|
-
ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
|
|
80
|
-
baseUrl?: string | Array<string>;
|
|
81
|
-
port?: number;
|
|
82
|
-
logger?: boolean | Record<string, any>;
|
|
83
|
-
metrics?: boolean | Record<string, any>;
|
|
84
|
-
enableMicroFrontendDebug?: boolean;
|
|
85
|
-
}
|
|
86
|
-
interface DevConfig {
|
|
87
|
-
assetPrefix?: string | boolean;
|
|
88
|
-
https?: boolean;
|
|
89
|
-
}
|
|
90
|
-
interface MicroFrontend {
|
|
91
|
-
enableHtmlEntry?: boolean;
|
|
92
|
-
externalBasicLibrary?: boolean;
|
|
93
|
-
moduleApp?: string;
|
|
94
|
-
}
|
|
95
|
-
interface DeployConfig {
|
|
96
|
-
microFrontend?: false | MicroFrontend;
|
|
97
|
-
domain?: string | Array<string>;
|
|
98
|
-
domainByEntries?: Record<string, string | Array<string>>;
|
|
99
|
-
}
|
|
100
|
-
declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>) => Record<string, unknown> | void);
|
|
101
|
-
declare type RequestHandler = (req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
|
102
|
-
declare type DevServerConfig = {
|
|
103
|
-
proxy?: ProxyOptions;
|
|
104
|
-
headers?: Record<string, string>;
|
|
105
|
-
before?: RequestHandler[];
|
|
106
|
-
after?: RequestHandler[];
|
|
107
|
-
[propsName: string]: any;
|
|
108
|
-
};
|
|
109
|
-
interface ToolsConfig {
|
|
110
|
-
webpack?: ConfigFunction;
|
|
111
|
-
babel?: ConfigFunction;
|
|
112
|
-
autoprefixer?: ConfigFunction;
|
|
113
|
-
postcss?: ConfigFunction;
|
|
114
|
-
styledComponents?: ConfigFunction;
|
|
115
|
-
lodash?: ConfigFunction;
|
|
116
|
-
devServer?: DevServerConfig;
|
|
117
|
-
tsLoader?: ConfigFunction;
|
|
118
|
-
terser?: ConfigFunction;
|
|
119
|
-
minifyCss?: ConfigFunction;
|
|
120
|
-
esbuild?: Record<string, unknown>;
|
|
121
|
-
}
|
|
122
|
-
declare type RuntimeConfig = Record<string, any>;
|
|
123
|
-
interface RuntimeByEntriesConfig {
|
|
124
|
-
[name: string]: RuntimeConfig;
|
|
125
|
-
}
|
|
126
|
-
interface UserConfig {
|
|
127
|
-
source?: SourceConfig;
|
|
128
|
-
output?: OutputConfig;
|
|
129
|
-
server?: ServerConfig;
|
|
130
|
-
dev?: DevConfig;
|
|
131
|
-
deploy?: DeployConfig;
|
|
132
|
-
tools?: ToolsConfig;
|
|
133
|
-
plugins?: PluginConfig;
|
|
134
|
-
runtime?: RuntimeConfig;
|
|
135
|
-
runtimeByEntries?: RuntimeByEntriesConfig;
|
|
136
|
-
}
|
|
137
|
-
declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
|
138
|
-
interface LoadedConfig {
|
|
139
|
-
config: UserConfig;
|
|
140
|
-
filePath: string | false;
|
|
141
|
-
dependencies: string[];
|
|
142
|
-
pkgConfig: UserConfig;
|
|
143
|
-
jsConfig: UserConfig;
|
|
144
|
-
}
|
|
8
|
+
export * from './types';
|
|
145
9
|
export declare const defineConfig: (config: ConfigParam) => ConfigParam;
|
|
146
10
|
export declare const loadUserConfig: (appDirectory: string, filePath?: string | undefined, packageJsonConfig?: string | undefined) => Promise<LoadedConfig>;
|
|
147
|
-
export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], restartWithExistingPort: number, argv: string[], onSchemaError?: (error: ErrorObject) => void) => Promise<NormalizedConfig>;
|
|
148
|
-
export type { SourceConfig, OutputConfig, ServerConfig, DevConfig, DeployConfig, ToolsConfig, RuntimeConfig, RuntimeByEntriesConfig, UserConfig, ConfigParam, LoadedConfig };
|
|
11
|
+
export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], restartWithExistingPort: number, argv: string[], onSchemaError?: (error: ErrorObject) => void) => Promise<NormalizedConfig>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import type { NextFunction, BffProxyOptions } from '@modern-js/types';
|
|
4
|
+
import type { MetaOptions } from '@modern-js/utils';
|
|
5
|
+
import type { TransformOptions } from '@babel/core';
|
|
6
|
+
import type { PluginConfig } from '../../loadPlugins';
|
|
7
|
+
import type { TestConfig, JestConfig } from './test';
|
|
8
|
+
import type { SassConfig, SassLoaderOptions } from './sass';
|
|
9
|
+
import type { LessConfig, LessLoaderOptions } from './less';
|
|
10
|
+
import type { UnbundleConfig } from './unbundle';
|
|
11
|
+
import type { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions } from './ssg';
|
|
12
|
+
export type { TestConfig, JestConfig, UnbundleConfig, SassConfig, SassLoaderOptions, LessConfig, LessLoaderOptions, SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, TransformOptions };
|
|
13
|
+
export interface SourceConfig {
|
|
14
|
+
entries?: Record<string, string | {
|
|
15
|
+
entry: string;
|
|
16
|
+
enableFileSystemRoutes?: boolean;
|
|
17
|
+
disableMount?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
disableDefaultEntries?: boolean;
|
|
20
|
+
entriesDir?: string;
|
|
21
|
+
configDir?: string;
|
|
22
|
+
apiDir?: string;
|
|
23
|
+
envVars?: Array<string>;
|
|
24
|
+
globalVars?: Record<string, string>;
|
|
25
|
+
alias?: Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>);
|
|
26
|
+
moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
|
|
27
|
+
include?: Array<string | RegExp>;
|
|
28
|
+
/**
|
|
29
|
+
* The configuration of `source.designSystem` is provided by plugin `@modern-js/plugin-tailwindcss`.
|
|
30
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
31
|
+
* @requires `@modern-js/plugin-tailwindcss`
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
designSystem?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
export interface OutputConfig {
|
|
37
|
+
assetPrefix?: string;
|
|
38
|
+
htmlPath?: string;
|
|
39
|
+
jsPath?: string;
|
|
40
|
+
cssPath?: string;
|
|
41
|
+
mediaPath?: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
titleByEntries?: Record<string, string>;
|
|
45
|
+
meta?: MetaOptions;
|
|
46
|
+
metaByEntries?: Record<string, MetaOptions>;
|
|
47
|
+
inject?: 'body' | 'head' | boolean;
|
|
48
|
+
injectByEntries?: Record<string, 'body' | 'head' | boolean>;
|
|
49
|
+
mountId?: string;
|
|
50
|
+
favicon?: string;
|
|
51
|
+
faviconByEntries?: Record<string, string | undefined>;
|
|
52
|
+
copy?: Array<Record<string, unknown> & {
|
|
53
|
+
from: string;
|
|
54
|
+
}>;
|
|
55
|
+
scriptExt?: Record<string, unknown>;
|
|
56
|
+
disableTsChecker?: boolean;
|
|
57
|
+
disableHtmlFolder?: boolean;
|
|
58
|
+
disableCssModuleExtension?: boolean;
|
|
59
|
+
disableCssExtract?: boolean;
|
|
60
|
+
enableCssModuleTSDeclaration?: boolean;
|
|
61
|
+
disableMinimize?: boolean;
|
|
62
|
+
enableInlineStyles?: boolean;
|
|
63
|
+
enableInlineScripts?: boolean;
|
|
64
|
+
disableSourceMap?: boolean;
|
|
65
|
+
disableInlineRuntimeChunk?: boolean;
|
|
66
|
+
disableAssetsCache?: boolean;
|
|
67
|
+
enableLatestDecorators?: boolean;
|
|
68
|
+
polyfill?: 'off' | 'usage' | 'entry' | 'ua';
|
|
69
|
+
dataUriLimit?: number;
|
|
70
|
+
templateParameters?: Record<string, unknown>;
|
|
71
|
+
templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
|
|
72
|
+
cssModuleLocalIdentName?: string;
|
|
73
|
+
enableModernMode?: boolean;
|
|
74
|
+
federation?: boolean;
|
|
75
|
+
disableNodePolyfill?: boolean;
|
|
76
|
+
enableTsLoader?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Disables lazy import support for styles, currently supports antd and arco-design.
|
|
79
|
+
* The configuration of `output.disableAutoImportStyle` is provided by plugin `@modern-js/plugin-unbundle`.
|
|
80
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
81
|
+
* @requires `@modern-js/plugin-unbundle`
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
disableAutoImportStyle?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The configuration of `output.ssg` is provided by plugin `@modern-js/plugin-ssg`.
|
|
87
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
88
|
+
* @requires `@modern-js/plugin-ssg`
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
ssg?: SSGConfig;
|
|
92
|
+
}
|
|
93
|
+
export interface ServerConfig {
|
|
94
|
+
routes?: Record<string, string | string[] | {
|
|
95
|
+
route: string | string[];
|
|
96
|
+
disableSpa?: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
publicRoutes?: {
|
|
99
|
+
[filepath: string]: string;
|
|
100
|
+
};
|
|
101
|
+
ssr?: boolean | Record<string, unknown>;
|
|
102
|
+
ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
|
|
103
|
+
baseUrl?: string | Array<string>;
|
|
104
|
+
port?: number;
|
|
105
|
+
logger?: boolean | Record<string, any>;
|
|
106
|
+
metrics?: boolean | Record<string, any>;
|
|
107
|
+
enableMicroFrontendDebug?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export declare type DevProxyOptions = string | Record<string, string>;
|
|
110
|
+
export interface DevConfig {
|
|
111
|
+
assetPrefix?: string | boolean;
|
|
112
|
+
https?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* The configuration of `dev.proxy` is provided by plugin `@modern-js/plugin-proxy`.
|
|
115
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
116
|
+
* @requires `@modern-js/plugin-proxy`
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
proxy?: DevProxyOptions;
|
|
120
|
+
/**
|
|
121
|
+
* The configuration of `dev.unbundle` is provided by plugin `@modern-js/plugin-unbundle`.
|
|
122
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
123
|
+
* @requires `@modern-js/plugin-unbundle`
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
unbundle?: UnbundleConfig;
|
|
127
|
+
}
|
|
128
|
+
export interface MicroFrontend {
|
|
129
|
+
enableHtmlEntry?: boolean;
|
|
130
|
+
externalBasicLibrary?: boolean;
|
|
131
|
+
moduleApp?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface DeployConfig {
|
|
134
|
+
microFrontend?: false | MicroFrontend;
|
|
135
|
+
domain?: string | Array<string>;
|
|
136
|
+
domainByEntries?: Record<string, string | Array<string>>;
|
|
137
|
+
}
|
|
138
|
+
declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>) => Record<string, unknown> | void);
|
|
139
|
+
export declare type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
140
|
+
export declare type DevServerConfig = {
|
|
141
|
+
proxy?: BffProxyOptions;
|
|
142
|
+
headers?: Record<string, string>;
|
|
143
|
+
before?: RequestHandler[];
|
|
144
|
+
after?: RequestHandler[];
|
|
145
|
+
[propsName: string]: any;
|
|
146
|
+
};
|
|
147
|
+
export declare type BabelConfig = TransformOptions | ((config: TransformOptions) => TransformOptions | void);
|
|
148
|
+
export interface ToolsConfig {
|
|
149
|
+
webpack?: ConfigFunction;
|
|
150
|
+
babel?: BabelConfig;
|
|
151
|
+
autoprefixer?: ConfigFunction;
|
|
152
|
+
postcss?: ConfigFunction;
|
|
153
|
+
styledComponents?: ConfigFunction;
|
|
154
|
+
lodash?: ConfigFunction;
|
|
155
|
+
devServer?: DevServerConfig;
|
|
156
|
+
tsLoader?: ConfigFunction;
|
|
157
|
+
terser?: ConfigFunction;
|
|
158
|
+
minifyCss?: ConfigFunction;
|
|
159
|
+
esbuild?: Record<string, unknown>;
|
|
160
|
+
/**
|
|
161
|
+
* The configuration of `tools.tailwindcss` is provided by plugin `@modern-js/plugin-tailwindcss`.
|
|
162
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
163
|
+
* @requires `@modern-js/plugin-tailwindcss`
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
167
|
+
/**
|
|
168
|
+
* The configuration of `tools.jest` is provided by plugin `@modern-js/plugin-testing`.
|
|
169
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
170
|
+
* @requires `@modern-js/plugin-testing`
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
jest?: TestConfig['jest'];
|
|
174
|
+
/**
|
|
175
|
+
* The configuration of `tools.sass` is provided by plugin `@modern-js/plugin-sass`.
|
|
176
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
177
|
+
* @requires `@modern-js/plugin-sass`
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
sass?: SassConfig;
|
|
181
|
+
/**
|
|
182
|
+
* The configuration of `tools.less` is provided by plugin `@modern-js/plugin-less`.
|
|
183
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
184
|
+
* @requires `@modern-js/plugin-less`
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
less?: LessConfig;
|
|
188
|
+
}
|
|
189
|
+
export declare type RuntimeConfig = Record<string, any>;
|
|
190
|
+
export interface RuntimeByEntriesConfig {
|
|
191
|
+
[name: string]: RuntimeConfig;
|
|
192
|
+
}
|
|
193
|
+
export declare type BffConfig = {
|
|
194
|
+
prefix?: string;
|
|
195
|
+
requestCreator?: string;
|
|
196
|
+
fetcher?: string;
|
|
197
|
+
proxy?: Record<string, any>;
|
|
198
|
+
};
|
|
199
|
+
export interface UserConfig {
|
|
200
|
+
source?: SourceConfig;
|
|
201
|
+
output?: OutputConfig;
|
|
202
|
+
server?: ServerConfig;
|
|
203
|
+
dev?: DevConfig;
|
|
204
|
+
deploy?: DeployConfig;
|
|
205
|
+
tools?: ToolsConfig;
|
|
206
|
+
plugins?: PluginConfig;
|
|
207
|
+
runtime?: RuntimeConfig;
|
|
208
|
+
runtimeByEntries?: RuntimeByEntriesConfig;
|
|
209
|
+
/**
|
|
210
|
+
* The configuration of `bff` is provided by plugin `@modern-js/plugin-bff`.
|
|
211
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
212
|
+
* @requires `@modern-js/plugin-bff`
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
bff?: BffConfig;
|
|
216
|
+
/**
|
|
217
|
+
* The configuration of `testing` is provided by plugin `@modern-js/plugin-testing`.
|
|
218
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
219
|
+
* @requires `@modern-js/plugin-testing`
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
testing?: TestConfig;
|
|
223
|
+
}
|
|
224
|
+
export declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
|
225
|
+
export interface LoadedConfig {
|
|
226
|
+
config: UserConfig;
|
|
227
|
+
filePath: string | false;
|
|
228
|
+
dependencies: string[];
|
|
229
|
+
pkgConfig: UserConfig;
|
|
230
|
+
jsConfig: UserConfig;
|
|
231
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="less" />
|
|
2
|
+
import type { LoaderContext } from 'webpack';
|
|
3
|
+
export declare type LessLoaderOptions = {
|
|
4
|
+
lessOptions?: Less.Options;
|
|
5
|
+
additionalData?: string | ((content: string, loaderContext: LoaderContext<LessLoaderOptions>) => string);
|
|
6
|
+
sourceMap?: boolean;
|
|
7
|
+
webpackImporter?: boolean;
|
|
8
|
+
implementation?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare type LessConfig = LessLoaderOptions | ((options: LessLoaderOptions) => LessLoaderOptions | void);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LegacyFileOptions } from 'sass';
|
|
2
|
+
export interface SassLoaderOptions {
|
|
3
|
+
sassOptions?: LegacyFileOptions<'sync'>;
|
|
4
|
+
sourceMap?: boolean;
|
|
5
|
+
implementation?: string;
|
|
6
|
+
additionalData?: string | ((content: string, filename: string) => string);
|
|
7
|
+
}
|
|
8
|
+
export declare type SassConfig = SassLoaderOptions | ((options: SassLoaderOptions) => SassLoaderOptions | void);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type SSGRouteOptions = string | {
|
|
2
|
+
url: string;
|
|
3
|
+
output?: string;
|
|
4
|
+
params?: Record<string, any>[];
|
|
5
|
+
headers?: Record<string, any>;
|
|
6
|
+
};
|
|
7
|
+
export declare type SSGSingleEntryOptions = boolean | {
|
|
8
|
+
preventDefault?: string[];
|
|
9
|
+
headers?: Record<string, any>;
|
|
10
|
+
routes?: SSGRouteOptions[];
|
|
11
|
+
};
|
|
12
|
+
export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
|
|
13
|
+
export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string) => SSGSingleEntryOptions);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Config as JestConfigTypes } from '@jest/types';
|
|
2
|
+
export declare type JestConfig = JestConfigTypes.InitialOptions;
|
|
3
|
+
export interface TestConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Decide which transformer will be used to compile file
|
|
6
|
+
* Default: babel-jest
|
|
7
|
+
*/
|
|
8
|
+
transformer?: 'babel-jest' | 'ts-jest';
|
|
9
|
+
/**
|
|
10
|
+
* Original jest config
|
|
11
|
+
* Doc: https://jestjs.io/docs/configuration
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare type UnbundleConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* Some package A may require another package B that is intended for Node.js
|
|
4
|
+
* use only. In such a case, if package B cannot be converted to ESM, it will
|
|
5
|
+
* cause package A to fail during unbundle development, even though package B
|
|
6
|
+
* is not really required. Package B can thus be safely ignored via this option
|
|
7
|
+
* to ensure transpilation of package A to ESM
|
|
8
|
+
*/
|
|
9
|
+
ignore?: string | string[];
|
|
10
|
+
/**
|
|
11
|
+
* ignores cached esm modules and recompiles dependencies not available
|
|
12
|
+
* from PDN host on dev start.
|
|
13
|
+
* default: false
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
ignoreModuleCache?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* clears cache of downloaded esm modules (from PDN) on dev start.
|
|
19
|
+
* default: false
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
clearPdnCache?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* modifies host to attempt to download esm modules from
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
pdnHost?: string;
|
|
28
|
+
};
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.6.
|
|
14
|
+
"version": "1.6.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/runtime": "^7",
|
|
45
45
|
"@modern-js/load-config": "^1.2.2",
|
|
46
46
|
"@modern-js/plugin": "^1.3.2",
|
|
47
|
-
"@modern-js/utils": "^1.3.
|
|
47
|
+
"@modern-js/utils": "^1.3.7",
|
|
48
48
|
"address": "^1.1.2",
|
|
49
49
|
"ajv": "^8.6.2",
|
|
50
50
|
"ajv-keywords": "^5.0.0",
|
|
@@ -59,20 +59,25 @@
|
|
|
59
59
|
"v8-compile-cache": "^2.3.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"
|
|
62
|
+
"@jest/types": "^27.0.6",
|
|
63
|
+
"@modern-js/types": "^1.3.6",
|
|
64
|
+
"@scripts/build": "0.0.0",
|
|
65
|
+
"@scripts/jest-config": "0.0.0",
|
|
63
66
|
"@types/babel__code-frame": "^7.0.3",
|
|
64
|
-
"@
|
|
67
|
+
"@types/babel__core": "^7.1.16",
|
|
65
68
|
"@types/jest": "^26",
|
|
69
|
+
"@types/less": "^3.0.3",
|
|
66
70
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
67
71
|
"@types/lodash.mergewith": "^4.6.6",
|
|
68
72
|
"@types/node": "^14",
|
|
69
73
|
"@types/react": "^17",
|
|
70
74
|
"@types/react-dom": "^17",
|
|
71
75
|
"@types/signale": "^1.4.2",
|
|
72
|
-
"
|
|
76
|
+
"btsm": "2.2.2",
|
|
73
77
|
"jest": "^27",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
78
|
+
"sass": "^1.45.0",
|
|
79
|
+
"typescript": "^4",
|
|
80
|
+
"webpack": "^5.71.0"
|
|
76
81
|
},
|
|
77
82
|
"sideEffects": false,
|
|
78
83
|
"modernConfig": {
|
package/tests/config.test.ts
CHANGED
|
@@ -26,7 +26,7 @@ jest.mock('@modern-js/utils', () => ({
|
|
|
26
26
|
|
|
27
27
|
describe('config', () => {
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* TypeScript Type annotations cannot be used for esbuild-jest
|
|
30
30
|
* test files that use jest.mock('@some/module')
|
|
31
31
|
* refer to this esbuild-jest issue:
|
|
32
32
|
* https://github.com/aelbore/esbuild-jest/issues/57
|