@modern-js/module-tools 2.5.2-beta.4 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +106 -3
- package/compiled/rollup-plugin-dts/package.json +1 -1
- package/dist/build.js +6 -0
- package/dist/build.js.map +1 -0
- package/dist/builder/build.js +7 -0
- package/dist/builder/build.js.map +1 -0
- package/dist/builder/clear.js +6 -0
- package/dist/builder/clear.js.map +1 -0
- package/dist/builder/copy.js +20 -11
- package/dist/builder/copy.js.map +1 -0
- package/dist/builder/dts/index.js +2 -0
- package/dist/builder/dts/index.js.map +1 -0
- package/dist/builder/dts/rollup.js +19 -1
- package/dist/builder/dts/rollup.js.map +1 -0
- package/dist/builder/dts/tsc.js +8 -0
- package/dist/builder/dts/tsc.js.map +1 -0
- package/dist/builder/index.js +6 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/platform.js +6 -0
- package/dist/builder/platform.js.map +1 -0
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.js +6 -0
- package/dist/command.js.map +1 -0
- package/dist/config/defineConfig.js +2 -0
- package/dist/config/defineConfig.js.map +1 -0
- package/dist/config/legacy-schema.js +9 -0
- package/dist/config/legacy-schema.js.map +1 -0
- package/dist/config/normalize.js +6 -0
- package/dist/config/normalize.js.map +1 -0
- package/dist/config/schema.js +4 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/transform-legacy-config.js +6 -0
- package/dist/config/transform-legacy-config.js.map +1 -0
- package/dist/constants/build-presets.js +2 -0
- package/dist/constants/build-presets.js.map +1 -0
- package/dist/constants/build.js +2 -0
- package/dist/constants/build.js.map +1 -0
- package/dist/constants/colors.js +2 -0
- package/dist/constants/colors.js.map +1 -0
- package/dist/constants/dts.js +4 -0
- package/dist/constants/dts.js.map +1 -0
- package/dist/constants/file.js +2 -0
- package/dist/constants/file.js.map +1 -0
- package/dist/constants/legacy-build-presets.js +6 -0
- package/dist/constants/legacy-build-presets.js.map +1 -0
- package/dist/constants/log.js +2 -0
- package/dist/constants/log.js.map +1 -0
- package/dist/dev.js +6 -0
- package/dist/dev.js.map +1 -0
- package/dist/error.js +2 -0
- package/dist/error.js.map +1 -0
- package/dist/hooks/build.js +2 -0
- package/dist/hooks/build.js.map +1 -0
- package/dist/hooks/dev.js +3 -0
- package/dist/hooks/dev.js.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/misc.js +2 -0
- package/dist/hooks/misc.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/en.js +2 -0
- package/dist/locale/en.js.map +1 -0
- package/dist/locale/index.js +2 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/locale/zh.js +2 -0
- package/dist/locale/zh.js.map +1 -0
- package/dist/plugins.js +6 -0
- package/dist/plugins.js.map +1 -0
- package/dist/types/color.js +2 -0
- package/dist/types/color.js.map +1 -0
- package/dist/types/command.js +2 -0
- package/dist/types/command.js.map +1 -0
- package/dist/types/config/index.js +2 -0
- package/dist/types/config/index.js.map +1 -0
- package/dist/types/config/style.js +2 -0
- package/dist/types/config/style.js.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/copy.js +2 -0
- package/dist/types/copy.js.map +1 -0
- package/dist/types/dts.js +2 -0
- package/dist/types/dts.js.map +1 -0
- package/dist/types/hooks.js +2 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/legacyConfig/index.js +2 -0
- package/dist/types/legacyConfig/index.js.map +1 -0
- package/dist/types/legacyConfig/output.js +2 -0
- package/dist/types/legacyConfig/output.js.map +1 -0
- package/dist/types/legacyConfig/source.js +2 -0
- package/dist/types/legacyConfig/source.js.map +1 -0
- package/dist/types/legacyConfig/tools.js +2 -0
- package/dist/types/legacyConfig/tools.js.map +1 -0
- package/dist/types/utils.js +2 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/utils/builder.js +6 -0
- package/dist/utils/builder.js.map +1 -0
- package/dist/utils/config.js +6 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/context.js +6 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/dts.js +7 -0
- package/dist/utils/dts.js.map +1 -0
- package/dist/utils/input.js +6 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/language.js +6 -0
- package/dist/utils/language.js.map +1 -0
- package/dist/utils/libuild-plugins.js +6 -0
- package/dist/utils/libuild-plugins.js.map +1 -0
- package/dist/utils/log.js +6 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/onExit.js +6 -0
- package/dist/utils/onExit.js.map +1 -0
- package/dist/utils/path.js +6 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/print.js +7 -0
- package/dist/utils/print.js.map +1 -0
- package/dist/utils/style.js +8 -0
- package/dist/utils/style.js.map +1 -0
- package/dist/utils/tspaths-transform.js +9 -0
- package/dist/utils/tspaths-transform.js.map +1 -0
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c1918f5: feat(module-tools): add new Buildpreset and `extendPreset` function
|
|
8
|
+
feat(module-tools): 新增新的 buildPreset 以及 extendPreset 函数
|
|
9
|
+
- 9d1905a: feat: support to handle files add and unlink in watch mode
|
|
10
|
+
feat: 支持在 watch 模式下处理文件的新增和删除
|
|
11
|
+
- 44e7b10: feat: add noDevTools hook. fix dev log content and add add chinese and english content
|
|
12
|
+
feat: 增加 noDevTools hook. 修复 dev 的日志内容, 增加中英内容
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 5f66bc5: fix(module-tools): fix copy context error path
|
|
17
|
+
fix(module-tools): 修复 copy context 错误路径的问题
|
|
18
|
+
- f0e41e7: fix: set composite false in bundle dts
|
|
19
|
+
fix: 打包 d.ts 时设置 composite 为 false
|
|
20
|
+
- Updated dependencies [e1f799e]
|
|
21
|
+
- Updated dependencies [7915ab3]
|
|
22
|
+
- Updated dependencies [0fe658a]
|
|
23
|
+
- @modern-js/utils@2.6.0
|
|
24
|
+
- @modern-js/core@2.6.0
|
|
25
|
+
- @modern-js/plugin-changeset@2.6.0
|
|
26
|
+
- @modern-js/plugin-i18n@2.6.0
|
|
27
|
+
- @modern-js/plugin-lint@2.6.0
|
|
28
|
+
- @modern-js/new-action@2.6.0
|
|
29
|
+
- @modern-js/upgrade@2.6.0
|
|
30
|
+
- @modern-js/plugin@2.6.0
|
|
31
|
+
|
|
3
32
|
## 2.5.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as rollup from '../rollup';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
|
|
4
4
|
interface Options {
|
|
@@ -20,6 +20,109 @@ interface Options {
|
|
|
20
20
|
*/
|
|
21
21
|
tsconfig?: string;
|
|
22
22
|
}
|
|
23
|
-
declare const plugin: PluginImpl<Options>;
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
declare function rollupPluginDts(options?: Options): {
|
|
25
|
+
name: string;
|
|
26
|
+
outputOptions: (this: rollup.PluginContext, options: rollup.OutputOptions) => {
|
|
27
|
+
chunkFileNames: string | ((chunkInfo: rollup.PreRenderedChunk) => string);
|
|
28
|
+
entryFileNames: string | ((chunkInfo: rollup.PreRenderedChunk) => string);
|
|
29
|
+
format: "es";
|
|
30
|
+
exports: "named";
|
|
31
|
+
compact: false;
|
|
32
|
+
freeze: true;
|
|
33
|
+
interop: "esModule";
|
|
34
|
+
generatedCode: {
|
|
35
|
+
symbols: boolean;
|
|
36
|
+
} & (rollup.GeneratedCodePreset | rollup.GeneratedCodeOptions | undefined);
|
|
37
|
+
strict: false;
|
|
38
|
+
amd?: rollup.AmdOptions | undefined;
|
|
39
|
+
assetFileNames?: string | ((chunkInfo: rollup.PreRenderedAsset) => string) | undefined;
|
|
40
|
+
banner?: string | rollup.AddonFunction | undefined;
|
|
41
|
+
dir?: string | undefined;
|
|
42
|
+
dynamicImportFunction?: string | undefined;
|
|
43
|
+
dynamicImportInCjs?: boolean | undefined;
|
|
44
|
+
esModule?: boolean | "if-default-prop" | undefined;
|
|
45
|
+
experimentalDeepDynamicChunkOptimization?: boolean | undefined;
|
|
46
|
+
experimentalMinChunkSize?: number | undefined;
|
|
47
|
+
extend?: boolean | undefined;
|
|
48
|
+
externalImportAssertions?: boolean | undefined;
|
|
49
|
+
externalLiveBindings?: boolean | undefined;
|
|
50
|
+
file?: string | undefined;
|
|
51
|
+
footer?: string | rollup.AddonFunction | undefined;
|
|
52
|
+
globals?: rollup.GlobalsOption | undefined;
|
|
53
|
+
hoistTransitiveImports?: boolean | undefined;
|
|
54
|
+
indent?: string | boolean | undefined;
|
|
55
|
+
inlineDynamicImports?: boolean | undefined;
|
|
56
|
+
intro?: string | rollup.AddonFunction | undefined;
|
|
57
|
+
manualChunks?: rollup.ManualChunksOption | undefined;
|
|
58
|
+
minifyInternalExports?: boolean | undefined;
|
|
59
|
+
name?: string | undefined;
|
|
60
|
+
namespaceToStringTag?: boolean | undefined;
|
|
61
|
+
noConflict?: boolean | undefined;
|
|
62
|
+
outro?: string | rollup.AddonFunction | undefined;
|
|
63
|
+
paths?: rollup.OptionsPaths | undefined;
|
|
64
|
+
plugins?: rollup.OutputPluginOption;
|
|
65
|
+
preferConst?: boolean | undefined;
|
|
66
|
+
preserveModules?: boolean | undefined;
|
|
67
|
+
preserveModulesRoot?: string | undefined;
|
|
68
|
+
sanitizeFileName?: boolean | ((fileName: string) => string) | undefined;
|
|
69
|
+
sourcemap?: boolean | "inline" | "hidden" | undefined;
|
|
70
|
+
sourcemapBaseUrl?: string | undefined;
|
|
71
|
+
sourcemapExcludeSources?: boolean | undefined;
|
|
72
|
+
sourcemapFile?: string | undefined;
|
|
73
|
+
sourcemapPathTransform?: rollup.SourcemapPathTransformOption | undefined;
|
|
74
|
+
systemNullSetters?: boolean | undefined;
|
|
75
|
+
validate?: boolean | undefined;
|
|
76
|
+
};
|
|
77
|
+
renderChunk: (this: rollup.PluginContext, code: string, chunk: rollup.RenderedChunk, options: rollup.NormalizedOutputOptions) => {
|
|
78
|
+
code: string;
|
|
79
|
+
map: {
|
|
80
|
+
mappings: "";
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
options(this: rollup.MinimalPluginContext, options: rollup.InputOptions): {
|
|
84
|
+
onwarn(warning: rollup.RollupLog, warn: rollup.WarningHandler): void;
|
|
85
|
+
treeshake: {
|
|
86
|
+
moduleSideEffects: "no-external";
|
|
87
|
+
propertyReadSideEffects: true;
|
|
88
|
+
unknownGlobalSideEffects: false;
|
|
89
|
+
};
|
|
90
|
+
acorn?: Record<string, unknown> | undefined;
|
|
91
|
+
acornInjectPlugins?: (() => unknown)[] | (() => unknown) | undefined;
|
|
92
|
+
cache?: false | rollup.RollupCache | undefined;
|
|
93
|
+
context?: string | undefined;
|
|
94
|
+
experimentalCacheExpiry?: number | undefined;
|
|
95
|
+
external?: rollup.ExternalOption | undefined;
|
|
96
|
+
inlineDynamicImports?: boolean | undefined;
|
|
97
|
+
input?: rollup.InputOption | undefined;
|
|
98
|
+
makeAbsoluteExternalsRelative?: boolean | "ifRelativeSource" | undefined;
|
|
99
|
+
manualChunks?: rollup.ManualChunksOption | undefined;
|
|
100
|
+
maxParallelFileOps?: number | undefined;
|
|
101
|
+
maxParallelFileReads?: number | undefined;
|
|
102
|
+
moduleContext?: ((id: string) => string | rollup.NullValue) | {
|
|
103
|
+
[id: string]: string;
|
|
104
|
+
} | undefined;
|
|
105
|
+
perf?: boolean | undefined;
|
|
106
|
+
plugins?: rollup.InputPluginOption;
|
|
107
|
+
preserveEntrySignatures?: rollup.PreserveEntrySignaturesOption | undefined;
|
|
108
|
+
preserveModules?: boolean | undefined;
|
|
109
|
+
preserveSymlinks?: boolean | undefined;
|
|
110
|
+
shimMissingExports?: boolean | undefined;
|
|
111
|
+
strictDeprecations?: boolean | undefined;
|
|
112
|
+
watch?: false | rollup.WatcherOptions | undefined;
|
|
113
|
+
};
|
|
114
|
+
transform(this: rollup.TransformPluginContext, code: string, id: string): {
|
|
115
|
+
code: string;
|
|
116
|
+
ast: any;
|
|
117
|
+
map: any;
|
|
118
|
+
} | null;
|
|
119
|
+
resolveId(this: rollup.PluginContext, source: string, importer: string | undefined): {
|
|
120
|
+
id: string;
|
|
121
|
+
external: true;
|
|
122
|
+
} | {
|
|
123
|
+
id: string;
|
|
124
|
+
external?: undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { Options, rollupPluginDts as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"rollup-plugin-dts","author":"Arpad Borsos <arpad.borsos@googlemail.com>","version":"5.
|
|
1
|
+
{"name":"rollup-plugin-dts","author":"Arpad Borsos <arpad.borsos@googlemail.com>","version":"5.2.0","funding":{"url":"https://github.com/sponsors/Swatinem"},"license":"LGPL-3.0","types":"./dist/rollup-plugin-dts.d.ts"}
|
package/dist/build.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -69,3 +73,5 @@ const build = (api, options, context) => __async(void 0, null, function* () {
|
|
|
69
73
|
0 && (module.exports = {
|
|
70
74
|
build
|
|
71
75
|
});
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+B;AAG/B,MAAM,YAAQ,6BAAe,cAAc;AAEpC,MAAM,QAAQ,CACnB,KACA,SACA,YACG;AACH,MAAI,QAAQ,UAAU;AACpB,UAAM,EAAE,cAAc,IAAI,MAAM,6CAAO,oBAAoB;AAC3D,UAAM,cAAc,SAAS,KAAK,OAAO;AACzC;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,eAAe;AAElC,QAAM,EAAE,qBAAqB,IAAI,MAAM,6CAAO,oBAAoB;AAClE,QAAM,sBAAsB,MAAM,qBAAqB,KAAK,SAAS,OAAO;AAE5E,QAAM,uBAAuB,mBAAmB;AAEhD,QAAM,OAAO,YAAY;AAAA,IACvB,QAAQ;AAAA,IACR,YAAY;AAAA,EACd,CAAC;AACD,QAAM,UAAU,MAAM,6CAAO,WAAW;AACxC,QAAM,QAAQ,IAAI,EAAE,YAAY,SAAS,qBAAqB,QAAQ,GAAG,GAAG;AAC9E;;;;;","names":[],"sources":["../src/build.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport { createDebugger } from '@modern-js/utils';\nimport type { ModuleTools, ModuleContext, BuildCommandOptions } from './types';\n\nconst debug = createDebugger('module-tools');\n\nexport const build = async (\n api: PluginAPI<ModuleTools>,\n options: BuildCommandOptions,\n context: ModuleContext,\n) => {\n if (options.platform) {\n const { buildPlatform } = await import('./builder/platform');\n await buildPlatform(options, api, context);\n return;\n }\n\n const runner = api.useHookRunners();\n\n const { normalizeBuildConfig } = await import('./config/normalize');\n const resolvedBuildConfig = await normalizeBuildConfig(api, context, options);\n\n debug('resolvedBuildConfig', resolvedBuildConfig);\n\n await runner.beforeBuild({\n config: resolvedBuildConfig,\n cliOptions: options,\n });\n const builder = await import('./builder');\n await builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);\n};\n"]}
|
package/dist/builder/build.js
CHANGED
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -228,6 +232,7 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
228
232
|
autoExternal,
|
|
229
233
|
bundle: buildType === "bundle",
|
|
230
234
|
sideEffects,
|
|
235
|
+
// outbase for [dir]/[name]
|
|
231
236
|
outbase: sourceDir,
|
|
232
237
|
esbuildOptions: (options2) => __spreadProps(__spreadValues({}, options2), {
|
|
233
238
|
supported: {
|
|
@@ -270,3 +275,5 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
270
275
|
generatorDts,
|
|
271
276
|
runBuildTask
|
|
272
277
|
});
|
|
278
|
+
|
|
279
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context } = options;\n const { appDirectory, isTsProject } = context;\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory });\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n sideEffects,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = format === 'umd' ? [umdPlugin(umdModuleName)] : [];\n if (target === 'es5') {\n plugins.push(es5Plugin());\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuild-plugins'\n );\n plugins.push(watchPlugin(api, config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n const { addOutputChunk } = await import('../utils/print');\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n addOutputChunk(builder.outputChunk, root, buildType === 'bundle');\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
package/dist/builder/clear.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -63,3 +67,5 @@ const clearBuildConfigPaths = (configs) => __async(void 0, null, function* () {
|
|
|
63
67
|
clearBuildConfigPaths,
|
|
64
68
|
clearDtsTemp
|
|
65
69
|
});
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe,MAAY;AACtC,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAC5D,QAAM,GAAG,OAAO,gBAAgB;AAClC;AAEO,MAAM,wBAAwB,CAAO,YAA+B;AACzE,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAE9C,aAAW,UAAU,SAAS;AAC5B,UAAM,GAAG,OAAO,OAAO,MAAM;AAAA,EAC/B;AACF;;;;;;","names":[],"sources":["../../src/builder/clear.ts"],"sourcesContent":["import type { BaseBuildConfig } from '../types';\n\nexport const clearDtsTemp = async () => {\n const { fs } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n await fs.remove(dtsTempDirectory);\n};\n\nexport const clearBuildConfigPaths = async (configs: BaseBuildConfig[]) => {\n const { fs } = await import('@modern-js/utils');\n\n for (const config of configs) {\n await fs.remove(config.outDir);\n }\n};\n"]}
|
package/dist/builder/copy.js
CHANGED
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -71,18 +75,19 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
71
75
|
const { default: normalizePath } = yield Promise.resolve().then(() => __toESM(require("../../compiled/normalize-path")));
|
|
72
76
|
const { appDirectory, enableCopySync = false } = options;
|
|
73
77
|
const { from, globOptions = {} } = pattern;
|
|
78
|
+
const targetPattern = __spreadValues({}, pattern);
|
|
74
79
|
const normalizedFrom = import_path.default.normalize(from);
|
|
75
80
|
const defaultAbsContext = options.defaultContext;
|
|
76
81
|
if (typeof pattern.context === "string") {
|
|
77
|
-
|
|
82
|
+
targetPattern.context = import_path.default.isAbsolute(pattern.context) ? pattern.context : import_path.default.join(appDirectory, pattern.context);
|
|
78
83
|
} else {
|
|
79
|
-
|
|
84
|
+
targetPattern.context = defaultAbsContext;
|
|
80
85
|
}
|
|
81
86
|
let absoluteFrom;
|
|
82
87
|
if (import_path.default.isAbsolute(normalizedFrom)) {
|
|
83
88
|
absoluteFrom = normalizedFrom;
|
|
84
89
|
} else {
|
|
85
|
-
absoluteFrom = import_path.default.resolve(
|
|
90
|
+
absoluteFrom = import_path.default.resolve(targetPattern.context, normalizedFrom);
|
|
86
91
|
}
|
|
87
92
|
let stats;
|
|
88
93
|
try {
|
|
@@ -104,7 +109,7 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
104
109
|
let glob;
|
|
105
110
|
switch (fromType) {
|
|
106
111
|
case "dir":
|
|
107
|
-
|
|
112
|
+
targetPattern.context = absoluteFrom;
|
|
108
113
|
glob = import_path.default.posix.join(
|
|
109
114
|
fastGlob.escapePath(normalizePath(import_path.default.resolve(absoluteFrom))),
|
|
110
115
|
"**/*"
|
|
@@ -115,7 +120,7 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
115
120
|
}
|
|
116
121
|
break;
|
|
117
122
|
case "file":
|
|
118
|
-
|
|
123
|
+
targetPattern.context = import_path.default.dirname(absoluteFrom);
|
|
119
124
|
glob = fastGlob.escapePath(normalizePath(import_path.default.resolve(absoluteFrom)));
|
|
120
125
|
if (typeof globOptions.dot === "undefined") {
|
|
121
126
|
globOptions.dot = true;
|
|
@@ -125,14 +130,16 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
125
130
|
default: {
|
|
126
131
|
glob = import_path.default.isAbsolute(from) ? from : import_path.default.posix.join(
|
|
127
132
|
fastGlob.escapePath(
|
|
128
|
-
normalizePath(
|
|
133
|
+
normalizePath(
|
|
134
|
+
import_path.default.resolve((_a = targetPattern.context) != null ? _a : appDirectory)
|
|
135
|
+
)
|
|
129
136
|
),
|
|
130
137
|
from
|
|
131
138
|
);
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
|
-
const globEntries = yield globby(glob, __spreadProps(__spreadValues(__spreadValues({}, { followSymbolicLinks: true }),
|
|
135
|
-
cwd:
|
|
141
|
+
const globEntries = yield globby(glob, __spreadProps(__spreadValues(__spreadValues({}, { followSymbolicLinks: true }), targetPattern.globOptions || {}), {
|
|
142
|
+
cwd: targetPattern.context,
|
|
136
143
|
objectMode: true
|
|
137
144
|
}));
|
|
138
145
|
const { default: pMap } = yield Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
@@ -142,13 +149,13 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
142
149
|
return;
|
|
143
150
|
}
|
|
144
151
|
const from2 = globEntry.path;
|
|
145
|
-
const absoluteFrom2 = import_path.default.resolve(
|
|
152
|
+
const absoluteFrom2 = import_path.default.resolve(targetPattern.context, from2);
|
|
146
153
|
const to = import_path.default.normalize(
|
|
147
|
-
typeof
|
|
154
|
+
typeof targetPattern.to !== "undefined" ? targetPattern.to : ""
|
|
148
155
|
);
|
|
149
156
|
const toType = import_path.default.extname(to) === "" || to.slice(-1) === import_path.default.sep ? "dir" : "file";
|
|
150
157
|
const relativeFrom = import_path.default.relative(
|
|
151
|
-
(_a2 =
|
|
158
|
+
(_a2 = targetPattern.context) != null ? _a2 : defaultAbsContext,
|
|
152
159
|
absoluteFrom2
|
|
153
160
|
);
|
|
154
161
|
const filename = toType === "dir" ? import_path.default.join(to, relativeFrom) : to;
|
|
@@ -192,3 +199,5 @@ const copyTask = (buildConfig, options) => __async(void 0, null, function* () {
|
|
|
192
199
|
copyTask,
|
|
193
200
|
runPatterns
|
|
194
201
|
});
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAKV,MAAM,cAAc,CACzB,SACA,YAMG;AAbL;AAcE,QAAM,EAAE,IAAI,UAAU,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AAChE,QAAM,EAAE,SAAS,cAAc,IAAI,MAAM,6CACvC,+BACF;AACA,QAAM,EAAE,cAAc,iBAAiB,MAAM,IAAI;AACjD,QAAM,EAAE,MAAM,cAAc,CAAC,EAAE,IAA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,WAAW,YAAY,WAAW,SAAS,WAAW,GAAG;AAC5D;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO,sBAAsB;AAC7D,QAAM,gBAAc,8CAAY,YAAZ,mBAAqB,gBAAe;AACxD,MAAI;AACF,UAAM;AAAA,MACJ,WAAW;AAAA,MACX,CAAM,eAAc;AAzJ1B;AA0JQ,cAAM,YAAY,YAAY,iCACzB,UADyB;AAAA,UAE5B,iBAAgBC,iBAAW,YAAX,oBAAoB;AAAA,UACpC,QAAQ,YAAY;AAAA,UACpB,gBAAgB,YAAY;AAAA,QAC9B,EAAC;AAAA,MACH;AAAA,MACA,EAAE,YAAY;AAAA,IAChB;AAAA,EACF,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,cAAQ,MAAM,eAAe,EAAE,SAAS;AAAA,IAC1C;AAAA,EACF;AACF;;;;;;","names":["from","absoluteFrom","_a"],"sources":["../../src/builder/copy.ts"],"sourcesContent":["import path from 'path';\nimport type { CopyPattern } from '../types/copy';\nimport type { BaseBuildConfig } from '../types/config';\n\n// TODO: about copy rules and debug\nexport const runPatterns = async (\n pattern: CopyPattern,\n options: {\n appDirectory: string;\n enableCopySync?: boolean;\n outDir: string;\n defaultContext: string;\n },\n) => {\n const { fs, fastGlob, globby } = await import('@modern-js/utils');\n const { default: normalizePath } = await import(\n '../../compiled/normalize-path'\n );\n const { appDirectory, enableCopySync = false } = options;\n const { from, globOptions = {} } = pattern;\n const targetPattern: CopyPattern = { ...pattern };\n const normalizedFrom = path.normalize(from);\n const defaultAbsContext = options.defaultContext;\n\n // when context is relative path\n if (typeof pattern.context === 'string') {\n targetPattern.context = path.isAbsolute(pattern.context)\n ? pattern.context\n : path.join(appDirectory, pattern.context);\n } else {\n targetPattern.context = defaultAbsContext;\n }\n\n let absoluteFrom;\n if (path.isAbsolute(normalizedFrom)) {\n absoluteFrom = normalizedFrom;\n } else {\n absoluteFrom = path.resolve(targetPattern.context, normalizedFrom);\n }\n\n let stats;\n try {\n stats = await fs.stat(absoluteFrom);\n } catch (error) {\n // Do Nothing\n }\n\n let fromType: 'file' | 'dir' | 'glob';\n if (stats) {\n if (stats.isDirectory()) {\n fromType = 'dir';\n } else if (stats.isFile()) {\n fromType = 'file';\n } else {\n fromType = 'glob';\n }\n } else {\n fromType = 'glob';\n }\n\n let glob;\n\n switch (fromType) {\n case 'dir':\n targetPattern.context = absoluteFrom;\n glob = path.posix.join(\n fastGlob.escapePath(normalizePath(path.resolve(absoluteFrom))),\n '**/*',\n );\n absoluteFrom = path.join(absoluteFrom, '**/*');\n\n if (typeof globOptions.dot === 'undefined') {\n globOptions.dot = true;\n }\n break;\n case 'file':\n targetPattern.context = path.dirname(absoluteFrom);\n glob = fastGlob.escapePath(normalizePath(path.resolve(absoluteFrom)));\n\n if (typeof globOptions.dot === 'undefined') {\n globOptions.dot = true;\n }\n break;\n case 'glob':\n default: {\n glob = path.isAbsolute(from)\n ? from\n : path.posix.join(\n fastGlob.escapePath(\n normalizePath(\n path.resolve(targetPattern.context ?? appDirectory),\n ),\n ),\n from,\n );\n }\n }\n\n const globEntries = await globby(glob, {\n ...{ followSymbolicLinks: true },\n ...(targetPattern.globOptions || {}),\n cwd: targetPattern.context,\n objectMode: true,\n });\n const { default: pMap } = await import('../../compiled/p-map');\n pMap(globEntries, async globEntry => {\n if (!globEntry.dirent.isFile()) {\n return;\n }\n\n const from = globEntry.path;\n const absoluteFrom = path.resolve(targetPattern.context!, from);\n const to = path.normalize(\n typeof targetPattern.to !== 'undefined' ? targetPattern.to : '',\n );\n const toType =\n path.extname(to) === '' || to.slice(-1) === path.sep ? 'dir' : 'file';\n\n const relativeFrom = path.relative(\n targetPattern.context ?? defaultAbsContext,\n absoluteFrom,\n );\n\n const filename = toType === 'dir' ? path.join(to, relativeFrom) : to;\n\n const absoluteTo = path.isAbsolute(filename)\n ? filename\n : path.join(options.outDir, filename);\n if (enableCopySync) {\n fs.copySync(absoluteFrom, absoluteTo);\n } else {\n await fs.copy(absoluteFrom, absoluteTo);\n }\n });\n};\n\nexport const copyTask = async (\n buildConfig: BaseBuildConfig,\n options: {\n appDirectory: string;\n },\n) => {\n const copyConfig = buildConfig.copy;\n\n if (!copyConfig.patterns || copyConfig.patterns.length === 0) {\n return;\n }\n\n const { default: pMap } = await import('../../compiled/p-map');\n const concurrency = copyConfig?.options?.concurrency || 100;\n try {\n await pMap(\n copyConfig.patterns,\n async copyOption => {\n await runPatterns(copyOption, {\n ...options,\n enableCopySync: copyConfig.options?.enableCopySync,\n outDir: buildConfig.outDir,\n defaultContext: buildConfig.sourceDir,\n });\n },\n { concurrency },\n );\n } catch (e) {\n if (e instanceof Error) {\n console.error(`copy error: ${e.message}`);\n }\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAC1B,iBAAuB;;;;;;","names":[],"sources":["../../../src/builder/dts/index.ts"],"sourcesContent":["export { runRollup } from './rollup';\nexport { runTsc } from './tsc';\n"]}
|
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -91,20 +95,32 @@ const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDi
|
|
|
91
95
|
jsonPlugin(),
|
|
92
96
|
ignoreFiles,
|
|
93
97
|
dtsPlugin({
|
|
98
|
+
// use external to prevent them which come from node_modules from be bundled.
|
|
94
99
|
respectExternal: true,
|
|
95
100
|
compilerOptions: __spreadProps(__spreadValues({
|
|
96
101
|
declarationMap: false,
|
|
97
102
|
skipLibCheck: true,
|
|
103
|
+
// https://github.com/Swatinem/rollup-plugin-dts/issues/143,
|
|
104
|
+
// but it will cause error when bundle ts which import another ts file.
|
|
98
105
|
preserveSymlinks: false
|
|
99
106
|
}, options), {
|
|
107
|
+
// https://github.com/Swatinem/rollup-plugin-dts/issues/127
|
|
108
|
+
composite: false,
|
|
109
|
+
// isAbsolute
|
|
100
110
|
baseUrl,
|
|
111
|
+
// Ensure ".d.ts" modules are generated
|
|
101
112
|
declaration: true,
|
|
113
|
+
// Skip ".js" generation
|
|
102
114
|
noEmit: false,
|
|
103
115
|
emitDeclarationOnly: true,
|
|
116
|
+
// Skip code generation when error occurs
|
|
104
117
|
noEmitOnError: true,
|
|
118
|
+
// Avoid extra work
|
|
105
119
|
checkJs: false,
|
|
120
|
+
// Ensure we can parse the latest code
|
|
106
121
|
target: ts.ScriptTarget.ESNext
|
|
107
|
-
})
|
|
122
|
+
}),
|
|
123
|
+
tsconfig: tsconfigPath
|
|
108
124
|
})
|
|
109
125
|
].filter(Boolean)
|
|
110
126
|
};
|
|
@@ -162,3 +178,5 @@ const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDi
|
|
|
162
178
|
0 && (module.exports = {
|
|
163
179
|
runRollup
|
|
164
180
|
});
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=rollup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAwBV,MAAM,YAAY,CACvB,IACA,OACG,iBAFH,IACA,KACG,WAFH,KAC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src/builder/dts/rollup.ts"],"sourcesContent":["import path from 'path';\nimport type {\n InputOptions,\n OutputOptions,\n Plugin,\n RollupWatcher,\n} from '../../../compiled/rollup';\nimport type {\n BaseBuildConfig,\n Input,\n PluginAPI,\n ModuleTools,\n} from '../../types';\n\nexport type { RollupWatcher };\n\ntype Config = {\n distDir: string;\n tsconfigPath: string;\n externals: BaseBuildConfig['externals'];\n input: Input;\n watch: boolean;\n};\n\nexport const runRollup = async (\n api: PluginAPI<ModuleTools>,\n { distDir, tsconfigPath, externals, input, watch }: Config,\n) => {\n const ignoreFiles: Plugin = {\n name: 'ignore-files',\n load(id) {\n if (!/\\.(js|jsx|ts|tsx|json|cts|mts)$/.test(id)) {\n return '';\n }\n return null;\n },\n };\n const ts = await import('typescript');\n const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n const { options } = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n './',\n );\n\n const { default: jsonPlugin } = await import(\n '../../../compiled/@rollup/plugin-json'\n );\n const { default: dtsPlugin } = await import(\n '../../../compiled/rollup-plugin-dts'\n );\n const baseUrl = path.isAbsolute(options.baseUrl || '.')\n ? options.baseUrl\n : path.join(path.dirname(tsconfigPath), options.baseUrl || '.');\n const inputConfig: InputOptions = {\n input,\n external: externals,\n plugins: [\n jsonPlugin(),\n ignoreFiles,\n dtsPlugin({\n // use external to prevent them which come from node_modules from be bundled.\n respectExternal: true,\n compilerOptions: {\n declarationMap: false,\n skipLibCheck: true,\n // https://github.com/Swatinem/rollup-plugin-dts/issues/143,\n // but it will cause error when bundle ts which import another ts file.\n preserveSymlinks: false,\n ...options,\n // https://github.com/Swatinem/rollup-plugin-dts/issues/127\n composite: false,\n // isAbsolute\n baseUrl,\n // Ensure \".d.ts\" modules are generated\n declaration: true,\n // Skip \".js\" generation\n noEmit: false,\n emitDeclarationOnly: true,\n // Skip code generation when error occurs\n noEmitOnError: true,\n // Avoid extra work\n checkJs: false,\n // Ensure we can parse the latest code\n target: ts.ScriptTarget.ESNext,\n },\n tsconfig: tsconfigPath,\n }),\n ].filter(Boolean),\n };\n const outputConfig: OutputOptions = {\n dir: distDir,\n format: 'esm',\n exports: 'named',\n };\n if (watch) {\n const { watch } = await import('../../../compiled/rollup');\n const { watchSectionTitle } = await import('../../utils/log');\n const { SectionTitleStatus, BundleDtsLogPrefix } = await import(\n '../../constants/log'\n );\n const runner = api.useHookRunners();\n const watcher = watch({\n ...inputConfig,\n plugins: inputConfig.plugins,\n output: outputConfig,\n }).on('event', async event => {\n if (event.code === 'START') {\n console.info(\n await watchSectionTitle(BundleDtsLogPrefix, SectionTitleStatus.Log),\n );\n } else if (event.code === 'BUNDLE_END') {\n console.info(\n await watchSectionTitle(\n BundleDtsLogPrefix,\n SectionTitleStatus.Success,\n ),\n );\n runner.buildWatchDts({ buildType: 'bundle' });\n } else if (event.code === 'ERROR') {\n // this is dts rollup plugin bug, error not complete message\n }\n });\n return watcher;\n } else {\n try {\n const { rollup } = await import('../../../compiled/rollup');\n const { addRollupChunk } = await import('../../utils/print');\n const bundle = await rollup(inputConfig);\n const rollupOutput = await bundle.write(outputConfig);\n const { appDirectory } = api.useAppContext();\n addRollupChunk(rollupOutput, appDirectory, outputConfig.dir!);\n return bundle;\n } catch (e) {\n if (e instanceof Error) {\n const { InternalDTSError } = await import('../../error');\n throw new InternalDTSError(e, {\n buildType: 'bundle',\n });\n }\n throw e;\n }\n }\n};\n"]}
|
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -112,7 +116,9 @@ const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
|
112
116
|
[
|
|
113
117
|
"-p",
|
|
114
118
|
result.tempTsconfigPath,
|
|
119
|
+
/* Required parameter, use it stdout have color */
|
|
115
120
|
"--pretty",
|
|
121
|
+
// https://github.com/microsoft/TypeScript/issues/21824
|
|
116
122
|
"--preserveWatchOutput",
|
|
117
123
|
...watchParams
|
|
118
124
|
],
|
|
@@ -153,3 +159,5 @@ const runTsc = (api, config) => __async(void 0, null, function* () {
|
|
|
153
159
|
getProjectTsconfig,
|
|
154
160
|
runTsc
|
|
155
161
|
});
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=tsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,qBAAqB,CAChC,iBACuB;AACvB,QAAM,EAAE,OAAO,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AACrD,MAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAChC,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAM,MAAM,GAAG,aAAa,cAAc,OAAO,CAAC;AAC3D;AAEA,MAAM,aAAa,CACjB,eACA,YAIG;AAzBL;AA0BE,QAAM,EAAE,QAAQ,OAAO,UAAU,MAAS;AAAG;AAAA,KAAU,IAAI;AAC3D,QAAM,EAAE,oBAAoB,uBAAuB,IAAI,MAAM,6CAC3D,qBACF;AACA,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,iBAAiB;AAC5D,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO,qBAAqB;AAO5D,sBAAc,WAAd,mB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6CAAO,iBAAiB;AACvD,YAAM,aAAa,QAAQ,iCAAK,SAAL,EAAa,aAAa,EAAC;AACtD,aAAO,cAAc,EAAE,WAAW,aAAa,CAAC;AAAA,IAClD;AAAA,EACF,CAAC;AAED,MAAI;AACF,UAAM;AAAA,EACR,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,YAAM,IAAI,iBAAiB,GAAG;AAAA,QAC5B,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,iCAAK,SAAL,EAAa,aAAa;AACnC;AAEO,MAAM,SAAS,CACpB,KACA,WACG;AACH,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,iBAAiB;AACvD,QAAM,EAAE,YAAY,IAAI,MAAM,6CAAO,mBAAmB;AACxD,QAAM,SAAS,MAAM,aAAa,KAAK,MAAM;AAC7C,QAAM,aAAa,QAAQ,MAAM;AACjC,QAAM,YAAY,OAAO,aAAa,OAAO,YAAY;AAC3D;;;;;;","names":[],"sources":["../../../src/builder/dts/tsc.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport type {\n BundlelessGeneratorDtsConfig,\n ITsconfig,\n PluginAPI,\n ModuleTools,\n} from '../../types';\n\nexport const getProjectTsconfig = async (\n tsconfigPath: string,\n): Promise<ITsconfig> => {\n const { json5, fs } = await import('@modern-js/utils');\n if (!fs.existsSync(tsconfigPath)) {\n return {};\n }\n\n return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));\n};\n\nconst resolveLog = async (\n childProgress: ChildProcess,\n options: {\n watch: boolean;\n watchFn: () => Promise<void>;\n },\n) => {\n const { watch = false, watchFn = async () => undefined } = options;\n const { SectionTitleStatus, BundlelessDtsLogPrefix } = await import(\n '../../constants/log'\n );\n const { watchSectionTitle } = await import('../../utils/log');\n const { watchDoneText } = await import('../../constants/dts');\n\n /**\n * tsc 所有的log信息都是从stdout data 事件中获取\n * 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理\n * watch 模式下,则使用这里的信息\n */\n childProgress.stdout?.on('data', async data => {\n if (watch) {\n console.info(\n await watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log),\n );\n console.info(data.toString());\n if (data.toString().includes(watchDoneText)) {\n await watchFn();\n }\n }\n });\n // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况\n childProgress.stdout?.on('error', error => {\n console.error(error.message);\n });\n childProgress.stderr?.on('data', chunk => {\n console.error(chunk.toString());\n });\n};\n\nconst generatorDts = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { execa } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../../error');\n const { generatorTsConfig } = await import('../../utils/dts');\n const { getTscBinPath } = await import('../../utils/dts');\n const { tsconfigPath, appDirectory, watch = false } = config;\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n const result = await generatorTsConfig(config);\n\n const tscBinFile = await getTscBinPath(appDirectory);\n\n const watchParams = watch ? ['-w'] : [];\n const childProgress = execa(\n tscBinFile,\n [\n '-p',\n result.tempTsconfigPath,\n /* Required parameter, use it stdout have color */\n '--pretty',\n // https://github.com/microsoft/TypeScript/issues/21824\n '--preserveWatchOutput',\n ...watchParams,\n ],\n {\n stdio: 'pipe',\n cwd: appDirectory,\n },\n );\n\n const runner = api.useHookRunners();\n resolveLog(childProgress, {\n watch,\n watchFn: async () => {\n const { resolveAlias } = await import('../../utils/dts');\n await resolveAlias(config, { ...result, userTsconfig });\n runner.buildWatchDts({ buildType: 'bundleless' });\n },\n });\n\n try {\n await childProgress;\n } catch (e) {\n if (e instanceof Error) {\n throw new InternalDTSError(e, {\n buildType: 'bundleless',\n });\n }\n }\n\n return { ...result, userTsconfig };\n};\n\nexport const runTsc = async (\n api: PluginAPI<ModuleTools>,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { resolveAlias } = await import('../../utils/dts');\n const { addDtsFiles } = await import('../../utils/print');\n const result = await generatorDts(api, config);\n await resolveAlias(config, result);\n await addDtsFiles(config.distAbsPath, config.appDirectory);\n};\n"]}
|
package/dist/builder/index.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -106,3 +110,5 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
106
110
|
0 && (module.exports = {
|
|
107
111
|
run
|
|
108
112
|
});
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,MAAM,CACjB,SAKA,QACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,qBAAqB,SAAS,WAAW,IAAI;AACrD,QAAM,SAAS,IAAI,eAAe;AAElC,MAAI,gBAAgB;AAEpB,MAAI,oBAAoB,WAAW,GAAG;AACpC,oBAAgB,KAAK,IAAI;AAEzB,UAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,SAAS;AAC/C,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO,sBAAsB;AAE7D,UAAM,EAAE,uBAAuB,aAAa,IAAI,MAAM,6CAAO,SAAS;AACtE,UAAM,sBAAsB,mBAAmB;AAC/C,UAAM,aAAa;AAEnB,QAAI,WAAW,OAAO;AACpB,cAAQ,KAAK,MAAM,KAAK,UAAU,gCAAgC,CAAC;AAAA,IACrE;AAEA,QAAI;AACF,YAAM,KAAK,qBAAqB,CAAM,WAAU;AAC9C,cAAM,cAAc,MAAM,OAAO,gBAAgB,MAAM;AAEvD,cAAM;AAAA,UACJ;AAAA,YACE;AAAA,YACA,iBAAiB;AAAA,YACjB;AAAA,UACF;AAAA,UACA;AAAA,QACF;AACA,cAAM,OAAO,eAAe,EAAE,QAAQ,WAAW,OAAO,CAAC;AAAA,MAC3D,EAAC;AAAA,IACH,SAAS,GAAP;AACA,YAAM,EAAE,iBAAiB,iBAAiB,IAAI,MAAM,6CAAO,UAAU;AACrE,UAAI,gBAAgB,CAAC,GAAG;AACtB,cAAM,IAAI,iBAAiB,CAAC;AAAA,MAC9B,OAAO;AACL,cAAM;AAAA,MACR;AAAA,IACF;AACA,oBAAgB,KAAK,IAAI,IAAI;AAC7B,QAAI,CAAC,WAAW,OAAO;AACrB,YAAM,EAAE,eAAe,aAAa,IAAI,MAAM,6CAAO,gBAAgB;AACrE,mBAAa,aAAa;AAC1B,oBAAc;AAAA,IAChB;AAAA,EACF,OAAO;AACL,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,WAAW;AAAA,IACtB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB;AAAA,EACF,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/index.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleContext } from '../types/context';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n} from '../types';\n\nexport const run = async (\n options: {\n cmdOptions: BuildCommandOptions;\n resolvedBuildConfig: BaseBuildConfig[];\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { resolvedBuildConfig, context, cmdOptions } = options;\n const runner = api.useHookRunners();\n\n let totalDuration = 0;\n\n if (resolvedBuildConfig.length !== 0) {\n totalDuration = Date.now();\n\n const { runBuildTask } = await import('./build');\n const { default: pMap } = await import('../../compiled/p-map');\n\n const { clearBuildConfigPaths, clearDtsTemp } = await import('./clear');\n await clearBuildConfigPaths(resolvedBuildConfig);\n await clearDtsTemp();\n\n if (cmdOptions.watch) {\n console.info(chalk.blue.underline('start build in watch mode...\\n'));\n }\n\n try {\n await pMap(resolvedBuildConfig, async config => {\n const buildConfig = await runner.beforeBuildTask(config);\n\n await runBuildTask(\n {\n buildConfig,\n buildCmdOptions: cmdOptions,\n context,\n },\n api,\n );\n await runner.afterBuildTask({ status: 'success', config });\n });\n } catch (e) {\n const { isInternalError, ModuleBuildError } = await import('../error');\n if (isInternalError(e)) {\n throw new ModuleBuildError(e);\n } else {\n throw e;\n }\n }\n totalDuration = Date.now() - totalDuration;\n if (!cmdOptions.watch) {\n const { printFileSize, printSucceed } = await import('../utils/print');\n printSucceed(totalDuration);\n printFileSize();\n }\n } else {\n console.warn(\n chalk.yellow(\n `No build configuration found! Please configure \\`buildConfig\\` or \\`buildPreset\\``,\n ),\n );\n }\n\n await runner.afterBuild({\n status: 'success',\n config: resolvedBuildConfig,\n commandOptions: cmdOptions,\n totalDuration,\n });\n};\n"]}
|
package/dist/builder/platform.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -142,3 +146,5 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
142
146
|
0 && (module.exports = {
|
|
143
147
|
buildPlatform
|
|
144
148
|
});
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,gBAAgB,CAC3B,SACA,KACA,YACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,MAAM,KAAK,IAAI,MAAM,6CAAO,qBAAqB;AACzD,QAAM,SAAS,IAAI,eAAe;AAClC,QAAM,mBAAmB,MAAM,OAAO,sBAAsB;AAC5D,MAAI,iBAAiB,WAAW,GAAG;AACjC,QAAI,QAAQ,aAAa,MAAM;AAC7B,cAAQ,KAAK,oCAAoC;AAAA,IACnD,WACE,MAAM,QAAQ,QAAQ,QAAQ,KAC9B,QAAQ,SAAS,WAAW,GAC5B;AACA,cAAQ;AAAA,QACN,iCAAiC,QAAQ,SAAS,CAAC;AAAA,MACrD;AAAA,IACF,WAAW,MAAM,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,SAAS,SAAS,GAAG;AACzE,cAAQ;AAAA,QACN,gCAAgC,QAAQ,SAAS,KAAK,GAAG;AAAA,MAC3D;AAAA,IACF,OAAO;AACL,cAAQ,KAAK,oBAAoB,KAAK,UAAU,QAAQ,QAAQ,CAAC;AAAA,IACnE;AAEA;AAAA,EACF;AAEA,QAAM,OAAO,oBAAoB,gBAAgB;AACjD,MAAI,WAAkC;AACtC,MAAI;AACF,QAAI,QAAQ,aAAa,MAAM;AAC7B,iBAAW,mBAAmB,kBAAkB;AAC9C,cAAM,kBAAkB,MAA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ACnC,mBAAO,QAAQ,SAAS,SAAS,QAAQ;AAAA,UAC3C;AAEA,iBAAO,QAAQ,aAAa;AAAA,QAC9B,CAAC;AAED,YAAI,CAAC,cAAc;AACjB,kBAAQ,KAAK,QAAQ,2CAA2C;AAChE;AAAA,QACF;AAEA,gBAAQ;AAAA,UACN,MAAM,UAAU,IAAI,GAAG,IAAI,EAAE,YAAY,uBAAuB;AAAA,QAClE;AAEA,cAAM,OAAO,cAAc,EAAE,SAAS,CAAC;AACvC,cAAM,aAAa,MAAM,UAAU;AAAA,UACjC,aAAa,QAAQ;AAAA,QACvB,CAAC;AAED,gBAAQ,KAAK,MAAM,IAAI,GAAG,IAAI,EAAE,aAAa,gBAAgB,CAAC;AAAA,MAChE;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,iBAAW;AAAA,IACb,OAAO;AACL,iBAAW,OAAO,CAAC;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,OAAO,mBAAmB;AAAA,IAC9B,QAAQ,aAAa,OAAO,YAAY;AAAA,IACxC,SAAS;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { ModuleContext } from '../types/context';\nimport { BuildCommandOptions, ModuleTools } from '../types';\n\nexport const buildPlatform = async (\n options: BuildCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { blue, gray } = await import('../constants/colors');\n const runner = api.useHookRunners();\n const platformBuilders = await runner.registerBuildPlatform();\n if (platformBuilders.length === 0) {\n if (options.platform === true) {\n console.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n console.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n console.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n console.info('Unknown platform', JSON.stringify(options.platform));\n }\n\n return;\n }\n\n await runner.beforeBuildPlatform(platformBuilders);\n let errorMsg: string | Error | null = null;\n try {\n if (options.platform === true) {\n for (const platformBuilder of platformBuilders) {\n const currentPlatform = Array.isArray(platformBuilder.platform)\n ? platformBuilder.platform[0]\n : platformBuilder.platform;\n\n console.info(\n chalk.underline.rgb(...blue)(\n `Running [${currentPlatform}] build task:`,\n ),\n );\n\n await runner.buildPlatform({ platform: currentPlatform });\n await platformBuilder.build(currentPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));\n }\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n const targetPlatform = options.platform[0];\n const selectPlatformBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(targetPlatform);\n }\n\n return builder.platform === targetPlatform;\n });\n\n if (!selectPlatformBuilder) {\n console.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`),\n );\n\n await runner.buildPlatform({ platform: targetPlatform });\n await selectPlatformBuilder.build(targetPlatform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n for (const platform of options.platform) {\n const foundBuilder = platformBuilders.find(builder => {\n if (Array.isArray(builder.platform)) {\n return builder.platform.includes(platform);\n }\n\n return builder.platform === platform;\n });\n\n if (!foundBuilder) {\n console.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n console.info(\n chalk.underline.rgb(...blue)(`Running [${platform}] build task:`),\n );\n\n await runner.buildPlatform({ platform });\n await foundBuilder.build(platform, {\n isTsProject: context.isTsProject,\n });\n\n console.info(chalk.rgb(...gray)(`Done for [${platform}] task`));\n }\n }\n } catch (e) {\n if (e instanceof Error) {\n errorMsg = e;\n } else {\n errorMsg = String(e);\n }\n }\n\n await runner.afterBuildPlatform({\n status: errorMsg === null ? 'success' : 'fail',\n message: errorMsg,\n });\n};\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -93,3 +97,5 @@ const setup = (api) => __async(void 0, null, function* () {
|
|
|
93
97
|
0 && (module.exports = {
|
|
94
98
|
cli
|
|
95
99
|
});
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6B;AAC7B,qBAA2B;AAEpB,MAAM,MAAM,OAA+B;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,gBAAY,2BAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;AAAA,EAC/C;AACF;AAEA,MAAM,QAAyC,CAAM,QAAO;AAC1D,QAAM,UAAU,MAAY;AAC1B,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,UAAM,kBAAkB;AAExB,UAAM,aAAa,IAAI,cAAc;AACrC,UAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,WAAO,OAAO;AAEd,UAAM,GAAG,SAAS,WAAW,iBAAiB;AAE9C,UAAM,cAAc,IAAI,eAAe;AACvC,UAAM,YAAY,kBAAkB;AAEpC,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,gBAAgB;AACzD,UAAM,gBAAgB,MAAY;AAChC,YAAM,YAAY,SAAS;AAAA,IAC7B,EAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,MAAY;AACjC,UAAM,EAAE,QAAQ,aAAa,IAAI,MAAM,6CAAO,iBAAiB;AAC/D,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,gBAAgB;AAC5D,UAAM,aAAa,IAAI,iBAAiB;AACxC,WAAO,mBAAmB,UAAkC,IACxD,eACA;AAAA,EACN;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACM,SAAS,IAAa;AAAA,iDAAb,EAAE,QAAQ,GAAG;AAC1B,cAAM,EAAE,cAAc,YAAY,YAAY,cAAc,IAC1D,MAAM,6CAAO,WAAW;AAC1B,cAAM,aAAa,SAAS,GAAG;AAC/B,cAAM,WAAW,SAAS,GAAG;AAC7B,cAAM,WAAW,OAAO;AACxB,cAAM,cAAc,OAAO;AAAA,MAC7B;AAAA;AAAA,EACF;AACF;;;;;","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import type { CliPlugin } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport { registerHook } from './hooks';\nimport { getPlugins } from './plugins';\n\nexport const cli = (): CliPlugin<ModuleTools> => ({\n name: '@modern-js/module-tools',\n registerHook,\n usePlugins: getPlugins(process.argv.slice(2)[0]),\n setup,\n});\n\nconst setup: CliPlugin<ModuleTools>['setup'] = async api => {\n const prepare = async () => {\n const { initLocalLanguage } = await import('./utils/language');\n await initLocalLanguage();\n\n const appContext = api.useAppContext();\n const { fs, dotenv } = await import('@modern-js/utils');\n dotenv.config();\n // remove '/node_modules/.modern-js'\n await fs.emptydir(appContext.internalDirectory);\n\n const hookRunners = api.useHookRunners();\n await hookRunners.addRuntimeExports();\n\n const { addExitListener } = await import('./utils/onExit');\n await addExitListener(async () => {\n await hookRunners.afterDev();\n });\n };\n\n const validateSchema = async () => {\n const { schema, legacySchema } = await import('./config/schema');\n const { isLegacyUserConfig } = await import('./utils/config');\n const userConfig = api.useConfigContext();\n return isLegacyUserConfig(userConfig as { legacy?: boolean })\n ? legacySchema\n : schema;\n };\n\n return {\n prepare,\n validateSchema,\n async commands({ program }) {\n const { buildCommand, devCommand, newCommand, upgradCommand } =\n await import('./command');\n await buildCommand(program, api);\n await devCommand(program, api);\n await newCommand(program);\n await upgradCommand(program);\n },\n };\n};\n"]}
|
package/dist/command.js
CHANGED
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -146,3 +150,5 @@ const upgradCommand = (program) => __async(void 0, null, function* () {
|
|
|
146
150
|
newCommand,
|
|
147
151
|
upgradCommand
|
|
148
152
|
});
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,eAAe,CAC1B,SACA,QACG;A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,iBAAiB,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,IAAI,CAAC,EACvE,OAAO,cAAc,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,QAAQ,CAAC,EACxE,OAAO,CAAM,YAAW;AACvB,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,uBAAuB;AAChE,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,UAAM,SAAS,kBAAkB;AAEjC,UAAM,gBAAgB,iCAAK,UAAL,EAAc,QAAQ,QAAQ,QAAQ,OAAO,EAAC;AAAA,EACtE,EAAC;AACL;AAEO,MAAM,gBAAgB,CAAO,YAAqB;AACvD,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO,oBAAoB;AAC3D,gBAAc,QAAQ,QAAQ,SAAS,CAAC;AAC1C;;;;;;;;","names":[],"sources":["../src/command.ts"],"sourcesContent":["import type { Command } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.noClear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.dev.tsconfig),\n defaultTsConfigPath,\n )\n .action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n\n // TODO: watch build\n // const { ensureFirstBuild, watchBuild } = await import('./dev');\n // await ensureFirstBuild(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 // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--lang <lang>', local.i18n.t(local.localeKeys.command.new.lang))\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import('./utils/language');\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale: options.lang || locale });\n });\n};\n\nexport const upgradCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(program.command('upgrade'));\n};\n"]}
|