@modern-js/module-tools 2.2.0 → 2.3.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 +30 -0
- package/dist/builder/build.d.ts +1 -1
- package/dist/builder/build.js +6 -6
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/dts/rollup.d.ts +2 -2
- package/dist/builder/dts/rollup.js +3 -7
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.d.ts +2 -2
- package/dist/builder/dts/tsc.js +5 -3
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/command.js +0 -6
- package/dist/command.js.map +1 -1
- package/dist/dev.d.ts +0 -4
- package/dist/dev.js +3 -26
- package/dist/dev.js.map +1 -1
- package/dist/hooks/build.d.ts +5 -1
- package/dist/hooks/build.js +8 -2
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/types/hooks.d.ts +8 -2
- package/dist/types/hooks.js.map +1 -1
- package/dist/utils/libuild-plugins.d.ts +2 -2
- package/dist/utils/libuild-plugins.js +3 -1
- package/dist/utils/libuild-plugins.js.map +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7736171: feat: add watch hooks
|
|
8
|
+
feat: 添加 watch hooks
|
|
9
|
+
- 7736171: feat: Remove the listening mode build task before Storybook starts
|
|
10
|
+
feat: 在 Storybook 启动之前,移除监听模式的构建任务
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- cdb8cd5: update libuild version
|
|
15
|
+
升级 libuild 版本
|
|
16
|
+
- 7ad838e: fix umd code can not support es5 target
|
|
17
|
+
修复 umd 的代码不能被转换成 es5 的问题
|
|
18
|
+
- Updated dependencies [65f1322]
|
|
19
|
+
- Updated dependencies [fd5a3ed]
|
|
20
|
+
- Updated dependencies [7b2cdcb]
|
|
21
|
+
- Updated dependencies [6ca1c0b]
|
|
22
|
+
- Updated dependencies [89b6739]
|
|
23
|
+
- Updated dependencies [7736171]
|
|
24
|
+
- @modern-js/core@2.3.0
|
|
25
|
+
- @modern-js/utils@2.3.0
|
|
26
|
+
- @modern-js/plugin-changeset@2.3.0
|
|
27
|
+
- @modern-js/plugin-lint@2.3.0
|
|
28
|
+
- @modern-js/plugin-i18n@2.3.0
|
|
29
|
+
- @modern-js/new-action@2.3.0
|
|
30
|
+
- @modern-js/upgrade@2.3.0
|
|
31
|
+
- @modern-js/plugin@2.3.0
|
|
32
|
+
|
|
3
33
|
## 2.2.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/dist/builder/build.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const buildInJsProject: (options: {
|
|
|
14
14
|
buildCmdOptions: BuildCommandOptions;
|
|
15
15
|
context: ModuleContext;
|
|
16
16
|
}, api: PluginAPI<ModuleTools>) => Promise<void>;
|
|
17
|
-
export declare const generatorDts: (config: BaseBuildConfig, api: PluginAPI
|
|
17
|
+
export declare const generatorDts: (config: BaseBuildConfig, api: PluginAPI<ModuleTools>, options: {
|
|
18
18
|
watch: boolean;
|
|
19
19
|
dts: DTSOptions;
|
|
20
20
|
}) => Promise<void>;
|
package/dist/builder/build.js
CHANGED
|
@@ -114,7 +114,7 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
114
114
|
if (buildType === "bundle") {
|
|
115
115
|
const { getFinalExternals } = yield Promise.resolve().then(() => __toESM(require("../utils/builder")));
|
|
116
116
|
const finalExternals = yield getFinalExternals(config, { appDirectory });
|
|
117
|
-
yield runRollup({
|
|
117
|
+
yield runRollup(api, {
|
|
118
118
|
distDir: distPath,
|
|
119
119
|
watch,
|
|
120
120
|
externals: finalExternals,
|
|
@@ -122,7 +122,7 @@ const generatorDts = (config, api, options) => __async(void 0, null, function* (
|
|
|
122
122
|
tsconfigPath
|
|
123
123
|
});
|
|
124
124
|
} else {
|
|
125
|
-
yield runTsc({
|
|
125
|
+
yield runTsc(api, {
|
|
126
126
|
appDirectory,
|
|
127
127
|
alias,
|
|
128
128
|
distAbsPath: distPath,
|
|
@@ -165,9 +165,9 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
165
165
|
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
166
166
|
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
167
167
|
const { es5Plugin, umdPlugin, transformPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
168
|
-
const plugins =
|
|
169
|
-
if (
|
|
170
|
-
plugins.push(
|
|
168
|
+
const plugins = format === "umd" ? [umdPlugin(umdModuleName)] : [];
|
|
169
|
+
if (target === "es5") {
|
|
170
|
+
plugins.push(es5Plugin());
|
|
171
171
|
}
|
|
172
172
|
const { getProjectTsconfig } = yield Promise.resolve().then(() => __toESM(require("./dts/tsc")));
|
|
173
173
|
const tsconfigPath = dts ? dts.tsconfigPath : (0, import_path.join)(appDirectory, "./tsconfig.json");
|
|
@@ -190,7 +190,7 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
190
190
|
plugins.push(svgrPlugin(options2));
|
|
191
191
|
}
|
|
192
192
|
const { watchPlugin, externalPlugin } = yield Promise.resolve().then(() => __toESM(require("../utils/libuild-plugins")));
|
|
193
|
-
plugins.push(watchPlugin(config));
|
|
193
|
+
plugins.push(watchPlugin(api, config));
|
|
194
194
|
plugins.push(externalPlugin(config, { appDirectory }));
|
|
195
195
|
const buildConfig = {
|
|
196
196
|
root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,YAAY,cAAc;AAAA,IACpC,SAAS;AAAA,IACT,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,cAAc;AAAA,IAEtB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB,CAACA,aAAkB,iCAC9BA,WAD8B;AAAA,MAEjC,WAAW;AAAA,QACT,kBAAkB,EAChB,CAAC,OAAO,KAAK,EAAE,SAAS,MAAM,KAAK,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AAEnC,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AAEpB,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,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;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,\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({\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc({\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 } = 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 = target === 'es5' ? [es5Plugin()] : [];\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\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(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 // outbase for [dir]/[name]\n outbase: sourceDir,\n logLevel: 'error',\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,OA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AW;AAAA,QACT,kBAAkB,EAChB,CAAC,OAAO,KAAK,EAAE,SAAS,MAAM,KAAK,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AAEnC,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AAEpB,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,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;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 } = 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 // outbase for [dir]/[name]\n outbase: sourceDir,\n logLevel: 'error',\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,5 +1,5 @@
|
|
|
1
1
|
import type { RollupWatcher } from '../../../compiled/rollup';
|
|
2
|
-
import type { BaseBuildConfig, Input } from '../../types';
|
|
2
|
+
import type { BaseBuildConfig, Input, PluginAPI, ModuleTools } from '../../types';
|
|
3
3
|
export type { RollupWatcher };
|
|
4
4
|
type Config = {
|
|
5
5
|
distDir: string;
|
|
@@ -8,7 +8,7 @@ type Config = {
|
|
|
8
8
|
input: Input;
|
|
9
9
|
watch: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare const runRollup: ({
|
|
11
|
+
export declare const runRollup: (api: PluginAPI<ModuleTools>, {
|
|
12
12
|
distDir,
|
|
13
13
|
tsconfigPath,
|
|
14
14
|
externals,
|
|
@@ -64,13 +64,7 @@ __export(rollup_exports, {
|
|
|
64
64
|
});
|
|
65
65
|
module.exports = __toCommonJS(rollup_exports);
|
|
66
66
|
var import_path = __toESM(require("path"));
|
|
67
|
-
const runRollup = (_0) => __async(void 0, [_0], function* ({
|
|
68
|
-
distDir,
|
|
69
|
-
tsconfigPath,
|
|
70
|
-
externals,
|
|
71
|
-
input,
|
|
72
|
-
watch
|
|
73
|
-
}) {
|
|
67
|
+
const runRollup = (_0, _1) => __async(void 0, [_0, _1], function* (api, { distDir, tsconfigPath, externals, input, watch }) {
|
|
74
68
|
const ignoreFiles = {
|
|
75
69
|
name: "ignore-files",
|
|
76
70
|
load(id) {
|
|
@@ -123,6 +117,7 @@ const runRollup = (_0) => __async(void 0, [_0], function* ({
|
|
|
123
117
|
const { watch: watch2 } = yield Promise.resolve().then(() => __toESM(require("../../../compiled/rollup")));
|
|
124
118
|
const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("../../utils/log")));
|
|
125
119
|
const { SectionTitleStatus, BundleDtsLogPrefix } = yield Promise.resolve().then(() => __toESM(require("../../constants/log")));
|
|
120
|
+
const runner = api.useHookRunners();
|
|
126
121
|
const watcher = watch2(__spreadProps(__spreadValues({}, inputConfig), {
|
|
127
122
|
plugins: inputConfig.plugins,
|
|
128
123
|
output: outputConfig
|
|
@@ -138,6 +133,7 @@ const runRollup = (_0) => __async(void 0, [_0], function* ({
|
|
|
138
133
|
SectionTitleStatus.Success
|
|
139
134
|
)
|
|
140
135
|
);
|
|
136
|
+
runner.buildWatchDts({ buildType: "bundle" });
|
|
141
137
|
} else if (event.code === "ERROR") {
|
|
142
138
|
}
|
|
143
139
|
}));
|
|
@@ -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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,MAAM,6CAAO;AAC/B,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,UAAM,EAAE,oBAAoB,mBAAmB,IAAI,MAAM,6CACvD;AAEF,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,UAAUA,OAAM,iCACjB,cADiB;AAAA,MAEpB,SAAS,YAAY;AAAA,MACrB,QAAQ;AAAA,IACV,EAAC,EAAE,GAAG,SAAS,CAAM,UAAS;AAC5B,UAAI,MAAM,SAAS,SAAS;AAC1B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,oBAAoB,mBAAmB,GAAG;AAAA,QACpE;AAAA,MACF,WAAW,MAAM,SAAS,cAAc;AACtC,gBAAQ;AAAA,UACN,MAAM;AAAA,YACJ;AAAA,YACA,mBAAmB;AAAA,UACrB;AAAA,QACF;AACA,eAAO,cAAc,EAAE,WAAW,SAAS,CAAC;AAAA,MAC9C,WAAW,MAAM,SAAS,SAAS;AAAA,MAEnC;AAAA,IACF,EAAC;AACD,WAAO;AAAA,EACT,OAAO;AACL,QAAI;AACF,YAAM,EAAE,OAAO,IAAI,MAAM,6CAAO;AAChC,YAAM,SAAS,MAAM,OAAO,WAAW;AACvC,YAAM,OAAO,MAAM,YAAY;AAC/B,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)$/.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 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 bundle = await rollup(inputConfig);\n await bundle.write(outputConfig);\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"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BundlelessGeneratorDtsConfig, ITsconfig } from '../../types';
|
|
1
|
+
import type { BundlelessGeneratorDtsConfig, ITsconfig, PluginAPI, ModuleTools } from '../../types';
|
|
2
2
|
export declare const getProjectTsconfig: (tsconfigPath: string) => Promise<ITsconfig>;
|
|
3
|
-
export declare const runTsc: (config: BundlelessGeneratorDtsConfig) => Promise<void>;
|
|
3
|
+
export declare const runTsc: (api: PluginAPI<ModuleTools>, config: BundlelessGeneratorDtsConfig) => Promise<void>;
|
package/dist/builder/dts/tsc.js
CHANGED
|
@@ -97,7 +97,7 @@ const resolveLog = (childProgress, options) => __async(void 0, null, function* (
|
|
|
97
97
|
console.error(chunk.toString());
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
|
-
const generatorDts = (config) => __async(void 0, null, function* () {
|
|
100
|
+
const generatorDts = (api, config) => __async(void 0, null, function* () {
|
|
101
101
|
const { execa } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
102
102
|
const { InternalDTSError } = yield Promise.resolve().then(() => __toESM(require("../../error")));
|
|
103
103
|
const { generatorTsConfig } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
@@ -121,11 +121,13 @@ const generatorDts = (config) => __async(void 0, null, function* () {
|
|
|
121
121
|
cwd: appDirectory
|
|
122
122
|
}
|
|
123
123
|
);
|
|
124
|
+
const runner = api.useHookRunners();
|
|
124
125
|
resolveLog(childProgress, {
|
|
125
126
|
watch,
|
|
126
127
|
watchFn: () => __async(void 0, null, function* () {
|
|
127
128
|
const { resolveAlias } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
128
129
|
yield resolveAlias(config, __spreadProps(__spreadValues({}, result), { userTsconfig }));
|
|
130
|
+
runner.buildWatchDts({ buildType: "bundleless" });
|
|
129
131
|
})
|
|
130
132
|
});
|
|
131
133
|
try {
|
|
@@ -139,9 +141,9 @@ const generatorDts = (config) => __async(void 0, null, function* () {
|
|
|
139
141
|
}
|
|
140
142
|
return __spreadProps(__spreadValues({}, result), { userTsconfig });
|
|
141
143
|
});
|
|
142
|
-
const runTsc = (config) => __async(void 0, null, function* () {
|
|
144
|
+
const runTsc = (api, config) => __async(void 0, null, function* () {
|
|
143
145
|
const { resolveAlias } = yield Promise.resolve().then(() => __toESM(require("../../utils/dts")));
|
|
144
|
-
const result = yield generatorDts(config);
|
|
146
|
+
const result = yield generatorDts(api, config);
|
|
145
147
|
yield resolveAlias(config, result);
|
|
146
148
|
});
|
|
147
149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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;AAQO,MAAM,qBAAqB,CAChC,iBACuB;AACvB,QAAM,EAAE,OAAO,GAAG,IAAI,MAAM,6CAAO;AACnC,MAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAChC,WAAO,CAAC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AAC;AACtC,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,MACE;AAAA,MACA,OAAO;AAAA,MAEP;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;AACtC,YAAM,aAAa,QAAQ,iCAAK,SAAL,EAAa,aAAa,EAAC;AACtD,aAAO,cAAc,EAAE,WAAW,aAAa,CAAC;AAAA,IAClD;AAAA,EACF,CAAC;AAED,MAAI;AACF,UAAM;AAAA,EACR,SAAS,GAAP;AACA,QAAI,aAAa,OAAO;AACtB,YAAM,IAAI,iBAAiB,GAAG;AAAA,QAC5B,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,iCAAK,SAAL,EAAa,aAAa;AACnC;AAEO,MAAM,SAAS,CACpB,KACA,WACG;AACH,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO;AACtC,QAAM,SAAS,MAAM,aAAa,KAAK,MAAM;AAC7C,QAAM,aAAa,QAAQ,MAAM;AACnC;;;;;;","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 result = await generatorDts(api, config);\n await resolveAlias(config, result);\n};\n"]}
|
package/dist/command.js
CHANGED
|
@@ -108,14 +108,8 @@ const devCommand = (program, api) => __async(void 0, null, function* () {
|
|
|
108
108
|
}
|
|
109
109
|
for (const subCmd of meta.subCommands) {
|
|
110
110
|
devProgram.command(subCmd).action((options) => __async(void 0, null, function* () {
|
|
111
|
-
var _a;
|
|
112
111
|
const { initModuleContext } = yield Promise.resolve().then(() => __toESM(require("./utils/context")));
|
|
113
112
|
const context = yield initModuleContext(api);
|
|
114
|
-
const { runBuildBeforeDevTools } = yield Promise.resolve().then(() => __toESM(require("./dev")));
|
|
115
|
-
yield runBuildBeforeDevTools(api, context, options, {
|
|
116
|
-
disableRunBuild: (_a = meta.disableRunBuild) != null ? _a : false,
|
|
117
|
-
appDirectory: context.appDirectory
|
|
118
|
-
});
|
|
119
113
|
yield runner.beforeDevTask(meta);
|
|
120
114
|
yield meta.action(options, { isTsProject: context.isTsProject });
|
|
121
115
|
}));
|
package/dist/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,eAAe,CAC1B,SACA,QACG;AACH,QAAM,QAAQ,MAAM,6CAAO;AAC3B,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAE7C,UACG,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,CAAC,EACjE,OAAO,eAAe,MAAM,KAAK,EAAE,MAAM,WAAW,QAA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AAM,WAAW,EACjB,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,QAAQ,CAAC,EAC/D;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,KAAK;AAAA,IAC/C;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,MAAM;AAAA,EAClD,EACC;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,OAAO;AAAA,EACnD,EACC,OAAO,iBAAiB,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,IAAI,CAAC,EACvE,OAAO,cAAc,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,IAAI,QAAQ,CAAC,EACxE,OAAO,CAAM,YAAW;AACvB,UAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO;AACzC,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,UAAM,SAAS,kBAAkB;AAEjC,UAAM,gBAAgB,iCAAK,UAAL,EAAc,QAAQ,QAAQ,QAAQ,OAAO,EAAC;AAAA,EACtE,EAAC;AACL;AAEO,MAAM,gBAAgB,CAAO,YAAqB;AACvD,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO;AACvC,gBAAc,QAAQ,QAAQ,SAAS,CAAC;AAC1C;;;;;;;;","names":[],"sources":["../src/command.ts"],"sourcesContent":["import type { Command } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.no_clear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.dev.tsconfig),\n defaultTsConfigPath,\n )\n .action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n\n // TODO: watch build\n // const { ensureFirstBuild, watchBuild } = await import('./dev');\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--lang <lang>', local.i18n.t(local.localeKeys.command.new.lang))\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import('./utils/language');\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale: options.lang || locale });\n });\n};\n\nexport const upgradCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(program.command('upgrade'));\n};\n"]}
|
package/dist/dev.d.ts
CHANGED
|
@@ -2,9 +2,5 @@ import type { PluginAPI } from '@modern-js/core';
|
|
|
2
2
|
import type { DevCommandOptions } from './types/command';
|
|
3
3
|
import type { ModuleContext } from './types/context';
|
|
4
4
|
import type { DevToolData, ModuleTools } from './types';
|
|
5
|
-
export declare const runBuildBeforeDevTools: (api: PluginAPI<ModuleTools>, context: ModuleContext, cliOptions: DevCommandOptions, options: {
|
|
6
|
-
disableRunBuild: boolean;
|
|
7
|
-
appDirectory: string;
|
|
8
|
-
}) => Promise<void>;
|
|
9
5
|
export declare const showMenu: (metas: DevToolData[], devCmdOptions: DevCommandOptions, api: PluginAPI<ModuleTools>, context: ModuleContext) => Promise<void>;
|
|
10
6
|
export declare const dev: (options: DevCommandOptions, metas: DevToolData[], api: PluginAPI<ModuleTools>, context: ModuleContext) => Promise<void>;
|
package/dist/dev.js
CHANGED
|
@@ -44,24 +44,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
44
44
|
var dev_exports = {};
|
|
45
45
|
__export(dev_exports, {
|
|
46
46
|
dev: () => dev,
|
|
47
|
-
runBuildBeforeDevTools: () => runBuildBeforeDevTools,
|
|
48
47
|
showMenu: () => showMenu
|
|
49
48
|
});
|
|
50
49
|
module.exports = __toCommonJS(dev_exports);
|
|
51
|
-
const runBuildBeforeDevTools = (api, context, cliOptions, options) => __async(void 0, null, function* () {
|
|
52
|
-
if (!options.disableRunBuild) {
|
|
53
|
-
const { build } = yield Promise.resolve().then(() => __toESM(require("./build")));
|
|
54
|
-
const defaultCmdOptions = {
|
|
55
|
-
watch: true,
|
|
56
|
-
tsconfig: cliOptions.tsconfig,
|
|
57
|
-
dts: true,
|
|
58
|
-
clear: true
|
|
59
|
-
};
|
|
60
|
-
build(api, defaultCmdOptions, context);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
50
|
const showMenu = (metas, devCmdOptions, api, context) => __async(void 0, null, function* () {
|
|
64
|
-
var _a;
|
|
65
51
|
const { chalk, inquirer } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
66
52
|
const runner = api.useHookRunners();
|
|
67
53
|
const menuTitle = chalk.rgb(255, 153, 0);
|
|
@@ -81,15 +67,11 @@ const showMenu = (metas, devCmdOptions, api, context) => __async(void 0, null, f
|
|
|
81
67
|
yield runner.afterDevMenu({ result, devTools: metas });
|
|
82
68
|
const currentDevTool = metas.find(
|
|
83
69
|
(meta) => {
|
|
84
|
-
var
|
|
85
|
-
return ((
|
|
70
|
+
var _a;
|
|
71
|
+
return ((_a = meta.menuItem) == null ? void 0 : _a.value) === result.choiceDevTool;
|
|
86
72
|
}
|
|
87
73
|
);
|
|
88
74
|
if (currentDevTool) {
|
|
89
|
-
yield runBuildBeforeDevTools(api, context, devCmdOptions, {
|
|
90
|
-
disableRunBuild: (_a = currentDevTool.disableRunBuild) != null ? _a : false,
|
|
91
|
-
appDirectory: context.appDirectory
|
|
92
|
-
});
|
|
93
75
|
yield runner.beforeDevTask(currentDevTool);
|
|
94
76
|
yield currentDevTool.action(devCmdOptions, {
|
|
95
77
|
isTsProject: context.isTsProject
|
|
@@ -97,7 +79,7 @@ const showMenu = (metas, devCmdOptions, api, context) => __async(void 0, null, f
|
|
|
97
79
|
}
|
|
98
80
|
});
|
|
99
81
|
const dev = (options, metas, api, context) => __async(void 0, null, function* () {
|
|
100
|
-
var _a, _b
|
|
82
|
+
var _a, _b;
|
|
101
83
|
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
102
84
|
const { purple } = yield Promise.resolve().then(() => __toESM(require("./constants/colors")));
|
|
103
85
|
if (metas.length === 0) {
|
|
@@ -112,10 +94,6 @@ const dev = (options, metas, api, context) => __async(void 0, null, function* ()
|
|
|
112
94
|
)
|
|
113
95
|
);
|
|
114
96
|
const meta = metas[0];
|
|
115
|
-
yield runBuildBeforeDevTools(api, context, options, {
|
|
116
|
-
disableRunBuild: (_c = meta.disableRunBuild) != null ? _c : false,
|
|
117
|
-
appDirectory: context.appDirectory
|
|
118
|
-
});
|
|
119
97
|
yield runner.beforeDevTask(meta);
|
|
120
98
|
yield meta.action(options, { isTsProject: context.isTsProject });
|
|
121
99
|
} else if (metas.length > 1) {
|
|
@@ -125,7 +103,6 @@ const dev = (options, metas, api, context) => __async(void 0, null, function* ()
|
|
|
125
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
104
|
0 && (module.exports = {
|
|
127
105
|
dev,
|
|
128
|
-
runBuildBeforeDevTools,
|
|
129
106
|
showMenu
|
|
130
107
|
});
|
|
131
108
|
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCO,MAAM,WAAW,CACtB,O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AAM,OAAO,MAAM;AAQnB,UAAM,OAAO,cAAc,IAAI;AAC/B,UAAM,KAAK,OAAO,SAAS,EAAE,aAAa,QAAQ,YAAY,CAAC;AAAA,EAMjE,WAAW,MAAM,SAAS,GAAG;AAC3B,UAAM,SAAS,OAAO,SAAS,KAAK,OAAO;AAAA,EAC7C;AACF;;;;;;","names":[],"sources":["../src/dev.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { DevCommandOptions } from './types/command';\nimport type { ModuleContext } from './types/context';\nimport type { DevToolData, ModuleTools } from './types';\n\n// TODO: watch build\n// export const ensureFirstBuild = async (\n// api: PluginAPI<ModuleTools>,\n// context: ModuleContext,\n// cliOptions: DevCommandOptions,\n// options: {\n// watch?: boolean;\n// disableRunBuild: boolean;\n// appDirectory: string;\n// },\n// ) => {\n// if (!options.disableRunBuild) {\n// const { build } = await import('./build');\n// const defaultCmdOptions: BuildCommandOptions = {\n// tsconfig: cliOptions.tsconfig,\n// watch: options.watch ?? false,\n// dts: true,\n// clear: true,\n// };\n// await build(api, defaultCmdOptions, context);\n// }\n// };\n\n// export const watchBuild = async (\n// api: PluginAPI<ModuleTools>,\n// context: ModuleContext,\n// cliOptions: DevCommandOptions,\n// options: {\n// disableRunBuild: boolean;\n// appDirectory: string;\n// },\n// ) => {\n// await ensureFirstBuild(api, context, cliOptions, { ...options, watch: true });\n// };\n\nexport const showMenu = async (\n metas: DevToolData[],\n devCmdOptions: DevCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk, inquirer } = await import('@modern-js/utils');\n const runner = api.useHookRunners();\n\n const menuTitle = chalk.rgb(255, 153, 0);\n const choices = metas\n .map(meta => meta.menuItem)\n .filter(menuItem => typeof menuItem === 'object');\n const questions = [\n {\n name: 'choiceDevTool',\n message: menuTitle('选择调试工具'),\n type: 'list',\n choices,\n },\n ];\n\n const newQuestions = await runner.beforeDevMenu(questions);\n const result: { choiceDevTool: string } = await inquirer.prompt(\n newQuestions.length !== 0 ? newQuestions : questions,\n );\n await runner.afterDevMenu({ result, devTools: metas });\n\n const currentDevTool = metas.find(\n meta => meta.menuItem?.value === result.choiceDevTool,\n );\n if (currentDevTool) {\n // TODO: watch build\n // await ensureFirstBuild(api, context, devCmdOptions, {\n // disableRunBuild: currentDevTool.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(currentDevTool);\n await currentDevTool.action(devCmdOptions, {\n isTsProject: context.isTsProject,\n });\n\n // TODO: watch build\n // await watchBuild(api, context, devCmdOptions, {\n // disableRunBuild: currentDevTool.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n }\n};\n\nexport const dev = async (\n options: DevCommandOptions,\n metas: DevToolData[],\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { purple } = await import('./constants/colors');\n if (metas.length === 0) {\n console.info('No dev tools found available');\n // eslint-disable-next-line no-process-exit\n process.exit(0);\n }\n\n const runner = api.useHookRunners();\n if (metas.length === 1) {\n console.info(\n chalk.rgb(...purple)(\n `Only one dev tooling is currently detected as available, run it directly [${\n metas[0].menuItem?.name ?? metas[0].name\n }]`,\n ),\n );\n const meta = metas[0];\n\n // TODO: watch build\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n } else if (metas.length > 1) {\n await showMenu(metas, options, api, context);\n }\n};\n"]}
|
package/dist/hooks/build.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RegisterBuildPlatformResult } from '@modern-js/core';
|
|
2
2
|
import { BuildCommandOptions } from '../types';
|
|
3
3
|
import type { BuildConfig, BaseBuildConfig } from '../types/config';
|
|
4
|
-
import type { BuildTaskResult, BuildResult, BuildPlatformResult } from '../types/hooks';
|
|
4
|
+
import type { BuildTaskResult, BuildResult, BuildPlatformResult, WatchDtsHookContext, WatchJsHookContext } from '../types/hooks';
|
|
5
5
|
export declare const buildHooks: {
|
|
6
6
|
beforeBuild: import("@modern-js/plugin").ParallelWorkflow<{
|
|
7
7
|
config: BuildConfig;
|
|
@@ -16,4 +16,8 @@ export declare const buildHooks: {
|
|
|
16
16
|
platform: string;
|
|
17
17
|
}, void>;
|
|
18
18
|
afterBuildPlatform: import("@modern-js/plugin").ParallelWorkflow<BuildPlatformResult, void>;
|
|
19
|
+
};
|
|
20
|
+
export declare const buildWatchHooks: {
|
|
21
|
+
buildWatchJs: import("@modern-js/plugin").ParallelWorkflow<WatchJsHookContext, void>;
|
|
22
|
+
buildWatchDts: import("@modern-js/plugin").ParallelWorkflow<WatchDtsHookContext, void>;
|
|
19
23
|
};
|
package/dist/hooks/build.js
CHANGED
|
@@ -17,7 +17,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var build_exports = {};
|
|
19
19
|
__export(build_exports, {
|
|
20
|
-
buildHooks: () => buildHooks
|
|
20
|
+
buildHooks: () => buildHooks,
|
|
21
|
+
buildWatchHooks: () => buildWatchHooks
|
|
21
22
|
});
|
|
22
23
|
module.exports = __toCommonJS(build_exports);
|
|
23
24
|
var import_plugin = require("@modern-js/plugin");
|
|
@@ -31,9 +32,14 @@ const buildHooks = {
|
|
|
31
32
|
buildPlatform: (0, import_plugin.createParallelWorkflow)(),
|
|
32
33
|
afterBuildPlatform: (0, import_plugin.createParallelWorkflow)()
|
|
33
34
|
};
|
|
35
|
+
const buildWatchHooks = {
|
|
36
|
+
buildWatchJs: (0, import_plugin.createParallelWorkflow)(),
|
|
37
|
+
buildWatchDts: (0, import_plugin.createParallelWorkflow)()
|
|
38
|
+
};
|
|
34
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
40
|
0 && (module.exports = {
|
|
36
|
-
buildHooks
|
|
41
|
+
buildHooks,
|
|
42
|
+
buildWatchHooks
|
|
37
43
|
});
|
|
38
44
|
|
|
39
45
|
//# sourceMappingURL=build.js.map
|
package/dist/hooks/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AAYA,MAAM,aAAa;AAAA,EACxB,iBAAa,sCAGX;AAAA,EACF,qBAAiB,oCAAsC;AAAA,EACvD,oBAAgB,sCAA8C;AAAA,EAC9D,gBAAY,sCAA0C;AAAA,EACtD,2BAAuB,sCAGrB;AAAA,EACF,yBAAqB,sCAGnB;AAAA,EACF,mBAAe,sCAAmD;AAAA,EAClE,wBAAoB,sCAAkD;AACxE;AAEO,MAAM,kBAAkB;AAAA,EAC7B,kBAAc,sCAAiD;AAAA,EAC/D,mBAAe,sCAAkD;AACnE;;;;;;","names":[],"sources":["../../src/hooks/build.ts"],"sourcesContent":["import {\n createParallelWorkflow,\n createAsyncWaterfall,\n} from '@modern-js/plugin';\nimport type { RegisterBuildPlatformResult } from '@modern-js/core';\nimport { BuildCommandOptions } from '../types';\nimport type { BuildConfig, BaseBuildConfig } from '../types/config';\nimport type {\n BuildTaskResult,\n BuildResult,\n BuildPlatformResult,\n WatchDtsHookContext,\n WatchJsHookContext,\n} from '../types/hooks';\n\nexport const buildHooks = {\n beforeBuild: createParallelWorkflow<\n { config: BuildConfig; cliOptions: BuildCommandOptions },\n void\n >(),\n beforeBuildTask: createAsyncWaterfall<BaseBuildConfig>(),\n afterBuildTask: createParallelWorkflow<BuildTaskResult, void>(),\n afterBuild: createParallelWorkflow<BuildResult, void>(),\n registerBuildPlatform: createParallelWorkflow<\n void,\n RegisterBuildPlatformResult\n >(),\n beforeBuildPlatform: createParallelWorkflow<\n RegisterBuildPlatformResult[],\n void\n >(),\n buildPlatform: createParallelWorkflow<{ platform: string }, void>(),\n afterBuildPlatform: createParallelWorkflow<BuildPlatformResult, void>(),\n};\n\nexport const buildWatchHooks = {\n buildWatchJs: createParallelWorkflow<WatchJsHookContext, void>(),\n buildWatchDts: createParallelWorkflow<WatchDtsHookContext, void>(),\n};\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const registerHook: {
|
|
2
|
+
buildWatchJs: import("@modern-js/plugin").ParallelWorkflow<import("..").WatchJsHookContext, void>;
|
|
3
|
+
buildWatchDts: import("@modern-js/plugin").ParallelWorkflow<import("..").WatchDtsHookContext, void>;
|
|
2
4
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
3
5
|
modifyLibuild: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/libuild").CLIConfig, import("@modern-js/libuild").CLIConfig>;
|
|
4
6
|
registerDev: import("@modern-js/plugin").ParallelWorkflow<void, import("..").DevToolData>;
|
package/dist/hooks/index.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(hooks_exports);
|
|
|
37
37
|
var import_build = require("./build");
|
|
38
38
|
var import_dev = require("./dev");
|
|
39
39
|
var import_misc = require("./misc");
|
|
40
|
-
const registerHook = __spreadValues(__spreadValues(__spreadValues({}, import_build.buildHooks), import_dev.devHooks), import_misc.miscHooks);
|
|
40
|
+
const registerHook = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, import_build.buildHooks), import_dev.devHooks), import_misc.miscHooks), import_build.buildWatchHooks);
|
|
41
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
42
|
0 && (module.exports = {
|
|
43
43
|
registerHook
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAC5C,iBAAyB;AACzB,kBAA0B;AAEnB,MAAM,eAAe,gEACvB,0BACA,sBACA,wBACA;;;;;","names":[],"sources":["../../src/hooks/index.ts"],"sourcesContent":["import { buildHooks, buildWatchHooks } from './build';\nimport { devHooks } from './dev';\nimport { miscHooks } from './misc';\n\nexport const registerHook = {\n ...buildHooks,\n ...devHooks,\n ...miscHooks,\n ...buildWatchHooks,\n};\n"]}
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DevToolData as BaseDevToolData } from '@modern-js/core';
|
|
2
2
|
import { registerHook } from '../hooks';
|
|
3
|
-
import type { BaseBuildConfig, BuildConfig } from './config';
|
|
3
|
+
import type { BaseBuildConfig, BuildConfig, BuildType } from './config';
|
|
4
4
|
import type { DevCommandOptions, BuildCommandOptions } from './command';
|
|
5
5
|
export interface BuildTaskResult {
|
|
6
6
|
status: 'success' | 'fail';
|
|
@@ -22,4 +22,10 @@ export type DevToolData = BaseDevToolData<DevCommandOptions>;
|
|
|
22
22
|
export type PromptResult = {
|
|
23
23
|
choiceDevTool: string;
|
|
24
24
|
} & Record<string, any>;
|
|
25
|
-
export type ModuleToolsHooks = typeof registerHook;
|
|
25
|
+
export type ModuleToolsHooks = typeof registerHook;
|
|
26
|
+
export interface WatchJsHookContext {
|
|
27
|
+
buildConfig: BaseBuildConfig;
|
|
28
|
+
}
|
|
29
|
+
export interface WatchDtsHookContext {
|
|
30
|
+
buildType: BuildType;
|
|
31
|
+
}
|
package/dist/types/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/hooks.ts"],"sourcesContent":["import { DevToolData as BaseDevToolData } from '@modern-js/core';\nimport { registerHook } from '../hooks';\nimport type { BaseBuildConfig, BuildConfig } from './config';\nimport type { DevCommandOptions, BuildCommandOptions } from './command';\n\nexport interface BuildTaskResult {\n status: 'success' | 'fail';\n message?: string;\n config: BaseBuildConfig;\n}\n\nexport interface BuildResult {\n status: 'success' | 'fail';\n message?: string;\n config: BuildConfig;\n commandOptions: BuildCommandOptions;\n totalDuration: number;\n}\nexport interface BuildPlatformResult {\n status: 'success' | 'fail';\n message: string | Error | null;\n}\n\nexport type DevToolData = BaseDevToolData<DevCommandOptions>;\n\nexport type PromptResult = { choiceDevTool: string } & Record<string, any>;\n\nexport type ModuleToolsHooks = typeof registerHook;\n"]}
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/hooks.ts"],"sourcesContent":["import { DevToolData as BaseDevToolData } from '@modern-js/core';\nimport { registerHook } from '../hooks';\nimport type { BaseBuildConfig, BuildConfig, BuildType } from './config';\nimport type { DevCommandOptions, BuildCommandOptions } from './command';\n\nexport interface BuildTaskResult {\n status: 'success' | 'fail';\n message?: string;\n config: BaseBuildConfig;\n}\n\nexport interface BuildResult {\n status: 'success' | 'fail';\n message?: string;\n config: BuildConfig;\n commandOptions: BuildCommandOptions;\n totalDuration: number;\n}\nexport interface BuildPlatformResult {\n status: 'success' | 'fail';\n message: string | Error | null;\n}\n\nexport type DevToolData = BaseDevToolData<DevCommandOptions>;\n\nexport type PromptResult = { choiceDevTool: string } & Record<string, any>;\n\nexport type ModuleToolsHooks = typeof registerHook;\n\nexport interface WatchJsHookContext {\n buildConfig: BaseBuildConfig;\n}\n\nexport interface WatchDtsHookContext {\n buildType: BuildType;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LibuildPlugin } from '@modern-js/libuild';
|
|
2
|
-
import type { BaseBuildConfig } from '../types';
|
|
3
|
-
export declare const watchPlugin: (config: BaseBuildConfig) => LibuildPlugin;
|
|
2
|
+
import type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';
|
|
3
|
+
export declare const watchPlugin: (api: PluginAPI<ModuleTools>, config: BaseBuildConfig) => LibuildPlugin;
|
|
4
4
|
export declare const externalPlugin: (config: BaseBuildConfig, options: {
|
|
5
5
|
appDirectory: string;
|
|
6
6
|
}) => LibuildPlugin;
|
|
@@ -47,7 +47,7 @@ __export(libuild_plugins_exports, {
|
|
|
47
47
|
watchPlugin: () => watchPlugin
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(libuild_plugins_exports);
|
|
50
|
-
const watchPlugin = (config) => {
|
|
50
|
+
const watchPlugin = (api, config) => {
|
|
51
51
|
return {
|
|
52
52
|
name: "watch-plugin",
|
|
53
53
|
apply(compiler) {
|
|
@@ -58,6 +58,8 @@ const watchPlugin = (config) => {
|
|
|
58
58
|
console.info(
|
|
59
59
|
yield watchSectionTitle(titleText, SectionTitleStatus.Log)
|
|
60
60
|
);
|
|
61
|
+
const runner = api.useHookRunners();
|
|
62
|
+
runner.buildWatchJs({ buildConfig: config });
|
|
61
63
|
}));
|
|
62
64
|
}
|
|
63
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuild-plugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.3.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@modern-js/libuild": "~0.
|
|
40
|
-
"@modern-js/libuild-plugin-svgr": "~0.
|
|
41
|
-
"@modern-js/libuild-plugin-swc": "~0.
|
|
42
|
-
"@modern-js/core": "2.
|
|
43
|
-
"@modern-js/new-action": "2.
|
|
44
|
-
"@modern-js/plugin": "2.
|
|
45
|
-
"@modern-js/plugin-i18n": "2.
|
|
46
|
-
"@modern-js/upgrade": "2.
|
|
47
|
-
"@modern-js/utils": "2.
|
|
48
|
-
"@modern-js/plugin-changeset": "2.
|
|
49
|
-
"@modern-js/plugin-lint": "2.
|
|
39
|
+
"@modern-js/libuild": "~0.9.0",
|
|
40
|
+
"@modern-js/libuild-plugin-svgr": "~0.9.0",
|
|
41
|
+
"@modern-js/libuild-plugin-swc": "~0.9.0",
|
|
42
|
+
"@modern-js/core": "2.3.0",
|
|
43
|
+
"@modern-js/new-action": "2.3.0",
|
|
44
|
+
"@modern-js/plugin": "2.3.0",
|
|
45
|
+
"@modern-js/plugin-i18n": "2.3.0",
|
|
46
|
+
"@modern-js/upgrade": "2.3.0",
|
|
47
|
+
"@modern-js/utils": "2.3.0",
|
|
48
|
+
"@modern-js/plugin-changeset": "2.3.0",
|
|
49
|
+
"@modern-js/plugin-lint": "2.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@modern-js/self": "npm:@modern-js/module-tools@*",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"postcss-alias": "2.0.0",
|
|
61
61
|
"react": "17",
|
|
62
62
|
"typescript": "^4",
|
|
63
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
64
|
-
"@scripts/
|
|
65
|
-
"@scripts/
|
|
63
|
+
"@modern-js/builder-webpack-provider": "2.3.0",
|
|
64
|
+
"@scripts/build": "2.3.0",
|
|
65
|
+
"@scripts/jest-config": "2.3.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/",
|