@modern-js/module-tools 2.10.1-beta.1 → 2.10.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/build.js +7 -4
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/copy.js +5 -4
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.d.ts +4 -2
- package/dist/builder/dts/rollup.js +14 -10
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +13 -12
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +3 -2
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +13 -12
- package/dist/builder/platform.js.map +1 -1
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +2 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/constants/build.d.ts +0 -3
- package/dist/constants/build.js +2 -11
- package/dist/constants/build.js.map +1 -1
- package/dist/dev.js +3 -2
- package/dist/dev.js.map +1 -1
- package/dist/locale/en.d.ts +3 -0
- package/dist/locale/en.js +5 -3
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +6 -0
- package/dist/locale/zh.d.ts +3 -0
- package/dist/locale/zh.js +5 -3
- package/dist/locale/zh.js.map +1 -1
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/dts.d.ts +1 -0
- package/dist/types/dts.js.map +1 -1
- package/dist/utils/builder.js +2 -1
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/dts.d.ts +6 -2
- package/dist/utils/dts.js +30 -2
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/libuildPlugins.js +2 -3
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +3 -7
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/print.js +7 -9
- package/dist/utils/print.js.map +1 -1
- package/package.json +5 -5
package/dist/builder/build.js
CHANGED
|
@@ -72,6 +72,7 @@ __export(build_exports, {
|
|
|
72
72
|
});
|
|
73
73
|
module.exports = __toCommonJS(build_exports);
|
|
74
74
|
var import_path = require("path");
|
|
75
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
75
76
|
const runBuildTask = (options, api) => __async(void 0, null, function* () {
|
|
76
77
|
const { buildConfig, context, buildCmdOptions } = options;
|
|
77
78
|
const { appDirectory, isTsProject } = context;
|
|
@@ -114,7 +115,7 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
114
115
|
const { watch, dts } = options;
|
|
115
116
|
const { buildType, input, sourceDir, alias } = config;
|
|
116
117
|
const { appDirectory } = api.useAppContext();
|
|
117
|
-
const { tsconfigPath, distPath } = dts;
|
|
118
|
+
const { tsconfigPath, distPath, abortOnError } = dts;
|
|
118
119
|
if (buildType === "bundle") {
|
|
119
120
|
const { getFinalExternals } = yield Promise.resolve().then(() => __toESM(require("../utils/builder")));
|
|
120
121
|
const finalExternals = yield getFinalExternals(config, { appDirectory });
|
|
@@ -123,7 +124,8 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
123
124
|
watch,
|
|
124
125
|
externals: finalExternals,
|
|
125
126
|
input,
|
|
126
|
-
tsconfigPath
|
|
127
|
+
tsconfigPath,
|
|
128
|
+
abortOnError
|
|
127
129
|
});
|
|
128
130
|
} else {
|
|
129
131
|
yield runTsc(api, {
|
|
@@ -132,7 +134,8 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
132
134
|
distAbsPath: distPath,
|
|
133
135
|
watch,
|
|
134
136
|
tsconfigPath,
|
|
135
|
-
sourceDir
|
|
137
|
+
sourceDir,
|
|
138
|
+
abortOnError
|
|
136
139
|
});
|
|
137
140
|
}
|
|
138
141
|
});
|
|
@@ -254,7 +257,7 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
254
257
|
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../utils/log")));
|
|
255
258
|
const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
256
259
|
const titleText = `[${buildType === "bundle" ? "Bundle" : "Bundleless"}: ${format}_${target}]`;
|
|
257
|
-
|
|
260
|
+
import_logger.logger.info(
|
|
258
261
|
yield watchSectionTitle(titleText, SectionTitleStatus.Success)
|
|
259
262
|
);
|
|
260
263
|
}
|
|
@@ -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,SAAS,gBAAgB,IAAI;AAClD,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO,QAAQ;AAC1C,QAAM,SAAS,aAAa,EAAE,cAAc,OAAO,gBAAgB,MAAM,CAAC;AAE1E,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AACF;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,sBAAsB;AAC7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AM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,YAAM,YAAY,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,UAAU;AACtD,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, buildCmdOptions } = options;\n const { appDirectory, isTsProject } = context;\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\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/libuildPlugins'\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"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAAuB;AAWhB,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,SAAS,gBAAgB,IAAI;AAClD,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO,QAAQ;AAC1C,QAAM,SAAS,aAAa,EAAE,cAAc,OAAO,gBAAgB,MAAM,CAAC;AAE1E,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AACF;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAxCL;AAyCE,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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AM,QAAQ,MAAM;AACpB,mBAAe,QAAQ,aAAa,MAAM,cAAc,QAAQ;AAEhE,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,cAAc;AACzD,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,2BAAO;AAAA,QACL,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,UAAU;AACtD,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 { logger } from '@modern-js/utils/logger';\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, buildCmdOptions } = options;\n const { appDirectory, isTsProject } = context;\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory, watch: buildCmdOptions.watch });\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\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, abortOnError } = 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 abortOnError,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n abortOnError,\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/libuildPlugins'\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 logger.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/copy.js
CHANGED
|
@@ -70,6 +70,7 @@ __export(copy_exports, {
|
|
|
70
70
|
});
|
|
71
71
|
module.exports = __toCommonJS(copy_exports);
|
|
72
72
|
var import_path = __toESM(require("path"));
|
|
73
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
73
74
|
const watchMap = /* @__PURE__ */ new Map();
|
|
74
75
|
const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
75
76
|
var _a;
|
|
@@ -173,7 +174,7 @@ const runPatterns = (pattern, options) => __async(void 0, null, function* () {
|
|
|
173
174
|
}));
|
|
174
175
|
});
|
|
175
176
|
const watchCopyFiles = (options, copyConfig) => __async(void 0, null, function* () {
|
|
176
|
-
const { watch, fs, logger, createDebugger } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
177
|
+
const { watch, fs, logger: logger2, createDebugger } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
177
178
|
const debug = createDebugger("module-tools:copy-watch");
|
|
178
179
|
debug("watchMap", watchMap);
|
|
179
180
|
const { SectionTitleStatus, CopyLogPrefix } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
|
|
@@ -189,7 +190,7 @@ const watchCopyFiles = (options, copyConfig) => __async(void 0, null, function*
|
|
|
189
190
|
const formatFilePath = import_path.default.relative(options.appDirectory, changedFilePath);
|
|
190
191
|
if (changeType === "unlink") {
|
|
191
192
|
fs.remove(result);
|
|
192
|
-
|
|
193
|
+
logger2.log(
|
|
193
194
|
yield watchSectionTitle(
|
|
194
195
|
CopyLogPrefix,
|
|
195
196
|
SectionTitleStatus.Log,
|
|
@@ -203,7 +204,7 @@ const watchCopyFiles = (options, copyConfig) => __async(void 0, null, function*
|
|
|
203
204
|
} else {
|
|
204
205
|
yield fs.copy(changedFilePath, result);
|
|
205
206
|
}
|
|
206
|
-
|
|
207
|
+
logger2.log(
|
|
207
208
|
yield watchSectionTitle(
|
|
208
209
|
CopyLogPrefix,
|
|
209
210
|
SectionTitleStatus.Log,
|
|
@@ -235,7 +236,7 @@ const copyTask = (buildConfig, options) => __async(void 0, null, function* () {
|
|
|
235
236
|
);
|
|
236
237
|
} catch (e) {
|
|
237
238
|
if (e instanceof Error) {
|
|
238
|
-
|
|
239
|
+
import_logger.logger.error(`copy error: ${e.message}`);
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
242
|
if (options.watch) {
|
package/dist/builder/copy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAIjB,MAAM,WAAW,oBAAI,IAAoB;AAElC,MAAM,cAAc,CACzB,SACA,YAOG;AAfL;AAgBE,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;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,QAAM,gBAAc,8CAAY,YAAZ,mBAAqB,gBAAe;AACxD,MAAI;AACF,UAAM;AAAA,MACJ,WAAW;AAAA,MACX,CAAM,eAAc;AA1N1B;AA2NQ,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;AACA,MAAI,QAAQ,OAAO;AACjB,UAAM,eAAe,SAAS,UAAU;AAAA,EAC1C;AACF;;;;;;;","names":["from","absoluteFrom","_a"],"sources":["../../src/builder/copy.ts"],"sourcesContent":["import path from 'path';\nimport type { CopyOptions, CopyPattern } from '../types/copy';\nimport type { BaseBuildConfig } from '../types/config';\n\nconst watchMap = new Map<string, string>();\n\nexport const runPatterns = async (\n pattern: CopyPattern,\n options: {\n appDirectory: string;\n enableCopySync?: boolean;\n outDir: string;\n defaultContext: string;\n watch?: boolean;\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\n if (options.watch) {\n watchMap.set(absoluteFrom, absoluteTo);\n }\n\n if (enableCopySync) {\n fs.copySync(absoluteFrom, absoluteTo);\n } else {\n await fs.copy(absoluteFrom, absoluteTo);\n }\n });\n};\n\nexport const watchCopyFiles = async (\n options: {\n appDirectory: string;\n },\n copyConfig: CopyOptions,\n) => {\n const { watch, fs, logger, createDebugger } = await import(\n '@modern-js/utils'\n );\n const debug = createDebugger('module-tools:copy-watch');\n\n debug('watchMap', watchMap);\n\n const { SectionTitleStatus, CopyLogPrefix } = await import(\n '../constants/log'\n );\n const { watchSectionTitle } = await import('../utils/log');\n const watchList = Array.from(watchMap.keys());\n\n debug('watchList', watchList);\n\n watch(watchList, async ({ changedFilePath, changeType }) => {\n const result = watchMap.get(changedFilePath);\n if (!result) {\n return;\n }\n\n const formatFilePath = path.relative(options.appDirectory, changedFilePath);\n\n if (changeType === 'unlink') {\n fs.remove(result);\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} removed`,\n ),\n );\n return;\n }\n\n if (copyConfig?.options?.enableCopySync) {\n fs.copySync(changedFilePath, result);\n } else {\n await fs.copy(changedFilePath, result);\n }\n\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} changed`,\n ),\n );\n });\n};\n\nexport const copyTask = async (\n buildConfig: BaseBuildConfig,\n options: {\n appDirectory: string;\n watch?: boolean;\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 if (options.watch) {\n await watchCopyFiles(options, copyConfig);\n }\n};\n"]}
|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AAG,SAAS,iBAAiB,MAAM;AAAA,IACrC,OAAO;AACL,YAAM,GAAG,KAAK,iBAAiB,MAAM;AAAA,IACvC;AAEA,YAAO;AAAA,MACL,MAAM;AAAA,QACJ;AAAA,QACA,mBAAmB;AAAA,QACnB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF,EAAC;AACH;AAEO,MAAM,WAAW,CACtB,aACA,YAIG;AA/ML;AAgNE,QAAM,aAAa,YAAY;AAE/B,MAAI,CAAC,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;AA3N1B;AA4NQ,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,2BAAO,MAAM,eAAe,EAAE,SAAS;AAAA,IACzC;AAAA,EACF;AACA,MAAI,QAAQ,OAAO;AACjB,UAAM,eAAe,SAAS,UAAU;AAAA,EAC1C;AACF;;;;;;;","names":["from","absoluteFrom","_a"],"sources":["../../src/builder/copy.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type { CopyOptions, CopyPattern } from '../types/copy';\nimport type { BaseBuildConfig } from '../types/config';\n\nconst watchMap = new Map<string, string>();\n\nexport const runPatterns = async (\n pattern: CopyPattern,\n options: {\n appDirectory: string;\n enableCopySync?: boolean;\n outDir: string;\n defaultContext: string;\n watch?: boolean;\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\n if (options.watch) {\n watchMap.set(absoluteFrom, absoluteTo);\n }\n\n if (enableCopySync) {\n fs.copySync(absoluteFrom, absoluteTo);\n } else {\n await fs.copy(absoluteFrom, absoluteTo);\n }\n });\n};\n\nexport const watchCopyFiles = async (\n options: {\n appDirectory: string;\n },\n copyConfig: CopyOptions,\n) => {\n const { watch, fs, logger, createDebugger } = await import(\n '@modern-js/utils'\n );\n const debug = createDebugger('module-tools:copy-watch');\n\n debug('watchMap', watchMap);\n\n const { SectionTitleStatus, CopyLogPrefix } = await import(\n '../constants/log'\n );\n const { watchSectionTitle } = await import('../utils/log');\n const watchList = Array.from(watchMap.keys());\n\n debug('watchList', watchList);\n\n watch(watchList, async ({ changedFilePath, changeType }) => {\n const result = watchMap.get(changedFilePath);\n if (!result) {\n return;\n }\n\n const formatFilePath = path.relative(options.appDirectory, changedFilePath);\n\n if (changeType === 'unlink') {\n fs.remove(result);\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} removed`,\n ),\n );\n return;\n }\n\n if (copyConfig?.options?.enableCopySync) {\n fs.copySync(changedFilePath, result);\n } else {\n await fs.copy(changedFilePath, result);\n }\n\n logger.log(\n await watchSectionTitle(\n CopyLogPrefix,\n SectionTitleStatus.Log,\n `${formatFilePath} changed`,\n ),\n );\n });\n};\n\nexport const copyTask = async (\n buildConfig: BaseBuildConfig,\n options: {\n appDirectory: string;\n watch?: boolean;\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 logger.error(`copy error: ${e.message}`);\n }\n }\n if (options.watch) {\n await watchCopyFiles(options, copyConfig);\n }\n};\n"]}
|
|
@@ -7,11 +7,13 @@ type Config = {
|
|
|
7
7
|
externals: BaseBuildConfig['externals'];
|
|
8
8
|
input: Input;
|
|
9
9
|
watch: boolean;
|
|
10
|
+
abortOnError?: boolean;
|
|
10
11
|
};
|
|
11
12
|
export declare const runRollup: (api: PluginAPI<ModuleTools>, {
|
|
12
13
|
distDir,
|
|
13
14
|
tsconfigPath,
|
|
14
15
|
externals,
|
|
15
16
|
input,
|
|
16
|
-
watch
|
|
17
|
-
|
|
17
|
+
watch,
|
|
18
|
+
abortOnError
|
|
19
|
+
}: Config) => Promise<RollupWatcher | import("../../../compiled/rollup").RollupBuild | null>;
|
|
@@ -68,7 +68,15 @@ __export(rollup_exports, {
|
|
|
68
68
|
});
|
|
69
69
|
module.exports = __toCommonJS(rollup_exports);
|
|
70
70
|
var import_path = __toESM(require("path"));
|
|
71
|
-
|
|
71
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
72
|
+
const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, {
|
|
73
|
+
distDir,
|
|
74
|
+
tsconfigPath,
|
|
75
|
+
externals,
|
|
76
|
+
input,
|
|
77
|
+
watch,
|
|
78
|
+
abortOnError = true
|
|
79
|
+
}) {
|
|
72
80
|
const ignoreFiles = {
|
|
73
81
|
name: "ignore-files",
|
|
74
82
|
load(id) {
|
|
@@ -146,11 +154,11 @@ const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDi
|
|
|
146
154
|
output: outputConfig
|
|
147
155
|
})).on("event", (event) => __async(void 0, null, function* () {
|
|
148
156
|
if (event.code === "START") {
|
|
149
|
-
|
|
157
|
+
import_logger.logger.info(
|
|
150
158
|
yield watchSectionTitle(BundleDtsLogPrefix, SectionTitleStatus.Log)
|
|
151
159
|
);
|
|
152
160
|
} else if (event.code === "BUNDLE_END") {
|
|
153
|
-
|
|
161
|
+
import_logger.logger.info(
|
|
154
162
|
yield watchSectionTitle(
|
|
155
163
|
BundleDtsLogPrefix,
|
|
156
164
|
SectionTitleStatus.Success
|
|
@@ -171,13 +179,9 @@ const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDi
|
|
|
171
179
|
addRollupChunk(rollupOutput, appDirectory, outputConfig.dir);
|
|
172
180
|
return bundle;
|
|
173
181
|
} catch (e) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
buildType: "bundle"
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
throw e;
|
|
182
|
+
const { printOrThrowDtsErrors } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
183
|
+
yield printOrThrowDtsErrors(e, { abortOnError, buildType: "bundle" });
|
|
184
|
+
return null;
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
187
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,k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AAc,aAAa,GAAI;AAC5D,aAAO;AAAA,IACT,SAAS,GAAP;AACA,YAAM,EAAE,sBAAsB,IAAI,MAAM,6CAAO,iBAAiB;AAChE,YAAM,sBAAsB,GAAG,EAAE,cAAc,WAAW,SAAS,CAAC;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;;;","names":["watch"],"sources":["../../../src/builder/dts/rollup.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\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 abortOnError?: boolean;\n};\n\nexport const runRollup = async (\n api: PluginAPI<ModuleTools>,\n {\n distDir,\n tsconfigPath,\n externals,\n input,\n watch,\n abortOnError = true,\n }: 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 { transformUndefineObject } = await import('../../utils/common');\n\n const baseUrl = path.isAbsolute(options.baseUrl || '.')\n ? options.baseUrl\n : path.join(path.dirname(tsconfigPath), options.baseUrl || '.');\n const ignoreCompileOptions = [\n 'incremental',\n 'tsBuildInfoFile',\n 'sourceMap',\n 'inlineSources',\n ];\n\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 ...transformUndefineObject(ignoreCompileOptions),\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 logger.info(\n await watchSectionTitle(BundleDtsLogPrefix, SectionTitleStatus.Log),\n );\n } else if (event.code === 'BUNDLE_END') {\n logger.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 const { printOrThrowDtsErrors } = await import('../../utils/dts');\n await printOrThrowDtsErrors(e, { abortOnError, buildType: 'bundle' });\n return null;\n }\n }\n};\n"]}
|
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -68,6 +68,7 @@ __export(tsc_exports, {
|
|
|
68
68
|
runTsc: () => runTsc
|
|
69
69
|
});
|
|
70
70
|
module.exports = __toCommonJS(tsc_exports);
|
|
71
|
+
var import_utils = require("@modern-js/utils");
|
|
71
72
|
const getProjectTsconfig = (tsconfigPath) => __async(void 0, null, function* () {
|
|
72
73
|
const { json5, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
73
74
|
if (!fs.existsSync(tsconfigPath)) {
|
|
@@ -85,28 +86,32 @@ const resolveLog = (childProgress, options) => __async(void 0, null, function* (
|
|
|
85
86
|
const { watchDoneText } = yield Promise.resolve().then(() => __toESM(require("../../constants/dts")));
|
|
86
87
|
(_a = childProgress.stdout) == null ? void 0 : _a.on("data", (data) => __async(void 0, null, function* () {
|
|
87
88
|
if (watch) {
|
|
88
|
-
|
|
89
|
+
import_utils.logger.info(
|
|
89
90
|
yield watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log)
|
|
90
91
|
);
|
|
91
|
-
|
|
92
|
+
import_utils.logger.info(data.toString());
|
|
92
93
|
if (data.toString().includes(watchDoneText)) {
|
|
93
94
|
yield watchFn();
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
}));
|
|
97
98
|
(_b = childProgress.stdout) == null ? void 0 : _b.on("error", (error) => {
|
|
98
|
-
|
|
99
|
+
import_utils.logger.error(error.message);
|
|
99
100
|
});
|
|
100
101
|
(_c = childProgress.stderr) == null ? void 0 : _c.on("data", (chunk) => {
|
|
101
|
-
|
|
102
|
+
import_utils.logger.error(chunk.toString());
|
|
102
103
|
});
|
|
103
104
|
});
|
|
104
105
|
const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
105
106
|
const { execa } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
106
|
-
const {
|
|
107
|
-
const { generatorTsConfig } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
107
|
+
const { generatorTsConfig, printOrThrowDtsErrors } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
108
108
|
const { getTscBinPath } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
109
|
-
const {
|
|
109
|
+
const {
|
|
110
|
+
tsconfigPath,
|
|
111
|
+
appDirectory,
|
|
112
|
+
watch = false,
|
|
113
|
+
abortOnError = true
|
|
114
|
+
} = config;
|
|
110
115
|
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
111
116
|
const result = yield generatorTsConfig(config);
|
|
112
117
|
const tscBinFile = yield getTscBinPath(appDirectory);
|
|
@@ -139,11 +144,7 @@ const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
|
139
144
|
try {
|
|
140
145
|
yield childProgress;
|
|
141
146
|
} catch (e) {
|
|
142
|
-
|
|
143
|
-
throw new InternalDTSError(e, {
|
|
144
|
-
buildType: "bundleless"
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
+
yield printOrThrowDtsErrors(e, { abortOnError, buildType: "bundleless" });
|
|
147
148
|
}
|
|
148
149
|
return __spreadProps(__spreadValues({}, result), { userTsconfig });
|
|
149
150
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuB;AAQhB,MAAM,qBAAqB,CAChC,iBACuB;AACvB,QAAM,EAAE,OAAO,GAAG,IAAI,MAAM,6CAAO,kBAAk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MAAM,kBAAkB,MAAM;AAE7C,QAAM,aAAa,MAAM,cAAc,YAAY;AAEnD,QAAM,cAAc,QAAQ,CAAC,IAAI,IAAI,CAAC;AACtC,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,MACE;AAAA,MACA,OAAO;AAAA;AAAA,MAEP;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,eAAe;AAClC,aAAW,eAAe;AAAA,IACxB;AAAA,IACA,SAAS,MAAY;AACnB,YAAM,EAAE,aAAa,IAAI,MAAM,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,UAAM,sBAAsB,GAAG,EAAE,cAAc,WAAW,aAAa,CAAC;AAAA,EAC1E;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 { logger } from '@modern-js/utils';\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 logger.info(\n await watchSectionTitle(BundlelessDtsLogPrefix, SectionTitleStatus.Log),\n );\n logger.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 logger.error(error.message);\n });\n childProgress.stderr?.on('data', chunk => {\n logger.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 { generatorTsConfig, printOrThrowDtsErrors } = await import(\n '../../utils/dts'\n );\n const { getTscBinPath } = await import('../../utils/dts');\n const {\n tsconfigPath,\n appDirectory,\n watch = false,\n abortOnError = true,\n } = 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 await printOrThrowDtsErrors(e, { abortOnError, buildType: 'bundleless' });\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
|
@@ -50,6 +50,7 @@ __export(builder_exports, {
|
|
|
50
50
|
run: () => run
|
|
51
51
|
});
|
|
52
52
|
module.exports = __toCommonJS(builder_exports);
|
|
53
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
53
54
|
const run = (options, api) => __async(void 0, null, function* () {
|
|
54
55
|
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
55
56
|
const { resolvedBuildConfig, context, cmdOptions } = options;
|
|
@@ -63,7 +64,7 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
63
64
|
yield clearBuildConfigPaths(resolvedBuildConfig);
|
|
64
65
|
yield clearDtsTemp();
|
|
65
66
|
if (cmdOptions.watch) {
|
|
66
|
-
|
|
67
|
+
import_logger.logger.info("Start build in watch mode...\n");
|
|
67
68
|
}
|
|
68
69
|
try {
|
|
69
70
|
yield pMap(resolvedBuildConfig, (config) => __async(void 0, null, function* () {
|
|
@@ -93,7 +94,7 @@ const run = (options, api) => __async(void 0, null, function* () {
|
|
|
93
94
|
printFileSize();
|
|
94
95
|
}
|
|
95
96
|
} else {
|
|
96
|
-
|
|
97
|
+
import_logger.logger.warn(
|
|
97
98
|
chalk.yellow(
|
|
98
99
|
`No build configuration found! Please configure \`buildConfig\` or \`buildPreset\``
|
|
99
100
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AAQhB,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,2BAAO,KAAK,gCAAgC;AAAA,IAC9C;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,yBAAO;AAAA,MACL,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 { logger } from '@modern-js/utils/logger';\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 logger.info('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 logger.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
|
@@ -50,6 +50,7 @@ __export(platform_exports, {
|
|
|
50
50
|
buildPlatform: () => buildPlatform
|
|
51
51
|
});
|
|
52
52
|
module.exports = __toCommonJS(platform_exports);
|
|
53
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
53
54
|
const buildPlatform = (options, api, context) => __async(void 0, null, function* () {
|
|
54
55
|
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
55
56
|
const { blue, gray } = yield Promise.resolve().then(() => __toESM(require("../constants/colors")));
|
|
@@ -57,17 +58,17 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
57
58
|
const platformBuilders = yield runner.registerBuildPlatform();
|
|
58
59
|
if (platformBuilders.length === 0) {
|
|
59
60
|
if (options.platform === true) {
|
|
60
|
-
|
|
61
|
+
import_logger.logger.info("No executable platform build tasks");
|
|
61
62
|
} else if (Array.isArray(options.platform) && options.platform.length === 1) {
|
|
62
|
-
|
|
63
|
+
import_logger.logger.info(
|
|
63
64
|
`No build tasks with platform "${options.platform[0]}" found`
|
|
64
65
|
);
|
|
65
66
|
} else if (Array.isArray(options.platform) && options.platform.length > 1) {
|
|
66
|
-
|
|
67
|
+
import_logger.logger.info(
|
|
67
68
|
`No build tasks with platform ${options.platform.join(",")} found`
|
|
68
69
|
);
|
|
69
70
|
} else {
|
|
70
|
-
|
|
71
|
+
import_logger.logger.info("Unknown platform", JSON.stringify(options.platform));
|
|
71
72
|
}
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
@@ -77,7 +78,7 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
77
78
|
if (options.platform === true) {
|
|
78
79
|
for (const platformBuilder of platformBuilders) {
|
|
79
80
|
const currentPlatform = Array.isArray(platformBuilder.platform) ? platformBuilder.platform[0] : platformBuilder.platform;
|
|
80
|
-
|
|
81
|
+
import_logger.logger.info(
|
|
81
82
|
chalk.underline.rgb(...blue)(
|
|
82
83
|
`Running [${currentPlatform}] build task:`
|
|
83
84
|
)
|
|
@@ -86,7 +87,7 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
86
87
|
yield platformBuilder.build(currentPlatform, {
|
|
87
88
|
isTsProject: context.isTsProject
|
|
88
89
|
});
|
|
89
|
-
|
|
90
|
+
import_logger.logger.info(chalk.rgb(...gray)(`Done for [${currentPlatform}] task`));
|
|
90
91
|
}
|
|
91
92
|
} else if (Array.isArray(options.platform) && options.platform.length === 1) {
|
|
92
93
|
const targetPlatform = options.platform[0];
|
|
@@ -97,17 +98,17 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
97
98
|
return builder.platform === targetPlatform;
|
|
98
99
|
});
|
|
99
100
|
if (!selectPlatformBuilder) {
|
|
100
|
-
|
|
101
|
+
import_logger.logger.info(`The specified "${targetPlatform}" build does not exist`);
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
import_logger.logger.info(
|
|
104
105
|
chalk.underline.rgb(...blue)(`Running [${targetPlatform}] build task:`)
|
|
105
106
|
);
|
|
106
107
|
yield runner.buildPlatform({ platform: targetPlatform });
|
|
107
108
|
yield selectPlatformBuilder.build(targetPlatform, {
|
|
108
109
|
isTsProject: context.isTsProject
|
|
109
110
|
});
|
|
110
|
-
|
|
111
|
+
import_logger.logger.info(chalk.rgb(...gray)(`Done for [${targetPlatform}] task`));
|
|
111
112
|
} else if (Array.isArray(options.platform) && options.platform.length > 1) {
|
|
112
113
|
for (const platform of options.platform) {
|
|
113
114
|
const foundBuilder = platformBuilders.find((builder) => {
|
|
@@ -117,17 +118,17 @@ const buildPlatform = (options, api, context) => __async(void 0, null, function*
|
|
|
117
118
|
return builder.platform === platform;
|
|
118
119
|
});
|
|
119
120
|
if (!foundBuilder) {
|
|
120
|
-
|
|
121
|
+
import_logger.logger.info(`skip ${platform} build, because it does not exist`);
|
|
121
122
|
continue;
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
import_logger.logger.info(
|
|
124
125
|
chalk.underline.rgb(...blue)(`Running [${platform}] build task:`)
|
|
125
126
|
);
|
|
126
127
|
yield runner.buildPlatform({ platform });
|
|
127
128
|
yield foundBuilder.build(platform, {
|
|
128
129
|
isTsProject: context.isTsProject
|
|
129
130
|
});
|
|
130
|
-
|
|
131
|
+
import_logger.logger.info(chalk.rgb(...gray)(`Done for [${platform}] task`));
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AAIhB,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,QA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AAa,OAAO,YAAY;AAAA,IACxC,SAAS;AAAA,EACX,CAAC;AACH;;;;;","names":[],"sources":["../../src/builder/platform.ts"],"sourcesContent":["import { PluginAPI } from '@modern-js/core';\nimport { logger } from '@modern-js/utils/logger';\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 logger.info('No executable platform build tasks');\n } else if (\n Array.isArray(options.platform) &&\n options.platform.length === 1\n ) {\n logger.info(\n `No build tasks with platform \"${options.platform[0]}\" found`,\n );\n } else if (Array.isArray(options.platform) && options.platform.length > 1) {\n logger.info(\n `No build tasks with platform ${options.platform.join(',')} found`,\n );\n } else {\n logger.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 logger.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 logger.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 logger.info(`The specified \"${targetPlatform}\" build does not exist`);\n return;\n }\n\n logger.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 logger.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 logger.info(`skip ${platform} build, because it does not exist`);\n continue;\n }\n\n logger.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 logger.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/config/schema.d.ts
CHANGED
|
@@ -85,6 +85,9 @@ export declare const buildConfig: {
|
|
|
85
85
|
tsconfigPath: {
|
|
86
86
|
type: string;
|
|
87
87
|
};
|
|
88
|
+
abortOnError: {
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
88
91
|
};
|
|
89
92
|
};
|
|
90
93
|
else: {
|
|
@@ -251,6 +254,9 @@ export declare const buildConfig: {
|
|
|
251
254
|
tsconfigPath: {
|
|
252
255
|
type: string;
|
|
253
256
|
};
|
|
257
|
+
abortOnError: {
|
|
258
|
+
type: string;
|
|
259
|
+
};
|
|
254
260
|
};
|
|
255
261
|
};
|
|
256
262
|
else: {
|
|
@@ -445,6 +451,9 @@ export declare const schema: ({
|
|
|
445
451
|
tsconfigPath: {
|
|
446
452
|
type: string;
|
|
447
453
|
};
|
|
454
|
+
abortOnError: {
|
|
455
|
+
type: string;
|
|
456
|
+
};
|
|
448
457
|
};
|
|
449
458
|
};
|
|
450
459
|
else: {
|
|
@@ -611,6 +620,9 @@ export declare const schema: ({
|
|
|
611
620
|
tsconfigPath: {
|
|
612
621
|
type: string;
|
|
613
622
|
};
|
|
623
|
+
abortOnError: {
|
|
624
|
+
type: string;
|
|
625
|
+
};
|
|
614
626
|
};
|
|
615
627
|
};
|
|
616
628
|
else: {
|
package/dist/config/schema.js
CHANGED
|
@@ -112,7 +112,8 @@ const buildConfigProperties = {
|
|
|
112
112
|
then: {
|
|
113
113
|
properties: {
|
|
114
114
|
distPath: { type: "string" },
|
|
115
|
-
tsconfigPath: { type: "string" }
|
|
115
|
+
tsconfigPath: { type: "string" },
|
|
116
|
+
abortOnError: { type: "boolean" }
|
|
116
117
|
}
|
|
117
118
|
},
|
|
118
119
|
else: { type: "boolean" }
|