@modern-js/module-tools 2.0.0-beta.6 → 2.0.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 +90 -0
- package/dist/build.d.ts +3 -0
- package/dist/build.js +73 -0
- package/dist/build.js.map +1 -0
- package/dist/builder/build.js +1 -1
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +1 -1
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.d.ts +1 -1
- package/dist/builder/copy.js +2 -2
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.d.ts +1 -1
- package/dist/builder/index.js +1 -9
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +60 -46
- package/dist/builder/platform.js.map +1 -1
- package/dist/command.js +15 -23
- package/dist/command.js.map +1 -1
- package/dist/config/normalize.js +3 -3
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +4 -4
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/constants/build-presets.js +12 -12
- package/dist/constants/build-presets.js.map +1 -1
- package/dist/constants/build.js +2 -2
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/legacy-build-presets.js +19 -19
- package/dist/constants/legacy-build-presets.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +8 -11
- package/dist/dev.js.map +1 -1
- package/dist/hooks/build.d.ts +5 -8
- package/dist/hooks/build.js +1 -1
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.d.ts +1 -1
- package/dist/hooks/dev.js +1 -1
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.d.ts +6 -9
- package/dist/locale/en.d.ts +1 -0
- package/dist/locale/en.js +4 -1
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/zh.d.ts +1 -0
- package/dist/locale/zh.js +4 -1
- package/dist/locale/zh.js.map +1 -1
- package/dist/types/color.d.ts +1 -1
- package/dist/types/command.d.ts +2 -1
- package/dist/types/command.js.map +1 -1
- package/dist/types/config/index.d.ts +26 -21
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.d.ts +8 -8
- package/dist/types/copy.d.ts +1 -1
- package/dist/types/hooks.d.ts +5 -5
- package/dist/types/hooks.js.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/utils.d.ts +3 -3
- package/dist/utils/config.js +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/dts.js +2 -7
- package/dist/utils/dts.js.map +1 -1
- package/package.json +12 -11
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,yBAAyB,CACpC,KACA,SACA,YACA,YAIG;AACH,MAAI,CAAC,QAAQ,iBAAiB;AAC5B,UAAM,EAAE,MAAM,IAAI,MAAM,6CAAO;AAC/B,UAAM,MAAM,KAAK,EAAE,OAAO,MAAM,UAAU,WAAW,SAAS,GAAG,OAAO;AAAA,EAC1E;AACF;AAEO,MAAM,WAAW,CACtB,OACA,eACA,KACA,YACG;AAzBL;AA0BE,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,6CAAO;AACzC,QAAM,SAAS,IAAI,eAAe;AAElC,QAAM,YAAY,MAAM,IAAI,KAAK,KAAK,CAAC;AACvC,QAAM,UAAU,MACb,IAAI,UAAQ,KAAK,QAAQ,EACzB,OAAO,cAAY,OAAO,aAAa,QAAQ;AAClD,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,MAAM;AAAA,MACN,S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;AAC/B,UAAM,KAAK,OAAO,SAAS,EAAE,aAAa,QAAQ,YAAY,CAAC;AAAA,EACjE,WAAW,MAAM,SAAS,GAAG;AAC3B,UAAM,SAAS,OAAO,SAAS,KAAK,OAAO;AAAA,EAC7C;AACF;;;;;;;","names":[],"sources":["../src/dev.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { DevCommandOptions } from './types/command';\nimport type { ModuleContext } from './types/context';\nimport type { DevToolData, ModuleTools } from './types';\n\nexport const runBuildBeforeDevTools = async (\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n cliOptions: DevCommandOptions,\n options: {\n disableRunBuild: boolean;\n appDirectory: string;\n },\n) => {\n if (!options.disableRunBuild) {\n const { build } = await import('./build');\n await build(api, { watch: true, tsconfig: cliOptions.tsconfig }, context);\n }\n};\n\nexport const showMenu = async (\n metas: DevToolData[],\n devCmdOptions: DevCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk, inquirer } = await import('@modern-js/utils');\n const runner = api.useHookRunners();\n\n const menuTitle = chalk.rgb(255, 153, 0);\n const choices = metas\n .map(meta => meta.menuItem)\n .filter(menuItem => typeof menuItem === 'object');\n const questions = [\n {\n name: 'choiceDevTool',\n message: menuTitle('选择调试工具'),\n type: 'list',\n choices,\n },\n ];\n\n const newQuestions = await runner.beforeDevMenu(questions);\n const result: { choiceDevTool: string } = await inquirer.prompt(\n newQuestions.length !== 0 ? newQuestions : questions,\n );\n await runner.afterDevMenu({ result, devTools: metas });\n\n const currentDevTool = metas.find(\n meta => meta.menuItem?.value === result.choiceDevTool,\n );\n if (currentDevTool) {\n await runBuildBeforeDevTools(api, context, devCmdOptions, {\n disableRunBuild: currentDevTool.disableRunBuild ?? false,\n appDirectory: context.appDirectory,\n });\n\n await runner.beforeDevTask(currentDevTool);\n await currentDevTool.action(devCmdOptions, {\n isTsProject: context.isTsProject,\n });\n }\n};\n\nexport const dev = async (\n options: DevCommandOptions,\n metas: DevToolData[],\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { purple } = await import('./constants/colors');\n if (metas.length === 0) {\n console.info('No dev tools found available');\n // eslint-disable-next-line no-process-exit\n process.exit(0);\n }\n\n const runner = api.useHookRunners();\n if (metas.length === 1) {\n console.info(\n chalk.rgb(...purple)(\n `Only one dev tooling is currently detected as available, run it directly [${\n metas[0].menuItem?.name ?? metas[0].name\n }]`,\n ),\n );\n const meta = metas[0];\n\n await runBuildBeforeDevTools(api, context, options, {\n disableRunBuild: meta.disableRunBuild ?? false,\n appDirectory: context.appDirectory,\n });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n } else if (metas.length > 1) {\n await showMenu(metas, options, api, context);\n }\n};\n"]}
|
package/dist/hooks/build.d.ts
CHANGED
|
@@ -5,18 +5,15 @@ import type { BuildTaskResult, BuildResult, BuildPlatformResult } from '../types
|
|
|
5
5
|
export declare const buildHooks: {
|
|
6
6
|
beforeBuild: import("@modern-js/plugin").ParallelWorkflow<{
|
|
7
7
|
config: BuildConfig;
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
beforeBuildTask: import("@modern-js/plugin").
|
|
11
|
-
config: BaseBuildConfig;
|
|
12
|
-
options: BuildCommandOptions;
|
|
13
|
-
}, BaseBuildConfig>;
|
|
8
|
+
cliOptions: BuildCommandOptions;
|
|
9
|
+
}, void>;
|
|
10
|
+
beforeBuildTask: import("@modern-js/plugin").AsyncWaterfall<BaseBuildConfig>;
|
|
14
11
|
afterBuildTask: import("@modern-js/plugin").ParallelWorkflow<BuildTaskResult, void>;
|
|
15
12
|
afterBuild: import("@modern-js/plugin").ParallelWorkflow<BuildResult, void>;
|
|
16
13
|
registerBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<void, RegisterBuildPlatformResult>;
|
|
17
14
|
beforeBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<RegisterBuildPlatformResult[], void>;
|
|
18
15
|
buildPlatform: import("@modern-js/plugin").ParallelWorkflow<{
|
|
19
16
|
platform: string;
|
|
20
|
-
},
|
|
21
|
-
afterBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<
|
|
17
|
+
}, void>;
|
|
18
|
+
afterBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<BuildPlatformResult, void>;
|
|
22
19
|
};
|
package/dist/hooks/build.js
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = __toCommonJS(build_exports);
|
|
|
23
23
|
var import_plugin = require("@modern-js/plugin");
|
|
24
24
|
const buildHooks = {
|
|
25
25
|
beforeBuild: (0, import_plugin.createParallelWorkflow)(),
|
|
26
|
-
beforeBuildTask: (0, import_plugin.
|
|
26
|
+
beforeBuildTask: (0, import_plugin.createAsyncWaterfall)(),
|
|
27
27
|
afterBuildTask: (0, import_plugin.createParallelWorkflow)(),
|
|
28
28
|
afterBuild: (0, import_plugin.createParallelWorkflow)(),
|
|
29
29
|
registerBuildPlatform: (0, import_plugin.createParallelWorkflow)(),
|
package/dist/hooks/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAUA,MAAM,aAAa;AAAA,EACxB,iBAAa,sCAGX;AAAA,EACF,qBAAiB,oCAAsC;AAAA,EACvD,oBAAgB,sCAA8C;AAAA,EAC9D,gBAAY,sCAA0C;AAAA,EACtD,2BAAuB,sCAGrB;AAAA,EACF,yBAAqB,sCAGnB;AAAA,EACF,mBAAe,sCAAmD;AAAA,EAClE,wBAAoB,sCAAkD;AACxE;;;;;","names":[],"sources":["../../src/hooks/build.ts"],"sourcesContent":["import {\n createParallelWorkflow,\n createAsyncWaterfall,\n} from '@modern-js/plugin';\nimport type { RegisterBuildPlatformResult } from '@modern-js/core';\nimport { BuildCommandOptions } from '../types';\nimport type { BuildConfig, BaseBuildConfig } from '../types/config';\nimport type {\n BuildTaskResult,\n BuildResult,\n BuildPlatformResult,\n} from '../types/hooks';\n\nexport const buildHooks = {\n beforeBuild: createParallelWorkflow<\n { config: BuildConfig; cliOptions: BuildCommandOptions },\n void\n >(),\n beforeBuildTask: createAsyncWaterfall<BaseBuildConfig>(),\n afterBuildTask: createParallelWorkflow<BuildTaskResult, void>(),\n afterBuild: createParallelWorkflow<BuildResult, void>(),\n registerBuildPlatform: createParallelWorkflow<\n void,\n RegisterBuildPlatformResult\n >(),\n beforeBuildPlatform: createParallelWorkflow<\n RegisterBuildPlatformResult[],\n void\n >(),\n buildPlatform: createParallelWorkflow<{ platform: string }, void>(),\n afterBuildPlatform: createParallelWorkflow<BuildPlatformResult, void>(),\n};\n"]}
|
package/dist/hooks/dev.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DevToolData, PromptResult } from '../types/hooks';
|
|
|
2
2
|
export declare const devHooks: {
|
|
3
3
|
registerDev: import("@modern-js/plugin").ParallelWorkflow<void, DevToolData>;
|
|
4
4
|
beforeDev: import("@modern-js/plugin").ParallelWorkflow<DevToolData[], void>;
|
|
5
|
-
beforeDevMenu: import("@modern-js/plugin").
|
|
5
|
+
beforeDevMenu: import("@modern-js/plugin").AsyncWaterfall<any>;
|
|
6
6
|
afterDevMenu: import("@modern-js/plugin").ParallelWorkflow<{
|
|
7
7
|
result: PromptResult;
|
|
8
8
|
devTools: DevToolData[];
|
package/dist/hooks/dev.js
CHANGED
|
@@ -24,7 +24,7 @@ var import_plugin = require("@modern-js/plugin");
|
|
|
24
24
|
const devHooks = {
|
|
25
25
|
registerDev: (0, import_plugin.createParallelWorkflow)(),
|
|
26
26
|
beforeDev: (0, import_plugin.createParallelWorkflow)(),
|
|
27
|
-
beforeDevMenu: (0, import_plugin.
|
|
27
|
+
beforeDevMenu: (0, import_plugin.createAsyncWaterfall)(),
|
|
28
28
|
afterDevMenu: (0, import_plugin.createParallelWorkflow)(),
|
|
29
29
|
beforeDevTask: (0, import_plugin.createParallelWorkflow)(),
|
|
30
30
|
afterDev: (0, import_plugin.createParallelWorkflow)()
|
package/dist/hooks/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAIA,MAAM,WAAW;AAAA,EACtB,iBAAa,sCAA0C;AAAA,EACvD,eAAW,sCAA4C;AAAA,EACvD,mBAAe,oCAAyC;AAAA,EACxD,kBAAc,sCAGZ;AAAA,EACF,mBAAe,sCAA0C;AAAA,EACzD,cAAU,sCAAmC;AAC/C;;;;;","names":[],"sources":["../../src/hooks/dev.ts"],"sourcesContent":["import {\n createParallelWorkflow,\n createAsyncWaterfall,\n} from '@modern-js/plugin';\nimport type { QuestionCollection } from '@modern-js/utils/compiled/inquirer';\nimport type { DevToolData, PromptResult } from '../types/hooks';\n\nexport const devHooks = {\n registerDev: createParallelWorkflow<void, DevToolData>(),\n beforeDev: createParallelWorkflow<DevToolData[], void>(),\n beforeDevMenu: createAsyncWaterfall<QuestionCollection>(),\n afterDevMenu: createParallelWorkflow<\n { result: PromptResult; devTools: DevToolData[] },\n void\n >(),\n beforeDevTask: createParallelWorkflow<DevToolData, void>(),\n afterDev: createParallelWorkflow<void, void>(),\n};\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const registerHook: {
|
|
|
3
3
|
modifyLibuild: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/libuild").CLIConfig, import("@modern-js/libuild").CLIConfig>;
|
|
4
4
|
registerDev: import("@modern-js/plugin").ParallelWorkflow<void, import("..").DevToolData>;
|
|
5
5
|
beforeDev: import("@modern-js/plugin").ParallelWorkflow<import("..").DevToolData[], void>;
|
|
6
|
-
beforeDevMenu: import("@modern-js/plugin").
|
|
6
|
+
beforeDevMenu: import("@modern-js/plugin").AsyncWaterfall<any>;
|
|
7
7
|
afterDevMenu: import("@modern-js/plugin").ParallelWorkflow<{
|
|
8
8
|
result: import("..").PromptResult;
|
|
9
9
|
devTools: import("..").DevToolData[];
|
|
@@ -12,18 +12,15 @@ export declare const registerHook: {
|
|
|
12
12
|
afterDev: import("@modern-js/plugin").ParallelWorkflow<void, void>;
|
|
13
13
|
beforeBuild: import("@modern-js/plugin").ParallelWorkflow<{
|
|
14
14
|
config: import("..").BuildConfig;
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
beforeBuildTask: import("@modern-js/plugin").
|
|
18
|
-
config: import("..").BaseBuildConfig;
|
|
19
|
-
options: import("..").BuildCommandOptions;
|
|
20
|
-
}, import("..").BaseBuildConfig>;
|
|
15
|
+
cliOptions: import("..").BuildCommandOptions;
|
|
16
|
+
}, void>;
|
|
17
|
+
beforeBuildTask: import("@modern-js/plugin").AsyncWaterfall<import("..").BaseBuildConfig>;
|
|
21
18
|
afterBuildTask: import("@modern-js/plugin").ParallelWorkflow<import("..").BuildTaskResult, void>;
|
|
22
19
|
afterBuild: import("@modern-js/plugin").ParallelWorkflow<import("..").BuildResult, void>;
|
|
23
20
|
registerBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<void, import("@modern-js/core").RegisterBuildPlatformResult>;
|
|
24
21
|
beforeBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<import("@modern-js/core").RegisterBuildPlatformResult[], void>;
|
|
25
22
|
buildPlatform: import("@modern-js/plugin").ParallelWorkflow<{
|
|
26
23
|
platform: string;
|
|
27
|
-
},
|
|
28
|
-
afterBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<
|
|
24
|
+
}, void>;
|
|
25
|
+
afterBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<import("..").BuildPlatformResult, void>;
|
|
29
26
|
};
|
package/dist/locale/en.d.ts
CHANGED
package/dist/locale/en.js
CHANGED
|
@@ -33,7 +33,10 @@ const EN_LOCALE = {
|
|
|
33
33
|
no_clear: "disable auto clear dist dir",
|
|
34
34
|
config: "specify config file"
|
|
35
35
|
},
|
|
36
|
-
dev: {
|
|
36
|
+
dev: {
|
|
37
|
+
describe: "start dev server",
|
|
38
|
+
tsconfig: "Specify a path to the tsconfig.json file"
|
|
39
|
+
},
|
|
37
40
|
new: {
|
|
38
41
|
describe: "generator runner for modern project",
|
|
39
42
|
debug: "using debug mode to log something",
|
package/dist/locale/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,UACE;AAAA,MACF,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,KAAK,
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,UACE;AAAA,MACF,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,IACZ;AAAA,EACF;AACF;","names":[],"sources":["../../src/locale/en.ts"],"sourcesContent":["export const EN_LOCALE = {\n command: {\n build: {\n describe: 'command for building module',\n watch: 'building module in watch mode',\n tsconfig: 'Specify a path to the tsconfig.json file',\n style_only: 'only build style',\n platform:\n 'build the specified task or all tasks, If exist. (tasks: \"storybook\", \"docs\")',\n no_tsc: 'close tsc compiler to emit d.ts (Deprecated)',\n dts: 'Turn on dts generation and type checking',\n no_clear: 'disable auto clear dist dir',\n config: 'specify config file',\n },\n dev: {\n describe: 'start dev server',\n tsconfig: 'Specify a path to the tsconfig.json file',\n },\n new: {\n describe: 'generator runner for modern project',\n debug: 'using debug mode to log something',\n config: 'set default generator config(json string)',\n distTag: `use specified tag version for it's generator`,\n registry: 'set npm registry url to run npm command',\n },\n },\n};\n"]}
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare const localeKeys: {
|
|
|
14
14
|
};
|
|
15
15
|
dev: {
|
|
16
16
|
describe: string;
|
|
17
|
+
tsconfig: string;
|
|
17
18
|
};
|
|
18
19
|
new: {
|
|
19
20
|
describe: string;
|
|
@@ -38,6 +39,7 @@ declare const localeKeys: {
|
|
|
38
39
|
};
|
|
39
40
|
dev: {
|
|
40
41
|
describe: string;
|
|
42
|
+
tsconfig: string;
|
|
41
43
|
};
|
|
42
44
|
new: {
|
|
43
45
|
describe: string;
|
package/dist/locale/zh.d.ts
CHANGED
package/dist/locale/zh.js
CHANGED
|
@@ -33,7 +33,10 @@ const ZH_LOCALE = {
|
|
|
33
33
|
no_clear: "不清理产物目录",
|
|
34
34
|
config: "指定配置文件路径,可以为相对路径或绝对路径"
|
|
35
35
|
},
|
|
36
|
-
dev: {
|
|
36
|
+
dev: {
|
|
37
|
+
describe: "本地开发命令",
|
|
38
|
+
tsconfig: "指定 tsconfig.json 文件的路径"
|
|
39
|
+
},
|
|
37
40
|
new: {
|
|
38
41
|
describe: "模块化工程方案中执行生成器",
|
|
39
42
|
debug: "开启 Debug 模式,打印调试日志信息",
|
package/dist/locale/zh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,UACE;AAAA,MACF,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,KAAK,
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,UACE;AAAA,MACF,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,IACZ;AAAA,EACF;AACF;","names":[],"sources":["../../src/locale/zh.ts"],"sourcesContent":["export const ZH_LOCALE = {\n command: {\n build: {\n describe: '构建模块命令',\n watch: '使用 Watch 模式构建模块',\n tsconfig: '指定 tsconfig.json 文件的路径',\n style_only: '只构建样式文件',\n platform:\n '如果存在的话,执行指定的构建任务或者全部构建任务. (构建任务包括: \"storybook\", \"文档\")',\n no_tsc: '关闭 tsc 编译(废弃)',\n dts: '开启 dts 文件的生成以及类型检查',\n no_clear: '不清理产物目录',\n config: '指定配置文件路径,可以为相对路径或绝对路径',\n },\n dev: {\n describe: '本地开发命令',\n tsconfig: '指定 tsconfig.json 文件的路径',\n },\n new: {\n describe: '模块化工程方案中执行生成器',\n debug: '开启 Debug 模式,打印调试日志信息',\n config: '生成器运行默认配置(JSON 字符串)',\n distTag: '生成器使用特殊的 npm Tag 版本',\n registry: '生成器运行过程中定制 npm Registry',\n },\n },\n};\n"]}
|
package/dist/types/color.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type RGB = [number, number, number];
|
package/dist/types/command.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["export interface DevCommandOptions {\n port?: string;\n}\n\nexport interface BuildCommandOptions {\n config
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["export interface DevCommandOptions {\n port?: string;\n tsconfig: string;\n}\n\nexport interface BuildCommandOptions {\n config?: string;\n clear?: boolean;\n dts?: boolean;\n platform?: boolean | string[];\n tsconfig: string;\n watch?: boolean;\n}\n"]}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import type { UserConfig as LibuildUserConfig, Asset as LibuildAsset, Style as LibuildStyle } from '@modern-js/libuild';
|
|
2
2
|
import type { Options } from '@modern-js/libuild-plugin-svgr';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';
|
|
4
4
|
import { BuildInPreset, presetList } from '../../constants/build-presets';
|
|
5
5
|
import type { CopyConfig } from '../copy';
|
|
6
6
|
import type { LessConfig, SassConfig, PostCSSConfig, TailwindCSSConfig } from './style';
|
|
7
7
|
export * from './style';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
8
|
+
export type BuildType = 'bundleless' | 'bundle';
|
|
9
|
+
export type Format = 'esm' | 'cjs' | 'umd' | 'iife';
|
|
10
|
+
export type Target = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
|
|
11
|
+
export type Input = Required<LibuildUserConfig>['input'];
|
|
12
|
+
export type DTSOptions = {
|
|
13
13
|
distPath: string;
|
|
14
14
|
tsconfigPath: string;
|
|
15
15
|
only: boolean;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type DTS = false | Partial<DTSOptions>;
|
|
18
18
|
export interface Asset {
|
|
19
19
|
path?: LibuildAsset['outdir'];
|
|
20
20
|
limit?: LibuildAsset['limit'];
|
|
21
21
|
publicPath?: LibuildAsset['publicPath'];
|
|
22
22
|
svgr?: boolean | Options;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
25
|
-
export
|
|
24
|
+
export type SourceMap = Required<LibuildUserConfig>['sourceMap'];
|
|
25
|
+
export type AutoExternal = boolean | {
|
|
26
26
|
dependencies?: boolean;
|
|
27
27
|
peerDependencies?: boolean;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
29
|
+
export type JSX = 'automatic' | 'transform';
|
|
30
|
+
export type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, string> | void);
|
|
31
|
+
export type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias'> & {
|
|
32
32
|
dts: false | DTSOptions;
|
|
33
33
|
style: Omit<Required<LibuildStyle>, 'cleanCss'> & {
|
|
34
34
|
tailwindCss: TailwindCSSConfig;
|
|
35
35
|
};
|
|
36
36
|
alias: Record<string, string>;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type PartialBaseBuildConfig = {
|
|
39
39
|
buildType?: 'bundleless' | 'bundle';
|
|
40
40
|
format?: Format;
|
|
41
41
|
target?: Target;
|
|
@@ -45,7 +45,7 @@ export declare type PartialBaseBuildConfig = {
|
|
|
45
45
|
copy?: CopyConfig;
|
|
46
46
|
asset?: Asset;
|
|
47
47
|
jsx?: JSX;
|
|
48
|
-
|
|
48
|
+
outDir?: string;
|
|
49
49
|
alias?: AliasOption;
|
|
50
50
|
input?: Input;
|
|
51
51
|
platform?: LibuildUserConfig['platform'];
|
|
@@ -58,9 +58,9 @@ export declare type PartialBaseBuildConfig = {
|
|
|
58
58
|
define?: LibuildUserConfig['define'];
|
|
59
59
|
style?: StyleConfig;
|
|
60
60
|
};
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
61
|
+
export type BuildConfig = BaseBuildConfig | BaseBuildConfig[];
|
|
62
|
+
export type PartialBuildConfig = PartialBaseBuildConfig | PartialBaseBuildConfig[];
|
|
63
|
+
export type BuildPreset = keyof typeof presetList | ((options: {
|
|
64
64
|
preset: typeof BuildInPreset;
|
|
65
65
|
}) => PartialBuildConfig | Promise<PartialBuildConfig>);
|
|
66
66
|
export interface StyleConfig {
|
|
@@ -78,15 +78,20 @@ export interface StyleConfig {
|
|
|
78
78
|
|
|
79
79
|
tailwindcss?: TailwindCSSConfig;
|
|
80
80
|
}
|
|
81
|
-
export interface
|
|
82
|
-
|
|
81
|
+
export interface StorybookBuildConfig {
|
|
82
|
+
webpack?: WebpackBuilderToolsConfig['webpack'];
|
|
83
|
+
webpackChain?: WebpackBuilderToolsConfig['webpackChain'];
|
|
83
84
|
}
|
|
84
85
|
export interface Dev {
|
|
85
|
-
storybook
|
|
86
|
+
storybook?: StorybookBuildConfig;
|
|
87
|
+
}
|
|
88
|
+
export interface RuntimeUserConfig {
|
|
89
|
+
[name: string]: any;
|
|
86
90
|
}
|
|
87
91
|
export interface ModuleExtraConfig {
|
|
88
92
|
designSystem?: Record<string, any>;
|
|
89
93
|
buildConfig?: PartialBuildConfig;
|
|
90
94
|
buildPreset?: BuildPreset;
|
|
91
|
-
dev?:
|
|
95
|
+
dev?: Dev;
|
|
96
|
+
runtime?: RuntimeUserConfig;
|
|
92
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type {
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';\nimport { BuildInPreset, presetList } from '../../constants/build-presets';\nimport type { CopyConfig } from '../copy';\nimport type {\n LessConfig,\n SassConfig,\n PostCSSConfig,\n TailwindCSSConfig,\n} from './style';\n\nexport * from './style';\n\nexport type BuildType = 'bundleless' | 'bundle';\n\nexport type Format = 'esm' | 'cjs' | 'umd' | 'iife';\n\nexport type Target =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n | 'es2021'\n | 'es2022'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\n\nexport type Input = Required<LibuildUserConfig>['input'];\n\nexport type DTSOptions = {\n distPath: string;\n tsconfigPath: string;\n only: boolean;\n};\nexport type DTS = false | Partial<DTSOptions>;\n\nexport interface Asset {\n path?: LibuildAsset['outdir'];\n limit?: LibuildAsset['limit'];\n publicPath?: LibuildAsset['publicPath'];\n svgr?: boolean | Options;\n}\nexport type SourceMap = Required<LibuildUserConfig>['sourceMap'];\nexport type AutoExternal =\n | boolean\n | {\n dependencies?: boolean;\n peerDependencies?: boolean;\n };\nexport type JSX = 'automatic' | 'transform';\n\nexport type AliasOption =\n | Record<string, string>\n | ((aliases: Record<string, string>) => Record<string, string> | void);\n\nexport type BaseBuildConfig = Omit<\n Required<PartialBaseBuildConfig>,\n 'dts' | 'style' | 'alias'\n> & {\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\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?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Style } from '@modern-js/libuild';
|
|
2
2
|
import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
3
|
+
export type LessOptions = Required<Style>['less'];
|
|
4
|
+
export type SassOptions = Required<Style>['sass'];
|
|
5
|
+
export type PostcssOptions = Required<Style>['postcss'];
|
|
6
|
+
export type LessConfig = LessOptions | ((options: LessOptions) => LessOptions | void);
|
|
7
|
+
export type SassConfig = SassOptions | ((options: SassOptions) => SassOptions | void);
|
|
8
|
+
export type PostCSSConfigUtils = {
|
|
9
9
|
addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type PostCSSConfig = PostcssOptions | ((options: PostcssOptions, utils: PostCSSConfigUtils) => PostcssOptions | void);
|
|
12
|
+
export type TailwindCSSConfig = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
package/dist/types/copy.d.ts
CHANGED
package/dist/types/hooks.d.ts
CHANGED
|
@@ -16,10 +16,10 @@ export interface BuildResult {
|
|
|
16
16
|
}
|
|
17
17
|
export interface BuildPlatformResult {
|
|
18
18
|
status: 'success' | 'fail';
|
|
19
|
-
message: string;
|
|
19
|
+
message: string | Error | null;
|
|
20
20
|
}
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
choiceDevTool: string
|
|
21
|
+
export type DevToolData = BaseDevToolData<DevCommandOptions>;
|
|
22
|
+
export type PromptResult = {
|
|
23
|
+
choiceDevTool: string;
|
|
24
24
|
} & Record<string, any>;
|
|
25
|
-
export
|
|
25
|
+
export type ModuleToolsHooks = typeof registerHook;
|
package/dist/types/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/hooks.ts"],"sourcesContent":["import { DevToolData as BaseDevToolData } from '@modern-js/core';\nimport { registerHook } from '../hooks';\nimport type { BaseBuildConfig, BuildConfig } from './config';\nimport type { DevCommandOptions, BuildCommandOptions } from './command';\n\nexport interface BuildTaskResult {\n status: 'success' | 'fail';\n message?: string;\n config: BaseBuildConfig;\n}\n\nexport interface BuildResult {\n status: 'success' | 'fail';\n message?: string;\n config: BuildConfig;\n commandOptions: BuildCommandOptions;\n totalDuration: number;\n}\nexport interface BuildPlatformResult {\n status: 'success' | 'fail';\n message: string;\n}\n\nexport type DevToolData = BaseDevToolData<DevCommandOptions>;\n\nexport type PromptResult = { choiceDevTool: string
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/hooks.ts"],"sourcesContent":["import { DevToolData as BaseDevToolData } from '@modern-js/core';\nimport { registerHook } from '../hooks';\nimport type { BaseBuildConfig, BuildConfig } from './config';\nimport type { DevCommandOptions, BuildCommandOptions } from './command';\n\nexport interface BuildTaskResult {\n status: 'success' | 'fail';\n message?: string;\n config: BaseBuildConfig;\n}\n\nexport interface BuildResult {\n status: 'success' | 'fail';\n message?: string;\n config: BuildConfig;\n commandOptions: BuildCommandOptions;\n totalDuration: number;\n}\nexport interface BuildPlatformResult {\n status: 'success' | 'fail';\n message: string | Error | null;\n}\n\nexport type DevToolData = BaseDevToolData<DevCommandOptions>;\n\nexport type PromptResult = { choiceDevTool: string } & Record<string, any>;\n\nexport type ModuleToolsHooks = typeof registerHook;\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ export * from './config';
|
|
|
7
7
|
export * from './dts';
|
|
8
8
|
export * from './context';
|
|
9
9
|
export type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';
|
|
10
|
-
export
|
|
10
|
+
export type ModuleTools = {
|
|
11
11
|
hooks: ModuleToolsHooks;
|
|
12
12
|
userConfig: ModuleExtraConfig;
|
|
13
13
|
normalizedConfig: Required<ModuleExtraConfig>;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
export type ModuleUserConfig = UserConfig<ModuleTools>;
|
|
16
|
+
export type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;
|
|
17
|
+
export type ModuleConfigParams = ModuleUserConfig | Promise<ModuleUserConfig> | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? DeepPartialArray<U> : T extends object ? DeepPartialObject<T> : T | undefined;
|
|
2
2
|
/** @private */
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type DeepPartialArray<T> = Array<DeepPartial<T>>;
|
|
5
5
|
/** @private */
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
|
package/dist/utils/config.js
CHANGED
|
@@ -124,7 +124,7 @@ const mergeDefaultBaseConfig = (pConfig, context) => __async(void 0, null, funct
|
|
|
124
124
|
target: (_e = pConfig.target) != null ? _e : defaultConfig.target,
|
|
125
125
|
sourceMap: (_f = pConfig.sourceMap) != null ? _f : defaultConfig.sourceMap,
|
|
126
126
|
copy: (_g = pConfig.copy) != null ? _g : cloneDeep(defaultConfig.copy),
|
|
127
|
-
|
|
127
|
+
outDir: (_h = pConfig.outDir) != null ? _h : defaultConfig.outDir,
|
|
128
128
|
dts: yield getDtsConfig(pConfig.dts, defaultConfig.dts),
|
|
129
129
|
jsx: (_i = pConfig.jsx) != null ? _i : defaultConfig.jsx,
|
|
130
130
|
input: (_j = pConfig.input) != null ? _j : cloneDeep(input),
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,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;AAlB3E;AAmBE,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;AAhC/B;AAiCE,QAAM,EAAE,oBAAoB,cAAc,IAAI,MAAM,6CAClD;AAEF,QAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AACnC,QAAM,EAAE,mBAAmB,oBAAoB,MAAM,IAAI,MAAM,6CAC7D;AAEF,QAAM,EAAE,qBAAqB,IAAI,MAAM,6CAAO;AAC9C,QAAM,EAAE,eAAe,IAAI,MAAM,6CAAO;AACxC,QAAM,eAAe;AAAA,IACnB,KAAK,QAAQ;AAAA,EACf;AACA,QAAM,cAAc,kBAAkB,cAAc,QAAQ,KAAK;AAOjE,QAAM,QAAQ,OAAO,KAAK,WAAW,EAAE;AAAA,IACrC,CAAC,MAAM,SAAS;AACd,YAAM,iBAAiB,CAACA,WAAkB;AACxC,YAAI,OAAOA,WAAU,YAAYA,OAAM,WAAW,GAAG,GAAG;AACtD,i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c;AAAA,IACpD,YAAY,kCACP,cAAc,aACd,QAAQ;AAAA,IAEb,gBAAe,aAAQ,kBAAR,YAAyB,cAAc;AAAA,IACtD,YAAW,aAAQ,cAAR,YAAqB,cAAc;AAAA,IAC9C;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,iCACF,cADE;AAAA,MAEL,SAAQ,mBAAQ,UAAR,mBAAe,WAAf,YAAyB,cAAc,MAAM;AAAA,MACrD,UAAS,mBAAQ,UAAR,mBAAe,YAAf,YAA0B,cAAc,MAAM;AAAA,MACvD,cACE,mBAAQ,UAAR,mBAAe,gBAAf,YAA8B,cAAc,MAAM;AAAA,MACpD,aAAa,cAAc,MAAM;AAAA,IACnC;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAC1B,SACA,eACG;AACH,QAAM,EAAE,WAAW,aAAa,SAAS,IAAI,MAAM,6CACjD;AAGF,MAAI,YAAY,OAAO,GAAG;AACxB,WAAO,UAAU,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS,OAAO,GAAG;AACrB,WAAO,kCACF,aACA;AAAA,EAEP;AAEA,SAAO;AACT;;;;;;;;","names":["value"],"sources":["../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n} from '../types/config';\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 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
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,0BAA0B,CAAC,WAA+B;AACrE,MAAI,MAAM,QAAQ,MAAM,GAAG;AAC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,gBAAf,YAA8B,cAAc,MAAM;AAAA,MACpD,aAAa,cAAc,MAAM;AAAA,IACnC;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAC1B,SACA,eACG;AACH,QAAM,EAAE,WAAW,aAAa,SAAS,IAAI,MAAM,6CACjD;AAGF,MAAI,YAAY,OAAO,GAAG;AACxB,WAAO,UAAU,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS,OAAO,GAAG;AACrB,WAAO,kCACF,aACA;AAAA,EAEP;AAEA,SAAO;AACT;;;;;;;;","names":["value"],"sources":["../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n} from '../types/config';\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 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 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"]}
|
package/dist/utils/dts.js
CHANGED
|
@@ -71,12 +71,7 @@ const generatorTsConfig = (projectTsconfig, config) => __async(void 0, null, fun
|
|
|
71
71
|
var _a, _b, _c;
|
|
72
72
|
const { fs, lodash, nanoid } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
73
73
|
const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
74
|
-
const {
|
|
75
|
-
appDirectory,
|
|
76
|
-
sourceDir: absSourceDir,
|
|
77
|
-
distAbsPath,
|
|
78
|
-
tsconfigPath
|
|
79
|
-
} = config;
|
|
74
|
+
const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
|
|
80
75
|
const tempDistAbsRootPath = import_path.default.join(
|
|
81
76
|
appDirectory,
|
|
82
77
|
`${dtsTempDirectory}/${nanoid()}`
|
|
@@ -101,7 +96,7 @@ const generatorTsConfig = (projectTsconfig, config) => __async(void 0, null, fun
|
|
|
101
96
|
};
|
|
102
97
|
if (projectTsconfig.extends) {
|
|
103
98
|
resetConfig.extends = projectTsconfig.extends.startsWith(".") ? import_path.default.join(
|
|
104
|
-
import_path.default.relative(`${
|
|
99
|
+
import_path.default.relative(`${tempDistAbsRootPath}`, import_path.default.dirname(tsconfigPath)),
|
|
105
100
|
projectTsconfig.extends
|
|
106
101
|
) : projectTsconfig.extends;
|
|
107
102
|
}
|
package/dist/utils/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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M,6CAAO;AACpC,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,QAAM,EAAE,YAAY,IAAI;AACxB,QAAM,cAAc,GAAG;AACvB,QAAM,eACJ,eAAe,SAAS,IACpB,iBACA,OAAO,KAAK,aAAa,EAAE,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,kBAAkB;AAAA,IAC/B,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAO,wBAAa,oBAAb,mBAA8B,UAA9B,YAAuC,CAAC;AAAA,EACjD,CAAC;AACD,aAAW,KAAK,QAAQ;AACtB,OAAG,cAAc,EAAE,MAAM,EAAE,OAAO;AAAA,EACpC;AAEA,QAAM,GAAG,KAAK,oBAAoB,WAAW;AAC/C;AAgDO,MAAM,qBAAqB,CAChC,QACA,YACG;AA9LL;AA+LE,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAG7C,MACE,OAAO,QAAQ,aAAa,YAC5B,QAAQ,aAAa,qBACrB;AACA,WAAO,MAAM;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,QACN,YAAO,QAAP,YAAc,CAAC,IAHR;AAAA,MAIX,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n projectTsconfig: ITsconfig,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, lodash, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsSrcPath = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const rootDir = path.relative(tempDistAbsRootPath, appDirectory);\n const baseUrl = projectTsconfig.compilerOptions?.baseUrl\n ? path.join(appDirectory, projectTsconfig.compilerOptions?.baseUrl)\n : appDirectory;\n // if include = ['src'], final include should be ['../src']\n const include = [path.relative(tempDistAbsRootPath, absSourceDir)];\n\n const resetConfig: ITsconfig = {\n compilerOptions: {\n ...projectTsconfig?.compilerOptions,\n rootDir,\n baseUrl,\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsRootPath,\n },\n include,\n exclude: projectTsconfig.exclude ?? [],\n };\n\n // extends: '../tsconfig.json'\n if (projectTsconfig.extends) {\n resetConfig.extends = projectTsconfig.extends.startsWith('.')\n ? path.join(\n path.relative(`${tempDistAbsRootPath}`, path.dirname(tsconfigPath)),\n projectTsconfig.extends,\n )\n : projectTsconfig.extends;\n }\n\n const recommendOption = {\n // Ensure that Babel can safely transpile files in the TypeScript project\n compilerOptions: {\n isolatedModules: true,\n },\n };\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const deepMerge = lodash.merge;\n fs.writeJSONSync(\n tempTsconfigPath,\n deepMerge(\n recommendOption,\n projectTsconfig,\n // 此处是必须要覆盖用户默认配置\n resetConfig,\n ),\n );\n\n return { tempTsconfigPath, tempDistAbsRootPath, tempDistAbsSrcPath };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspaths-transform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
|