@modern-js/module-tools 2.5.0-beta.0 → 2.5.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/README.md +5 -5
- package/dist/builder/build.js +2 -0
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/dts/rollup.js +4 -1
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +2 -0
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +5 -3
- package/dist/builder/index.js.map +1 -1
- package/dist/constants/log.d.ts +3 -1
- package/dist/constants/log.js +8 -2
- package/dist/constants/log.js.map +1 -1
- package/dist/utils/print.d.ts +14 -0
- package/dist/utils/print.js +160 -0
- package/dist/utils/print.js.map +1 -0
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0bbc91a: support sideEffects config and change log level to info
|
|
8
|
+
支持 sideEffects 配置并将日志级别改为 info
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 59172e9: feat: report size and info after build
|
|
13
|
+
feat: 构建后报告文件大小和信息
|
|
14
|
+
- 138a6b5: chore: update README and description of module-tools packages
|
|
15
|
+
|
|
16
|
+
chore: 更新 module-tools 相关包的 README 和 description
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [89ca6cc]
|
|
19
|
+
- Updated dependencies [30614fa]
|
|
20
|
+
- Updated dependencies [1b0ce87]
|
|
21
|
+
- Updated dependencies [11c053b]
|
|
22
|
+
- Updated dependencies [577084d]
|
|
23
|
+
- @modern-js/plugin-changeset@2.5.0
|
|
24
|
+
- @modern-js/plugin-i18n@2.5.0
|
|
25
|
+
- @modern-js/plugin-lint@2.5.0
|
|
26
|
+
- @modern-js/new-action@2.5.0
|
|
27
|
+
- @modern-js/plugin@2.5.0
|
|
28
|
+
- @modern-js/core@2.5.0
|
|
29
|
+
- @modern-js/utils@2.5.0
|
|
30
|
+
- @modern-js/upgrade@2.5.0
|
|
31
|
+
|
|
3
32
|
## 2.4.0
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<h1 align="center">Modern.js</h1>
|
|
5
|
+
<h1 align="center">Modern.js Module Tools</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
|
|
8
|
+
Simple, powerful, high-performance modern npm package development solution.
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
## Getting Started
|
|
12
12
|
|
|
13
|
-
Please follow [Quick Start](https://modernjs.dev/en/
|
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/module-tools/en/guide/intro/getting-started.html) to get started with Modern.js Module Tools.
|
|
14
14
|
|
|
15
15
|
## Documentation
|
|
16
16
|
|
|
17
|
-
- [English Documentation](https://modernjs.dev/en
|
|
18
|
-
- [中文文档](https://modernjs.dev)
|
|
17
|
+
- [English Documentation](https://modernjs.dev/module-tools/en)
|
|
18
|
+
- [中文文档](https://modernjs.dev/module-tools/)
|
|
19
19
|
|
|
20
20
|
## Contributing
|
|
21
21
|
|
package/dist/builder/build.js
CHANGED
|
@@ -237,12 +237,14 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
237
237
|
};
|
|
238
238
|
try {
|
|
239
239
|
const { Libuilder } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild")));
|
|
240
|
+
const { addOutputChunk } = yield Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
240
241
|
const runner = api.useHookRunners();
|
|
241
242
|
const modifiedBuildConfig = yield runner.modifyLibuild(buildConfig, {
|
|
242
243
|
onLast: (c) => c
|
|
243
244
|
});
|
|
244
245
|
const builder = yield Libuilder.create(modifiedBuildConfig);
|
|
245
246
|
yield builder.build();
|
|
247
|
+
addOutputChunk(builder.outputChunk, root, buildType === "bundle");
|
|
246
248
|
if (watch) {
|
|
247
249
|
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../utils/log")));
|
|
248
250
|
const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,QAAQ,IAAI;AACjC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AAEA,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO;AAClC,QAAM,SAAS,aAAa,EAAE,aAAa,CAAC;AAC9C;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAvCL;AAwCE,QAAM,EAAE,aAAa,gBAAgB,IAAI;AACzC,QAAM,MAAM,gBAAgB,MAAM,YAAY,MAAM;AACpD,QAAM,eAAe,YAAY,MAAM,YAAY,IAAI,OAAO;AAC9D,QAAM,SAAQ,qBAAgB,UAAhB,YAAyB;AAEvC,MAAI,QAAQ,OAAO;AAEjB,KAAC,iBAAiB,MAAM,SAAS,aAAa,KAAK,EAAE,MAAM,CAAC;AAAA,EAC9D,OAAO;AACL,UAAM,QAA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Y,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,cAAQ;AAAA,QACN,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["options"],"sources":["../../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\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\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"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,QAAQ,IAAI;AACjC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AAEA,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO;AAClC,QAAM,SAAS,aAAa,EAAE,aAAa,CAAC;AAC9C;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAvCL;AAwCE,QAAM,EAAE,aAAa,gBAAgB,IAAI;AACzC,QAAM,MAAM,gBAAgB,MAAM,YAAY,MAAM;AACpD,QAAM,eAAe,YAAY,MAAM,YAAY,IAAI,OAAO;AAC9D,QAAM,SAAQ,qBAAgB,UAAhB,YAAyB;AAEvC,MAAI,QAAQ,OAAO;AAEjB,KAAC,iBAAiB,MAAM,SAAS,aAAa,KAAK,EAAE,MAAM,CAAC;AAAA,EAC9D,OAAO;AACL,UAAM,QAAQ,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,UAAU,YAAY;AACjE,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,6CAAO;AACvC,UAAM,KAAK,OAAO,CAAM,SAAQ;AAC9B,YAAM,KAAK,aAAa,KAAY,EAAE,OAAO,IAAI,CAAC;AAAA,IACpD,EAAC;AA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A,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["options"],"sources":["../../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"]}
|
|
@@ -141,8 +141,11 @@ const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDi
|
|
|
141
141
|
} else {
|
|
142
142
|
try {
|
|
143
143
|
const { rollup } = yield Promise.resolve().then(() => __toESM(require("../../../compiled/rollup")));
|
|
144
|
+
const { addRollupChunk } = yield Promise.resolve().then(() => __toESM(require("../../utils/print")));
|
|
144
145
|
const bundle = yield rollup(inputConfig);
|
|
145
|
-
yield bundle.write(outputConfig);
|
|
146
|
+
const rollupOutput = yield bundle.write(outputConfig);
|
|
147
|
+
const { appDirectory } = api.useAppContext();
|
|
148
|
+
addRollupChunk(rollupOutput, appDirectory, outputConfig.dir);
|
|
146
149
|
return bundle;
|
|
147
150
|
} catch (e) {
|
|
148
151
|
if (e instanceof Error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAwBV,MAAM,YAAY,CACvB,IACA,OACG,iBAFH,IACA,KACG,WAFH,KACA,EAAE,SAAS,cAAc,WAAW,OAAO,MAAM,GAC9C;AACH,QAAM,cAAsB;AAAA,IAC1B,MAAM;AAAA,IACN,KAAK,IAAI;AACP,UAAI,CAAC,kCAAkC,KAAK,EAAE,GAAG;AAC/C,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,KAAK,MAAM,6CAAO;AACxB,QAAM,aAAa,GAAG,eAAe,cAAc,GAAG,IAAI,QAAQ;AAClE,QAAM,EAAE,QAAQ,IAAI,GAAG;AAAA,IACrB,WAAW;AAAA,IACX,GAAG;AAAA,IACH;AAAA,EACF;AAEA,QAAM,E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M,OAAO,MAAM,YAAY;AACpD,YAAM,EAAE,aAAa,IAAI,IAAI,cAAc;AAC3C,qBAAe,cAAc,cAAc,aAAa,GAAI;AAC5D,aAAO;AAAA,IACT,SAAS,GAAP;AACA,UAAI,aAAa,OAAO;AACtB,cAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO;AAC1C,cAAM,IAAI,iBAAiB,GAAG;AAAA,UAC5B,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;;;","names":["watch"],"sources":["../../../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 // 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 }),\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
|
@@ -143,8 +143,10 @@ const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
|
143
143
|
});
|
|
144
144
|
const runTsc = (api, config) => __async(void 0, null, function* () {
|
|
145
145
|
const { resolveAlias } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
146
|
+
const { addDtsFiles } = yield Promise.resolve().then(() => __toESM(require("../../utils/print")));
|
|
146
147
|
const result = yield generatorDts(api, config);
|
|
147
148
|
yield resolveAlias(config, result);
|
|
149
|
+
yield addDtsFiles(config.distAbsPath, config.appDirectory);
|
|
148
150
|
});
|
|
149
151
|
// Annotate the CommonJS export names for ESM import in node:
|
|
150
152
|
0 && (module.exports = {
|
|
@@ -1 +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;AACnC,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;AAEF,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO;AAOvC,sBAAc,WAAd,mBAAsB,GAAG,QAAQ,CAAM,SAAQ;AAC7C,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,MAAM,kBAAkB,wBAAwB,mBAAmB,GAAG;AAAA,MACxE;AACA,cAAQ,KAAK,KAAK,SAAS,CAAC;AAC5B,UAAI,KAAK,SAAS,EAAE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AAE,aAAa,IAAI,MAAM,6CAAO;AACtC,QAAM,EAAE,YAAY,IAAI,MAAM,6CAAO;AACrC,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
|
@@ -52,9 +52,7 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
52
52
|
const runner = api.useHookRunners();
|
|
53
53
|
let totalDuration = 0;
|
|
54
54
|
if (resolvedBuildConfig.length !== 0) {
|
|
55
|
-
const { buildSuccessText } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
56
55
|
totalDuration = Date.now();
|
|
57
|
-
!cmdOptions.watch && console.time(buildSuccessText);
|
|
58
56
|
const { runBuildTask } = yield Promise.resolve().then(() => __toESM(require("./build")));
|
|
59
57
|
const { default: pMap } = yield Promise.resolve().then(() => __toESM(require("../../compiled/p-map")));
|
|
60
58
|
const { clearBuildConfigPaths, clearDtsTemp } = yield Promise.resolve().then(() => __toESM(require("./clear")));
|
|
@@ -76,7 +74,6 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
76
74
|
);
|
|
77
75
|
yield runner.afterBuildTask({ status: "success", config });
|
|
78
76
|
}));
|
|
79
|
-
!cmdOptions.watch && console.timeEnd(buildSuccessText);
|
|
80
77
|
} catch (e) {
|
|
81
78
|
const { isInternalError, ModuleBuildError } = yield Promise.resolve().then(() => __toESM(require("../error")));
|
|
82
79
|
if (isInternalError(e)) {
|
|
@@ -86,6 +83,11 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
totalDuration = Date.now() - totalDuration;
|
|
86
|
+
if (!cmdOptions.watch) {
|
|
87
|
+
const { printFileSize, printSucceed } = yield Promise.resolve().then(() => __toESM(require("../utils/print")));
|
|
88
|
+
printSucceed(totalDuration);
|
|
89
|
+
printFileSize();
|
|
90
|
+
}
|
|
89
91
|
} else {
|
|
90
92
|
console.warn(
|
|
91
93
|
chalk.yellow(
|
|
@@ -1 +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;AAC/B,QAAM,EAAE,qBAAqB,SAAS,WAAW,IAAI;AACrD,QAAM,SAAS,IAAI,eAAe;AAElC,MAAI,gBAAgB;AAEpB,MAAI,oBAAoB,WAAW,GAAG;AACpC,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,MAAM,C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;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/constants/log.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export declare enum SectionTitleStatus {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const BundleDtsLogPrefix = "[Bundle:DTS]";
|
|
7
7
|
export declare const BundlelessDtsLogPrefix = "[Bundleless:DTS]";
|
|
8
|
-
export declare const buildSuccessText = "Build succeed";
|
|
8
|
+
export declare const buildSuccessText = "Build succeed";
|
|
9
|
+
export declare const reportFile1LineText = "Bundle Files";
|
|
10
|
+
export declare const reportFile2LineText = "Size";
|
package/dist/constants/log.js
CHANGED
|
@@ -20,7 +20,9 @@ __export(log_exports, {
|
|
|
20
20
|
BundleDtsLogPrefix: () => BundleDtsLogPrefix,
|
|
21
21
|
BundlelessDtsLogPrefix: () => BundlelessDtsLogPrefix,
|
|
22
22
|
SectionTitleStatus: () => SectionTitleStatus,
|
|
23
|
-
buildSuccessText: () => buildSuccessText
|
|
23
|
+
buildSuccessText: () => buildSuccessText,
|
|
24
|
+
reportFile1LineText: () => reportFile1LineText,
|
|
25
|
+
reportFile2LineText: () => reportFile2LineText
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(log_exports);
|
|
26
28
|
var SectionTitleStatus = /* @__PURE__ */ ((SectionTitleStatus2) => {
|
|
@@ -32,12 +34,16 @@ var SectionTitleStatus = /* @__PURE__ */ ((SectionTitleStatus2) => {
|
|
|
32
34
|
const BundleDtsLogPrefix = "[Bundle:DTS]";
|
|
33
35
|
const BundlelessDtsLogPrefix = "[Bundleless:DTS]";
|
|
34
36
|
const buildSuccessText = "Build succeed";
|
|
37
|
+
const reportFile1LineText = "Bundle Files";
|
|
38
|
+
const reportFile2LineText = "Size";
|
|
35
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
40
|
0 && (module.exports = {
|
|
37
41
|
BundleDtsLogPrefix,
|
|
38
42
|
BundlelessDtsLogPrefix,
|
|
39
43
|
SectionTitleStatus,
|
|
40
|
-
buildSuccessText
|
|
44
|
+
buildSuccessText,
|
|
45
|
+
reportFile1LineText,
|
|
46
|
+
reportFile2LineText
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
//# sourceMappingURL=log.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,qBAAL,kBAAKA,wBAAL;AACL;AACA;AACA;AAHU;AAAA;AAML,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;","names":["SectionTitleStatus"],"sources":["../../src/constants/log.ts"],"sourcesContent":["export enum SectionTitleStatus {\n Success,\n Fail,\n Log,\n}\n\nexport const BundleDtsLogPrefix = '[Bundle:DTS]';\nexport const BundlelessDtsLogPrefix = '[Bundleless:DTS]';\nexport const buildSuccessText = 'Build succeed';\n"]}
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,qBAAL,kBAAKA,wBAAL;AACL;AACA;AACA;AAHU;AAAA;AAML,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AAEzB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;","names":["SectionTitleStatus"],"sources":["../../src/constants/log.ts"],"sourcesContent":["export enum SectionTitleStatus {\n Success,\n Fail,\n Log,\n}\n\nexport const BundleDtsLogPrefix = '[Bundle:DTS]';\nexport const BundlelessDtsLogPrefix = '[Bundleless:DTS]';\nexport const buildSuccessText = 'Build succeed';\n\nexport const reportFile1LineText = 'Bundle Files';\nexport const reportFile2LineText = 'Size';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ILibuilder } from '@modern-js/libuild';
|
|
2
|
+
import type { RollupOutput } from '../../compiled/rollup/types/rollup';
|
|
3
|
+
type Files = {
|
|
4
|
+
name: string;
|
|
5
|
+
size: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const bundleFiles: Files[];
|
|
8
|
+
export declare const bundlelessFiles: Files[];
|
|
9
|
+
export declare const addOutputChunk: (outputChunk: ILibuilder['outputChunk'], appDirectory: string, isBundle: boolean) => void;
|
|
10
|
+
export declare const addRollupChunk: (rollupOutput: RollupOutput, appDirectory: string, distDir: string) => void;
|
|
11
|
+
export declare const addDtsFiles: (distDir: string, appDirectory: string) => Promise<void>;
|
|
12
|
+
export declare const printFileSize: () => void;
|
|
13
|
+
export declare const printSucceed: (totalDuration: number) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve2, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var print_exports = {};
|
|
45
|
+
__export(print_exports, {
|
|
46
|
+
addDtsFiles: () => addDtsFiles,
|
|
47
|
+
addOutputChunk: () => addOutputChunk,
|
|
48
|
+
addRollupChunk: () => addRollupChunk,
|
|
49
|
+
bundleFiles: () => bundleFiles,
|
|
50
|
+
bundlelessFiles: () => bundlelessFiles,
|
|
51
|
+
printFileSize: () => printFileSize,
|
|
52
|
+
printSucceed: () => printSucceed
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(print_exports);
|
|
55
|
+
var import_path = require("path");
|
|
56
|
+
var import_utils = require("@modern-js/utils");
|
|
57
|
+
var import_log = require("../constants/log");
|
|
58
|
+
const bundleFiles = [];
|
|
59
|
+
const bundlelessFiles = [];
|
|
60
|
+
const addOutputChunk = (outputChunk, appDirectory, isBundle) => {
|
|
61
|
+
const files = Array.from(outputChunk).map((val) => {
|
|
62
|
+
const [path, chunk] = val;
|
|
63
|
+
return {
|
|
64
|
+
name: (0, import_path.relative)(appDirectory, path),
|
|
65
|
+
size: chunk.contents.length
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
if (isBundle) {
|
|
69
|
+
bundleFiles.push(...files);
|
|
70
|
+
} else {
|
|
71
|
+
bundlelessFiles.push(...files);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const addRollupChunk = (rollupOutput, appDirectory, distDir) => {
|
|
75
|
+
const { output } = rollupOutput;
|
|
76
|
+
bundleFiles.push(
|
|
77
|
+
...output.map((o) => {
|
|
78
|
+
return {
|
|
79
|
+
name: (0, import_path.relative)(appDirectory, (0, import_path.resolve)(distDir, o.fileName)),
|
|
80
|
+
size: o.code.length
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
const addDtsFiles = (distDir, appDirectory) => __async(void 0, null, function* () {
|
|
86
|
+
const { fastGlob, slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
87
|
+
const files = yield fastGlob(`${slash(distDir)}**/*.d.ts`, {
|
|
88
|
+
stats: true
|
|
89
|
+
});
|
|
90
|
+
bundlelessFiles.push(
|
|
91
|
+
...files.map((file) => {
|
|
92
|
+
return {
|
|
93
|
+
name: (0, import_path.relative)(appDirectory, file.path),
|
|
94
|
+
size: file.stats.size
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
const printFileSize = () => {
|
|
100
|
+
printBundlelessInfo();
|
|
101
|
+
printBundleFiles();
|
|
102
|
+
};
|
|
103
|
+
const printSucceed = (totalDuration) => {
|
|
104
|
+
import_utils.logger.info(
|
|
105
|
+
import_utils.chalk.bold(import_utils.chalk.blue(`${import_log.buildSuccessText}: ${totalDuration / 1e3}s`))
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
const prettyBytes = (bytes) => {
|
|
109
|
+
if (bytes === 0) {
|
|
110
|
+
return "0 B";
|
|
111
|
+
}
|
|
112
|
+
const unit = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
113
|
+
const exp = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
114
|
+
return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;
|
|
115
|
+
};
|
|
116
|
+
const printBundleFiles = () => {
|
|
117
|
+
if (bundleFiles.length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const longestFileLength = bundleFiles.reduce(
|
|
121
|
+
(max, str) => Math.max(max, str.name.length),
|
|
122
|
+
import_log.reportFile1LineText.length
|
|
123
|
+
);
|
|
124
|
+
const info = `Bundle generated ${bundleFiles.length} files
|
|
125
|
+
`;
|
|
126
|
+
const headerRow = import_log.reportFile1LineText + " ".repeat(longestFileLength - 10) + import_log.reportFile2LineText;
|
|
127
|
+
import_utils.logger.info(import_utils.chalk.bold(import_utils.chalk.blue(info)));
|
|
128
|
+
import_utils.logger.log(import_utils.chalk.bold(import_utils.chalk.green(headerRow)));
|
|
129
|
+
bundleFiles.forEach(({ name, size }) => {
|
|
130
|
+
const infoRow = `${name}${" ".repeat(
|
|
131
|
+
longestFileLength - name.length + 2
|
|
132
|
+
)}${prettyBytes(size)}`;
|
|
133
|
+
import_utils.logger.log(infoRow);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const printBundlelessInfo = () => {
|
|
137
|
+
if (bundlelessFiles.length === 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const count = bundlelessFiles.length;
|
|
141
|
+
const totalSize = bundlelessFiles.reduce((total, file) => {
|
|
142
|
+
return total + file.size;
|
|
143
|
+
}, 0);
|
|
144
|
+
const info = `Bundleless generated ${count} files, the total size is ${prettyBytes(
|
|
145
|
+
totalSize
|
|
146
|
+
)}`;
|
|
147
|
+
import_utils.logger.info(import_utils.chalk.bold(import_utils.chalk.blue(info)));
|
|
148
|
+
};
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
addDtsFiles,
|
|
152
|
+
addOutputChunk,
|
|
153
|
+
addRollupChunk,
|
|
154
|
+
bundleFiles,
|
|
155
|
+
bundlelessF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,IAAI,OAAO;AAAA,EACpB,CAAC;AACH;AAEA,MAAM,sBAAsB,MAAM;AAChC,MAAI,gBAAgB,WAAW,GAAG;AAChC;AAAA,EACF;AAEA,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,YAAY,gBAAgB,OAAO,CAAC,OAAO,SAAS;AACxD,WAAO,QAAQ,KAAK;AAAA,EACtB,GAAG,CAAC;AACJ,QAAM,OAAO,wBAAwB,kCAAkC;AAAA,IACrE;AAAA,EACF;AACA,sBAAO,KAAK,mBAAM,KAAK,mBAAM,KAAK,IAAI,CAAC,CAAC;AAC1C;;;;;;;;;;;","names":[],"sources":["../../src/utils/print.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport type { ILibuilder } from '@modern-js/libuild';\nimport { chalk, logger } from '@modern-js/utils';\nimport type {\n RollupOutput,\n OutputChunk,\n} from '../../compiled/rollup/types/rollup';\nimport {\n buildSuccessText,\n reportFile1LineText,\n reportFile2LineText,\n} from '../constants/log';\n\ntype Files = {\n name: string;\n size: number;\n};\n\nexport const bundleFiles: Files[] = [];\n\nexport const bundlelessFiles: Files[] = [];\n\nexport const addOutputChunk = (\n outputChunk: ILibuilder['outputChunk'],\n appDirectory: string,\n isBundle: boolean,\n) => {\n const files = Array.from(outputChunk).map(val => {\n const [path, chunk] = val;\n return {\n name: relative(appDirectory, path),\n size: chunk.contents.length,\n };\n });\n if (isBundle) {\n bundleFiles.push(...files);\n } else {\n bundlelessFiles.push(...files);\n }\n};\n\nexport const addRollupChunk = (\n rollupOutput: RollupOutput,\n appDirectory: string,\n distDir: string,\n) => {\n const { output } = rollupOutput;\n bundleFiles.push(\n ...output.map(o => {\n return {\n name: relative(appDirectory, resolve(distDir, o.fileName)),\n // only d.ts, is outputChunk not outputAsset\n size: (o as OutputChunk).code.length,\n };\n }),\n );\n};\n\nexport const addDtsFiles = async (distDir: string, appDirectory: string) => {\n const { fastGlob, slash } = await import('@modern-js/utils');\n const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {\n stats: true,\n });\n bundlelessFiles.push(\n ...files.map(file => {\n return {\n name: relative(appDirectory, file.path),\n size: file.stats.size,\n };\n }),\n );\n};\n\nexport const printFileSize = () => {\n printBundlelessInfo();\n printBundleFiles();\n};\n\nexport const printSucceed = (totalDuration: number) => {\n logger.info(\n chalk.bold(chalk.blue(`${buildSuccessText}: ${totalDuration / 1000}s`)),\n );\n};\n\nconst prettyBytes = (bytes: number) => {\n if (bytes === 0) {\n return '0 B';\n }\n const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const exp = Math.floor(Math.log(bytes) / Math.log(1024));\n return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;\n};\n\nconst printBundleFiles = () => {\n if (bundleFiles.length === 0) {\n return;\n }\n const longestFileLength = bundleFiles.reduce(\n (max, str) => Math.max(max, str.name.length),\n reportFile1LineText.length,\n );\n const info = `Bundle generated ${bundleFiles.length} files\\n`;\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n\n logger.info(chalk.bold(chalk.blue(info)));\n logger.log(chalk.bold(chalk.green(headerRow)));\n\n bundleFiles.forEach(({ name, size }) => {\n const infoRow = `${name}${' '.repeat(\n longestFileLength - name.length + 2,\n )}${prettyBytes(size)}`;\n logger.log(infoRow);\n });\n};\n\nconst printBundlelessInfo = () => {\n if (bundlelessFiles.length === 0) {\n return;\n }\n\n const count = bundlelessFiles.length;\n const totalSize = bundlelessFiles.reduce((total, file) => {\n return total + file.size;\n }, 0);\n const info = `Bundleless generated ${count} files, the total size is ${prettyBytes(\n totalSize,\n )}`;\n logger.info(chalk.bold(chalk.blue(info)));\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
-
"description": "
|
|
4
|
-
"homepage": "https://modernjs.dev",
|
|
3
|
+
"description": "Simple, powerful, high-performance modern npm package development solution.",
|
|
4
|
+
"homepage": "https://modernjs.dev/module-tools",
|
|
5
5
|
"bugs": "https://github.com/modern-js-dev/modern.js/issues",
|
|
6
6
|
"repository": "modern-js-dev/modern.js",
|
|
7
7
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.5.0
|
|
14
|
+
"version": "2.5.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -39,17 +39,16 @@
|
|
|
39
39
|
"@modern-js/libuild": "~0.10.0",
|
|
40
40
|
"@modern-js/libuild-plugin-svgr": "~0.10.0",
|
|
41
41
|
"@modern-js/libuild-plugin-swc": "~0.10.0",
|
|
42
|
-
"@modern-js/core": "2.
|
|
43
|
-
"@modern-js/
|
|
44
|
-
"@modern-js/
|
|
45
|
-
"@modern-js/
|
|
46
|
-
"@modern-js/
|
|
47
|
-
"@modern-js/utils": "2.
|
|
48
|
-
"@modern-js/plugin-changeset": "2.
|
|
49
|
-
"@modern-js/plugin-lint": "2.
|
|
42
|
+
"@modern-js/core": "2.5.0",
|
|
43
|
+
"@modern-js/new-action": "2.5.0",
|
|
44
|
+
"@modern-js/plugin": "2.5.0",
|
|
45
|
+
"@modern-js/plugin-i18n": "2.5.0",
|
|
46
|
+
"@modern-js/upgrade": "2.5.0",
|
|
47
|
+
"@modern-js/utils": "2.5.0",
|
|
48
|
+
"@modern-js/plugin-changeset": "2.5.0",
|
|
49
|
+
"@modern-js/plugin-lint": "2.5.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@modern-js/self": "npm:@modern-js/module-tools@*",
|
|
53
52
|
"@types/jest": "^27",
|
|
54
53
|
"@types/node": "^14",
|
|
55
54
|
"@types/fs-extra": "9.0.13",
|
|
@@ -60,9 +59,10 @@
|
|
|
60
59
|
"postcss-alias": "2.0.0",
|
|
61
60
|
"react": "17",
|
|
62
61
|
"typescript": "^4",
|
|
63
|
-
"@modern-js/
|
|
64
|
-
"@
|
|
65
|
-
"@scripts/jest-config": "2.
|
|
62
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.5.0",
|
|
63
|
+
"@modern-js/builder-webpack-provider": "2.5.0",
|
|
64
|
+
"@scripts/jest-config": "2.5.0",
|
|
65
|
+
"@scripts/build": "2.5.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/",
|