@modern-js/module-tools 2.1.0 → 2.1.1-beta.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.
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/config/defineConfig.d.ts +8 -2
- package/dist/config/defineConfig.js +25 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacy-schema.d.ts +649 -0
- package/dist/config/legacy-schema.js +220 -0
- package/dist/config/legacy-schema.js.map +1 -0
- package/dist/config/normalize.js +6 -1
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +13 -1
- package/dist/config/schema.js +12 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transform-legacy-config.d.ts +27 -0
- package/dist/config/transform-legacy-config.js +424 -0
- package/dist/config/transform-legacy-config.js.map +1 -0
- package/dist/constants/build-presets.d.ts +5 -0
- package/dist/constants/build-presets.js +6 -1
- package/dist/constants/build-presets.js.map +1 -1
- package/dist/constants/legacy-build-presets.d.ts +5 -0
- package/dist/constants/legacy-build-presets.js +5 -0
- package/dist/constants/legacy-build-presets.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/legacyConfig/index.d.ts +20 -0
- package/dist/types/legacyConfig/index.js +17 -0
- package/dist/types/legacyConfig/index.js.map +1 -0
- package/dist/types/legacyConfig/output.d.ts +65 -0
- package/dist/types/legacyConfig/output.js +17 -0
- package/dist/types/legacyConfig/output.js.map +1 -0
- package/dist/types/legacyConfig/source.d.ts +14 -0
- package/dist/types/legacyConfig/source.js +17 -0
- package/dist/types/legacyConfig/source.js.map +1 -0
- package/dist/types/legacyConfig/tools.d.ts +57 -0
- package/dist/types/legacyConfig/tools.js +17 -0
- package/dist/types/legacyConfig/tools.js.map +1 -0
- package/dist/utils/config.d.ts +5 -2
- package/dist/utils/config.js +3 -0
- package/dist/utils/config.js.map +1 -1
- package/package.json +9 -9
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
2
2
|
import { ModuleToolsHooks } from './hooks';
|
|
3
3
|
import { ModuleExtraConfig } from './config';
|
|
4
|
+
import type { ModuleToolsLegacyUserConfig, ModuleToolsLegacyNormalizedConfig } from './legacyConfig';
|
|
4
5
|
export * from './hooks';
|
|
5
6
|
export * from './command';
|
|
6
7
|
export * from './config';
|
|
8
|
+
export * from './legacyConfig';
|
|
7
9
|
export * from './dts';
|
|
8
10
|
export * from './context';
|
|
9
11
|
export type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';
|
|
@@ -12,6 +14,13 @@ export type ModuleTools = {
|
|
|
12
14
|
userConfig: ModuleExtraConfig;
|
|
13
15
|
normalizedConfig: Required<ModuleExtraConfig>;
|
|
14
16
|
};
|
|
17
|
+
export type LegacyModuleTools = {
|
|
18
|
+
hooks: ModuleToolsHooks;
|
|
19
|
+
userConfig: ModuleToolsLegacyUserConfig;
|
|
20
|
+
normalizedConfig: ModuleToolsLegacyNormalizedConfig;
|
|
21
|
+
};
|
|
15
22
|
export type ModuleUserConfig = UserConfig<ModuleTools>;
|
|
23
|
+
export type ModuleLegacyUserConfig = UserConfig<LegacyModuleTools>;
|
|
16
24
|
export type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;
|
|
25
|
+
export type ModuleLegacyNormalizedConfig = NormalizedConfig<LegacyModuleTools>;
|
|
17
26
|
export type ModuleConfigParams = ModuleUserConfig | Promise<ModuleUserConfig> | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);
|
package/dist/types/index.js
CHANGED
|
@@ -17,6 +17,7 @@ module.exports = __toCommonJS(types_exports);
|
|
|
17
17
|
__reExport(types_exports, require("./hooks"), module.exports);
|
|
18
18
|
__reExport(types_exports, require("./command"), module.exports);
|
|
19
19
|
__reExport(types_exports, require("./config"), module.exports);
|
|
20
|
+
__reExport(types_exports, require("./legacyConfig"), module.exports);
|
|
20
21
|
__reExport(types_exports, require("./dts"), module.exports);
|
|
21
22
|
__reExport(types_exports, require("./context"), module.exports);
|
|
22
23
|
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAQA,0BAAc,oBARd;AASA,0BAAc,sBATd;AAUA,0BAAc,qBAVd;AAWA,0BAAc,2BAXd;AAYA,0BAAc,kBAZd;AAaA,0BAAc,sBAbd;","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import { NormalizedConfig, UserConfig } from '@modern-js/core';\nimport { ModuleToolsHooks } from './hooks';\nimport { ModuleExtraConfig } from './config';\nimport type {\n ModuleToolsLegacyUserConfig,\n ModuleToolsLegacyNormalizedConfig,\n} from './legacyConfig';\n\nexport * from './hooks';\nexport * from './command';\nexport * from './config';\nexport * from './legacyConfig';\nexport * from './dts';\nexport * from './context';\nexport type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';\n\nexport type ModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleExtraConfig;\n normalizedConfig: Required<ModuleExtraConfig>;\n};\nexport type LegacyModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleToolsLegacyUserConfig;\n normalizedConfig: ModuleToolsLegacyNormalizedConfig;\n};\n\nexport type ModuleUserConfig = UserConfig<ModuleTools>;\nexport type ModuleLegacyUserConfig = UserConfig<LegacyModuleTools>;\n\nexport type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;\nexport type ModuleLegacyNormalizedConfig = NormalizedConfig<LegacyModuleTools>;\n\n// params type for defineConfig\nexport type ModuleConfigParams =\n | ModuleUserConfig\n | Promise<ModuleUserConfig>\n | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OutputLegacyUserConfig } from './output';
|
|
2
|
+
import type { SourceLegacyUserConfig } from './source';
|
|
3
|
+
import type { ToolsLegacyUserConfig } from './tools';
|
|
4
|
+
export type { OutputLegacyUserConfig } from './output';
|
|
5
|
+
export type { SourceLegacyUserConfig } from './source';
|
|
6
|
+
export type { ToolsLegacyUserConfig } from './tools';
|
|
7
|
+
export interface RuntimeLegacyConfig {
|
|
8
|
+
[name: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface RuntimeByEntriesLegacyConfig {
|
|
11
|
+
[name: string]: RuntimeLegacyConfig;
|
|
12
|
+
}
|
|
13
|
+
export type ModuleToolsLegacyUserConfig = {
|
|
14
|
+
source?: SourceLegacyUserConfig;
|
|
15
|
+
output?: OutputLegacyUserConfig;
|
|
16
|
+
tools?: ToolsLegacyUserConfig;
|
|
17
|
+
runtime?: RuntimeLegacyConfig;
|
|
18
|
+
legacy?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ModuleToolsLegacyNormalizedConfig = Required<ModuleToolsLegacyUserConfig>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var legacyConfig_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(legacyConfig_exports);
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/index.ts"],"sourcesContent":["import type { OutputLegacyUserConfig } from './output';\nimport type { SourceLegacyUserConfig } from './source';\n\nimport type { ToolsLegacyUserConfig } from './tools';\n\nexport type { OutputLegacyUserConfig } from './output';\n\nexport type { SourceLegacyUserConfig } from './source';\nexport type { ToolsLegacyUserConfig } from './tools';\n\nexport interface RuntimeLegacyConfig {\n [name: string]: any;\n}\n\nexport interface RuntimeByEntriesLegacyConfig {\n [name: string]: RuntimeLegacyConfig;\n}\n\nexport type ModuleToolsLegacyUserConfig = {\n source?: SourceLegacyUserConfig;\n output?: OutputLegacyUserConfig;\n tools?: ToolsLegacyUserConfig;\n runtime?: RuntimeLegacyConfig;\n legacy?: boolean;\n};\n\nexport type ModuleToolsLegacyNormalizedConfig =\n Required<ModuleToolsLegacyUserConfig>;\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { UserConfig as LibuildUserConfig } from '@modern-js/libuild';
|
|
2
|
+
export type LegacyBuildPreset = 'npm-library' | 'npm-library-with-umd' | 'npm-component' | 'npm-component-with-umd';
|
|
3
|
+
export type LegacyFormat = 'esm' | 'cjs' | 'umd';
|
|
4
|
+
export type LegacyTarget = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'esnext';
|
|
5
|
+
export type LegacyBuildType = 'bundle' | 'bundleless';
|
|
6
|
+
export type LegacySourceMap = boolean | 'inline' | 'external';
|
|
7
|
+
export type LegacyBundleOptions = {
|
|
8
|
+
entry?: Record<string, string>;
|
|
9
|
+
platform?: LibuildUserConfig['platform'];
|
|
10
|
+
splitting?: boolean;
|
|
11
|
+
minify?: LibuildUserConfig['minify'];
|
|
12
|
+
externals?: LibuildUserConfig['external'];
|
|
13
|
+
skipDeps?: boolean;
|
|
14
|
+
getModuleId?: (moduleName: string) => string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type LegacyBundlelessOptions = {
|
|
17
|
+
sourceDir?: string;
|
|
18
|
+
style?: {
|
|
19
|
+
compileMode?: 'all' | 'only-compiled-code' |
|
|
20
|
+
/* may be will be deprecated */
|
|
21
|
+
'only-source-code' | false;
|
|
22
|
+
path?: string;
|
|
23
|
+
};
|
|
24
|
+
static?: {
|
|
25
|
+
path?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type LegacyBaseBuildConfig = {
|
|
29
|
+
format?: LegacyFormat;
|
|
30
|
+
target?: LegacyTarget;
|
|
31
|
+
sourceMap?: LegacySourceMap;
|
|
32
|
+
buildType?: LegacyBuildType;
|
|
33
|
+
bundleOptions?: LegacyBundleOptions;
|
|
34
|
+
bundlelessOptions?: LegacyBundlelessOptions;
|
|
35
|
+
tsconfig?: string;
|
|
36
|
+
enableDts?: boolean;
|
|
37
|
+
dtsOnly?: boolean;
|
|
38
|
+
outputPath?: string;
|
|
39
|
+
};
|
|
40
|
+
export type LegacyBuildConfig = LegacyBaseBuildConfig | LegacyBaseBuildConfig[];
|
|
41
|
+
export type JsSyntaxType = 'CJS+ES6' | 'ESM+ES5' | 'ESM+ES6';
|
|
42
|
+
export interface PackageFields {
|
|
43
|
+
main?: JsSyntaxType;
|
|
44
|
+
'jsnext:modern'?: JsSyntaxType;
|
|
45
|
+
module?: JsSyntaxType;
|
|
46
|
+
}
|
|
47
|
+
export type OutputLegacyUserConfig = {
|
|
48
|
+
jsPath?: string;
|
|
49
|
+
path?: string;
|
|
50
|
+
copy?: Array<Record<string, unknown> & {
|
|
51
|
+
from: string;
|
|
52
|
+
}>;
|
|
53
|
+
disableTsChecker?: boolean;
|
|
54
|
+
/** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */
|
|
55
|
+
|
|
56
|
+
assetsPath?: string;
|
|
57
|
+
/** @deprecated Use the `buildConfig.sourceMap` instead */
|
|
58
|
+
|
|
59
|
+
disableSourceMap?: boolean;
|
|
60
|
+
buildPreset?: LegacyBuildPreset;
|
|
61
|
+
buildConfig?: LegacyBuildConfig;
|
|
62
|
+
importStyle?: 'source-code' | 'compiled-code';
|
|
63
|
+
packageMode?: 'universal-js' | 'universal-js-lite' | 'browser-js' | 'browser-js-lite' | 'node-js';
|
|
64
|
+
packageFields?: PackageFields;
|
|
65
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var output_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(output_exports);
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/output.ts"],"sourcesContent":["import type { UserConfig as LibuildUserConfig } from '@modern-js/libuild';\n\nexport type LegacyBuildPreset =\n | 'npm-library'\n | 'npm-library-with-umd'\n | 'npm-component'\n | 'npm-component-with-umd';\n\nexport type LegacyFormat = 'esm' | 'cjs' | 'umd';\nexport type LegacyTarget =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\nexport type LegacyBuildType = 'bundle' | 'bundleless';\nexport type LegacySourceMap = boolean | 'inline' | 'external';\n\nexport type LegacyBundleOptions = {\n entry?: Record<string, string>;\n platform?: LibuildUserConfig['platform'];\n splitting?: boolean;\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n skipDeps?: boolean;\n getModuleId?: (moduleName: string) => string | undefined;\n};\n\nexport type LegacyBundlelessOptions = {\n sourceDir?: string;\n style?: {\n compileMode?:\n | 'all'\n | 'only-compiled-code'\n | /* may be will be deprecated */ 'only-source-code'\n | false;\n path?: string;\n };\n static?: {\n path?: string;\n };\n};\n\nexport type LegacyBaseBuildConfig = {\n format?: LegacyFormat;\n target?: LegacyTarget;\n sourceMap?: LegacySourceMap;\n buildType?: LegacyBuildType;\n bundleOptions?: LegacyBundleOptions;\n bundlelessOptions?: LegacyBundlelessOptions;\n tsconfig?: string;\n enableDts?: boolean;\n dtsOnly?: boolean;\n outputPath?: string;\n};\n\nexport type LegacyBuildConfig = LegacyBaseBuildConfig | LegacyBaseBuildConfig[];\n\nexport type JsSyntaxType = 'CJS+ES6' | 'ESM+ES5' | 'ESM+ES6';\nexport interface PackageFields {\n main?: JsSyntaxType;\n 'jsnext:modern'?: JsSyntaxType;\n module?: JsSyntaxType;\n}\n\nexport type OutputLegacyUserConfig = {\n jsPath?: string;\n path?: string;\n copy?: Array<Record<string, unknown> & { from: string }>;\n disableTsChecker?: boolean;\n /** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */\n assetsPath?: string;\n /** @deprecated Use the `buildConfig.sourceMap` instead */\n disableSourceMap?: boolean;\n buildPreset?: LegacyBuildPreset;\n buildConfig?: LegacyBuildConfig;\n importStyle?: 'source-code' | 'compiled-code';\n packageMode?:\n | 'universal-js'\n | 'universal-js-lite'\n | 'browser-js'\n | 'browser-js-lite'\n | 'node-js';\n packageFields?: PackageFields;\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AliasOption } from '../config';
|
|
2
|
+
export type SourceLegacyUserConfig = {
|
|
3
|
+
alias?: AliasOption;
|
|
4
|
+
envVars?: Array<string>;
|
|
5
|
+
globalVars?: Record<string, string>;
|
|
6
|
+
jsxTransformRuntime?: 'automatic' | 'classic';
|
|
7
|
+
/**
|
|
8
|
+
* The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
|
|
9
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
10
|
+
* @requires `tailwindcss` plugin
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
designSystem?: Record<string, any>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var source_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(source_exports);
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/source.ts"],"sourcesContent":["import type { AliasOption } from '../config';\n\nexport type SourceLegacyUserConfig = {\n alias?: AliasOption;\n envVars?: Array<string>;\n globalVars?: Record<string, string>;\n jsxTransformRuntime?: 'automatic' | 'classic';\n /**\n * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n designSystem?: Record<string, any>;\n};\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { JestConfig } from '@modern-js/core';
|
|
2
|
+
import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
|
|
3
|
+
import type { LessConfig, SassConfig } from '../config';
|
|
4
|
+
export type PostCSSOptions = {
|
|
5
|
+
to?: string;
|
|
6
|
+
from?: string;
|
|
7
|
+
map?: any;
|
|
8
|
+
syntax?: any;
|
|
9
|
+
parser?: any;
|
|
10
|
+
plugins?: PostCSSPlugin[];
|
|
11
|
+
stringifier?: any;
|
|
12
|
+
};
|
|
13
|
+
export type PostCSSLoaderOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
|
|
16
|
+
*/
|
|
17
|
+
execute?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
sourceMap?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The special implementation option determines which implementation of PostCSS to use.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
implementation?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Allows to set PostCSS options and plugins.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
postcssOptions?: PostCSSOptions;
|
|
33
|
+
};
|
|
34
|
+
export type PostCSSConfigUtils = {
|
|
35
|
+
addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
|
|
36
|
+
};
|
|
37
|
+
interface ToolsConfig {
|
|
38
|
+
speedy?: any | ((config: any) => any);
|
|
39
|
+
}
|
|
40
|
+
export type PostCSSFunction = (options: PostCSSLoaderOptions, utils: PostCSSConfigUtils) => PostCSSLoaderOptions | void;
|
|
41
|
+
export type ToolsLegacyUserConfig = {
|
|
42
|
+
babel?: any;
|
|
43
|
+
less?: LessConfig;
|
|
44
|
+
lodash?: any;
|
|
45
|
+
postcss?: PostCSSLoaderOptions | PostCSSFunction;
|
|
46
|
+
sass?: SassConfig;
|
|
47
|
+
speedy?: ToolsConfig['speedy'] | Array<NonNullable<ToolsConfig['speedy']>>;
|
|
48
|
+
/**
|
|
49
|
+
* The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
|
|
50
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
51
|
+
* @requires `tailwindcss` plugin
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
55
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var tools_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(tools_exports);
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/tools.ts"],"sourcesContent":["import type { JestConfig } from '@modern-js/core';\nimport type { AcceptedPlugin as PostCSSPlugin } from 'postcss';\nimport type { LessConfig, SassConfig } from '../config';\n\nexport type PostCSSOptions = {\n to?: string;\n from?: string;\n map?: any;\n syntax?: any;\n parser?: any;\n plugins?: PostCSSPlugin[];\n stringifier?: any;\n};\n\nexport type PostCSSLoaderOptions = {\n /**\n * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.\n */\n execute?: boolean;\n /**\n * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.\n */\n sourceMap?: boolean;\n /**\n * The special implementation option determines which implementation of PostCSS to use.\n */\n implementation?: unknown;\n /**\n * Allows to set PostCSS options and plugins.\n */\n postcssOptions?: PostCSSOptions;\n};\n\nexport type PostCSSConfigUtils = {\n addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;\n};\n\ninterface ToolsConfig {\n speedy?: any | ((config: any) => any);\n}\n\nexport type PostCSSFunction = (\n options: PostCSSLoaderOptions,\n utils: PostCSSConfigUtils,\n) => PostCSSLoaderOptions | void;\n\nexport type ToolsLegacyUserConfig = {\n babel?: any;\n less?: LessConfig;\n lodash?: any;\n postcss?: PostCSSLoaderOptions | PostCSSFunction;\n sass?: SassConfig;\n speedy?: ToolsConfig['speedy'] | Array<NonNullable<ToolsConfig['speedy']>>;\n /**\n * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n tailwindcss?:\n | Record<string, any>\n | ((options: Record<string, any>) => Record<string, any> | void);\n jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);\n};\n"]}
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ModuleContext } from '../types';
|
|
2
|
-
import type { BaseBuildConfig, PartialBuildConfig, PartialBaseBuildConfig, DTSOptions } from '../types
|
|
2
|
+
import type { BaseBuildConfig, PartialBuildConfig, PartialBaseBuildConfig, DTSOptions, ModuleLegacyUserConfig } from '../types';
|
|
3
3
|
export declare const validPartialBuildConfig: (config: PartialBuildConfig) => void;
|
|
4
4
|
export declare const validBuildTypeAndFormat: (config: PartialBaseBuildConfig) => void;
|
|
5
5
|
export declare const mergeDefaultBaseConfig: (pConfig: PartialBaseBuildConfig, context: ModuleContext) => Promise<BaseBuildConfig>;
|
|
6
|
-
export declare const getDtsConfig: (userDTS: PartialBaseBuildConfig['dts'], defaultDTS: Required<DTSOptions>) => Promise<false | Required<DTSOptions>>;
|
|
6
|
+
export declare const getDtsConfig: (userDTS: PartialBaseBuildConfig['dts'], defaultDTS: Required<DTSOptions>) => Promise<false | Required<DTSOptions>>;
|
|
7
|
+
export declare const isLegacyUserConfig: (config: {
|
|
8
|
+
legacy?: boolean;
|
|
9
|
+
}) => config is ModuleLegacyUserConfig;
|
package/dist/utils/config.js
CHANGED
|
@@ -61,6 +61,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
61
61
|
var config_exports = {};
|
|
62
62
|
__export(config_exports, {
|
|
63
63
|
getDtsConfig: () => getDtsConfig,
|
|
64
|
+
isLegacyUserConfig: () => isLegacyUserConfig,
|
|
64
65
|
mergeDefaultBaseConfig: () => mergeDefaultBaseConfig,
|
|
65
66
|
validBuildTypeAndFormat: () => validBuildTypeAndFormat,
|
|
66
67
|
validPartialBuildConfig: () => validPartialBuildConfig
|
|
@@ -158,9 +159,11 @@ const getDtsConfig = (userDTS, defaultDTS) => __async(void 0, null, function* ()
|
|
|
158
159
|
}
|
|
159
160
|
return userDTS;
|
|
160
161
|
});
|
|
162
|
+
const isLegacyUserConfig = (config) => Boolean(config.legacy);
|
|
161
163
|
// Annotate the CommonJS export names for ESM import in node:
|
|
162
164
|
0 && (module.exports = {
|
|
163
165
|
getDtsConfig,
|
|
166
|
+
isLegacyUserConfig,
|
|
164
167
|
mergeDefaultBaseConfig,
|
|
165
168
|
validBuildTypeAndFormat,
|
|
166
169
|
validPartialBuildConfig
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,0BAA0B,CAAC,WAA+B;AACrE,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAW,KAAK,QAAQ;AACtB,8BAAwB,CAAC;AAAA,IAC3B;AAAA,EACF,OAAO;AACL,4BAAwB,MAAM;AAAA,EAChC;AACF;AAEO,MAAM,0BAA0B,CAAC,WAAmC;AAnB3E;AAoBE,MACE,OAAO,cAAc,gBACrB,CAAC,QAAQ,KAAK,EAAE,UAAS,YAAO,WAAP,YAAiB,EAAE,GAC5C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,CACpC,SACA,YAC6B;AAjC/B;AAkCE,QAAM,EAAE,oBAAoB,cAAc,IAAI,MAAM,6CAClD;AAEF,QAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AACnC,QAAM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../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n} from '../types';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindCss: defaultConfig.style.tailwindCss,\n },\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.1.
|
|
14
|
+
"version": "2.1.1-beta.2",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -36,20 +36,23 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@modern-js/libuild": "~0.8.0",
|
|
40
|
-
"@modern-js/libuild-plugin-svgr": "~0.8.0",
|
|
41
|
-
"@modern-js/libuild-plugin-swc": "~0.8.0",
|
|
42
39
|
"@modern-js/core": "2.1.0",
|
|
40
|
+
"@modern-js/libuild": "~0.8.0",
|
|
43
41
|
"@modern-js/new-action": "2.1.0",
|
|
44
42
|
"@modern-js/plugin": "2.1.0",
|
|
45
43
|
"@modern-js/plugin-i18n": "2.1.0",
|
|
46
44
|
"@modern-js/upgrade": "2.1.0",
|
|
47
45
|
"@modern-js/utils": "2.1.0",
|
|
48
46
|
"@modern-js/plugin-changeset": "2.1.0",
|
|
49
|
-
"@modern-js/plugin-lint": "2.1.0"
|
|
47
|
+
"@modern-js/plugin-lint": "2.1.0",
|
|
48
|
+
"@modern-js/libuild-plugin-svgr": "~0.8.0",
|
|
49
|
+
"@modern-js/libuild-plugin-swc": "~0.8.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@modern-js/self": "npm:@modern-js/module-tools@*",
|
|
53
|
+
"@modern-js/builder-webpack-provider": "2.1.0",
|
|
54
|
+
"@scripts/build": "2.1.0",
|
|
55
|
+
"@scripts/jest-config": "2.1.0",
|
|
53
56
|
"@types/jest": "^27",
|
|
54
57
|
"@types/node": "^14",
|
|
55
58
|
"@types/fs-extra": "9.0.13",
|
|
@@ -59,10 +62,7 @@
|
|
|
59
62
|
"postcss": "8.4.6",
|
|
60
63
|
"postcss-alias": "2.0.0",
|
|
61
64
|
"react": "17",
|
|
62
|
-
"typescript": "^4"
|
|
63
|
-
"@modern-js/builder-webpack-provider": "2.1.0",
|
|
64
|
-
"@scripts/jest-config": "2.1.0",
|
|
65
|
-
"@scripts/build": "2.1.0"
|
|
65
|
+
"typescript": "^4"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/",
|