@modern-js/module-tools 2.22.2-beta.0 → 2.22.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,14 +134,27 @@ const buildLib = async (config, api, options) => {
134
134
  format,
135
135
  disableSwcTransform
136
136
  })) {
137
- var _userTsconfig_compilerOptions;
137
+ var _userTsconfig_compilerOptions, _userTsconfig_compilerOptions1, _userTsconfig_compilerOptions2;
138
+ const { tsTargetAtOrAboveES2022 } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../utils/dts")));
139
+ const tsUseDefineForClassFields = userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.useDefineForClassFields;
140
+ let tsTarget = userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions1 = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions1 === void 0 ? void 0 : _userTsconfig_compilerOptions1.target;
141
+ tsTarget = tsTarget ? tsTarget.toLowerCase() : void 0;
142
+ let useDefineForClassFields;
143
+ if (tsUseDefineForClassFields !== void 0) {
144
+ useDefineForClassFields = tsUseDefineForClassFields;
145
+ } else if (tsTarget !== void 0) {
146
+ useDefineForClassFields = tsTargetAtOrAboveES2022(tsTarget);
147
+ } else {
148
+ useDefineForClassFields = true;
149
+ }
138
150
  plugins.push(swcTransformPlugin({
139
151
  pluginImport: transformImport,
140
152
  externalHelpers: Boolean(externalHelpers),
141
- emitDecoratorMetadata: userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.emitDecoratorMetadata
153
+ emitDecoratorMetadata: userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions2 = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions2 === void 0 ? void 0 : _userTsconfig_compilerOptions2.emitDecoratorMetadata,
154
+ useDefineForClassFields
142
155
  }));
143
156
  } else {
144
- var _userTsconfig_compilerOptions1;
157
+ var _userTsconfig_compilerOptions3;
145
158
  if (matchEs5PluginCondition({
146
159
  sourceType,
147
160
  buildType,
@@ -151,7 +164,7 @@ const buildLib = async (config, api, options) => {
151
164
  })) {
152
165
  plugins.push(es5Plugin());
153
166
  }
154
- if (userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions1 = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions1 === void 0 ? void 0 : _userTsconfig_compilerOptions1.emitDecoratorMetadata) {
167
+ if (userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions3 = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions3 === void 0 ? void 0 : _userTsconfig_compilerOptions3.emitDecoratorMetadata) {
155
168
  plugins.push(legacyTransformPlugin({
156
169
  jsc: {
157
170
  transform: {
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,cAAY;WAAZA;;EAqBAC,kBAAgB;WAAhBA;;EAyBAC,kBAAgB;WAAhBA;;EAmBAC,cAAY;WAAZA;;EAuCAC,UAAQ;WAARA;;;;sBApHQ;wBACE;AAWhB,MAAMJ,eAAe,OAC1BK,SAKAC,QACG;AACH,QAAM,EAAEC,aAAaC,SAASC,gBAAe,IAAKJ;AAClD,QAAM,EAAEK,cAAcC,YAAW,IAAKH;AAEtC,QAAM,EAAEI,SAAQ,IAAK,MAAM,iFAAO;AAClC,QAAMA,SAASL,aAAa;IAAEG;IAAcG,OAAOJ,gBAAgBI;EAAM;AAEzE,MAAIF,aAAa;AACf,UAAMV,iBAAiBI,SAASC;EAClC,OAAO;AACL,UAAMJ,iBAAiBG,SAASC;EAClC;AACF;AAEO,MAAML,mBAAmB,OAC9BI,SAKAC,QACG;AACH,QAAM,EAAE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O;AACnC,UAAM,EAAEC,eAAc,IAAK,MAAM,iFAAO;AACxC,UAAMC,SAASjG,IAAIkG,eAAc;AACjC,UAAMC,sBAAsB,MAAMF,OAAOG,cAAcnG,aAAa;MAClEoG,QAAQC,OAAKA;IACf;AAEA,UAAMC,UAAU,MAAMR,UAAUS,OAAOL;AACvC,UAAMI,QAAQE,MAAK;AACnBT,mBAAeO,QAAQG,aAAanD,MAAMrC,cAAc;AAExD,QAAIX,OAAO;AACT,YAAM,EAAEoG,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,YAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,YAAMC,YAAY,IAChB3F,cAAc,WAAW,WAAW,iBACjCgB,UAAUF;AAEf8E,qBAAOC,KACL,MAAMJ,kBAAkBE,WAAWD,mBAAmBI,OAAO;IAEjE;EACF,SAASC,GAAP;AACA,UAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,UAAM,IAAIA,mBAAmBD,GAAG;MAC9BjF;MACAE;MACAhB;IACF;EACF;AACF;","names":["runBuildTask","buildInTsProject","buildInJsProject","generatorDts","buildLib","options","api","buildConfig","context","buildCmdOptions","appDirectory","isTsProject","copyTask","watch","dts","skipBuildLib","only","tasks","default","pMap","task","config","runRollup","runTsc","buildType","input","sourceDir","alias","useAppContext","tsconfigPath","distPath","abortOnError","respectExternal","getFinalExternals","finalExternals","distDir","externals","distAbsPath","target","sourceMap","format","outDir","asset","jsx","platform","splitting","minify","umdGlobals","umdModuleName","define","style","autoExternal","metafile","sideEffects","redirect","esbuildOptions","externalHelpers","transformImport","sourceType","disableSwcTransform","slash","root","outdir","assetOutDir","path","less","sass","postcss","inject","modules","autoModules","umdPlugin","swcTransformPlugin","transformPlugin","legacyTransformPlugin","es5Plugin","checkSwcHelpers","matchEs5PluginCondition","matchSwcTransformCondition","getProjectTsconfig","join","userTsconfig","plugins","push","pluginImport","Boolean","emitDecoratorMetadata","compilerOptions","jsc","transform","legacyDecorator","decoratorMetadata","svgr","svgrPlugin","watchPlugin","externalPlugin","resolve","globals","external","bundle","outbase","Libuilder","addOutputChunk","runner","useHookRunners","modifiedBuildConfig","modifyLibuild","onLast","c","builder","create","build","outputChunk","watchSectionTitle","SectionTitleStatus","titleText","logger","info","Success","e","InternalBuildError"],"sources":["../../src/builder/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/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, respectExternal } = 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 respectExternal,\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 redirect,\n esbuildOptions,\n externalHelpers,\n transformImport,\n sourceType,\n disableSwcTransform,\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 swc-transform, umd and emitDecoratorMetadata by swc\n const {\n umdPlugin,\n swcTransformPlugin,\n transformPlugin: legacyTransformPlugin,\n es5Plugin,\n } = await import('@modern-js/libuild-plugin-swc');\n const {\n checkSwcHelpers,\n matchEs5PluginCondition,\n matchSwcTransformCondition,\n } = await import('../utils/builder');\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\n const plugins = [];\n\n if (\n matchSwcTransformCondition({\n sourceType,\n buildType,\n format,\n disableSwcTransform,\n })\n ) {\n plugins.push(\n swcTransformPlugin({\n pluginImport: transformImport,\n externalHelpers: Boolean(externalHelpers),\n emitDecoratorMetadata:\n userTsconfig?.compilerOptions?.emitDecoratorMetadata,\n }),\n );\n } else {\n if (\n matchEs5PluginCondition({\n sourceType,\n buildType,\n format,\n target,\n disableSwcTransform,\n })\n ) {\n plugins.push(es5Plugin());\n }\n\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n legacyTransformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n }\n\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n\n await checkSwcHelpers({ appDirectory, externalHelpers });\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 redirect,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions,\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"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAaaA,cAAY;WAAZA;;EAqBAC,kBAAgB;WAAhBA;;EAyBAC,kBAAgB;WAAhBA;;EAmBAC,cAAY;WAAZA;;EAuCAC,UAAQ;WAARA;;;;sBArHQ;wBACE;AAYhB,MAAMJ,eAAe,OAC1BK,SAKAC,QACG;AACH,QAAM,EAAEC,aAAaC,SAASC,gBAAe,IAAKJ;AAClD,QAAM,EAAEK,cAAcC,YAAW,IAAKH;AAEtC,QAAM,EAAEI,SAAQ,IAAK,MAAM,iFAAO;AAClC,QAAMA,SAASL,aAAa;IAAEG;IAAcG,OAAOJ,gBAAgBI;EAAM;AAEzE,MAAIF,aAAa;AACf,UAAMV,iBAAiBI,SAASC;EAClC,OAAO;AACL,UAAMJ,iBAAiBG,SAASC;EAClC;AACF;AAEO,MAAML,mBAAmB,OAC9BI,SAKAC,QACG;AACH,Q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AC7BsD;IACAhD;IACAyB;IACAC;IACAC;IACAsB;IACAb;IACAC,OAAO;MACLe;MACAC;MACAC;MACAC;MACAC;MACAC;IACF;IACAgC,SAAS;MACP3E;IACF;IACAe,OAAO;MACL,GAAGA;MACHoB,QAAQC;IACV;IACAmB;IACAvC;IACAlB;IACAmB;IACAC;IACAC;IACApB;IACA0B,UAAUA,YAAY5B,cAAc;IACpC+E,SAASxD;IACTyD,UAAUpE;IACVe;IACAG;IACAmD,QAAQjF,cAAc;IACtB6B;;IAEAqD,SAAShF;IACT6B;EACF;AAEA,MAAI;AACF,UAAM,EAAEoD,UAAS,IAAK,MAAM,iFAAO;AACnC,UAAM,EAAEC,eAAc,IAAK,MAAM,iFAAO;AACxC,UAAMC,SAASvG,IAAIwG,eAAc;AACjC,UAAMC,sBAAsB,MAAMF,OAAOG,cAAczG,aAAa;MAClE0G,QAAQC,OAAKA;IACf;AAEA,UAAMC,UAAU,MAAMR,UAAUS,OAAOL;AACvC,UAAMI,QAAQE,MAAK;AACnBT,mBAAeO,QAAQG,aAAazD,MAAMrC,cAAc;AAExD,QAAIX,OAAO;AACT,YAAM,EAAE0G,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,YAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,YAAMC,YAAY,IAChBjG,cAAc,WAAW,WAAW,iBACjCgB,UAAUF;AAEfoF,qBAAOC,KACL,MAAMJ,kBAAkBE,WAAWD,mBAAmBI,OAAO;IAEjE;EACF,SAASC,GAAP;AACA,UAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,UAAM,IAAIA,mBAAmBD,GAAG;MAC9BvF;MACAE;MACAhB;IACF;EACF;AACF;","names":["runBuildTask","buildInTsProject","buildInJsProject","generatorDts","buildLib","options","api","buildConfig","context","buildCmdOptions","appDirectory","isTsProject","copyTask","watch","dts","skipBuildLib","only","tasks","default","pMap","task","config","runRollup","runTsc","buildType","input","sourceDir","alias","useAppContext","tsconfigPath","distPath","abortOnError","respectExternal","getFinalExternals","finalExternals","distDir","externals","distAbsPath","target","sourceMap","format","outDir","asset","jsx","platform","splitting","minify","umdGlobals","umdModuleName","define","style","autoExternal","metafile","sideEffects","redirect","esbuildOptions","externalHelpers","transformImport","sourceType","disableSwcTransform","slash","root","outdir","assetOutDir","path","less","sass","postcss","inject","modules","autoModules","umdPlugin","swcTransformPlugin","transformPlugin","legacyTransformPlugin","es5Plugin","checkSwcHelpers","matchEs5PluginCondition","matchSwcTransformCondition","getProjectTsconfig","join","userTsconfig","plugins","tsTargetAtOrAboveES2022","tsUseDefineForClassFields","compilerOptions","useDefineForClassFields","tsTarget","toLowerCase","undefined","push","pluginImport","Boolean","emitDecoratorMetadata","jsc","transform","legacyDecorator","decoratorMetadata","svgr","svgrPlugin","watchPlugin","externalPlugin","resolve","globals","external","bundle","outbase","Libuilder","addOutputChunk","runner","useHookRunners","modifiedBuildConfig","modifyLibuild","onLast","c","builder","create","build","outputChunk","watchSectionTitle","SectionTitleStatus","titleText","logger","info","Success","e","InternalBuildError"],"sources":["../../src/builder/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/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 TsTarget,\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, respectExternal } = 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 respectExternal,\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 redirect,\n esbuildOptions,\n externalHelpers,\n transformImport,\n sourceType,\n disableSwcTransform,\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 swc-transform, umd and emitDecoratorMetadata by swc\n const {\n umdPlugin,\n swcTransformPlugin,\n transformPlugin: legacyTransformPlugin,\n es5Plugin,\n } = await import('@modern-js/libuild-plugin-swc');\n const {\n checkSwcHelpers,\n matchEs5PluginCondition,\n matchSwcTransformCondition,\n } = await import('../utils/builder');\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\n const plugins = [];\n\n if (\n matchSwcTransformCondition({\n sourceType,\n buildType,\n format,\n disableSwcTransform,\n })\n ) {\n // TODO: refactor config plugins logic\n\n const { tsTargetAtOrAboveES2022 } = await import('../utils/dts');\n const tsUseDefineForClassFields =\n userTsconfig?.compilerOptions?.useDefineForClassFields;\n let tsTarget = userTsconfig?.compilerOptions?.target;\n tsTarget = tsTarget ? (tsTarget.toLowerCase() as TsTarget) : undefined;\n let useDefineForClassFields: boolean;\n if (tsUseDefineForClassFields !== undefined) {\n useDefineForClassFields = tsUseDefineForClassFields;\n } else if (tsTarget !== undefined) {\n useDefineForClassFields = tsTargetAtOrAboveES2022(tsTarget);\n } else {\n useDefineForClassFields = true;\n }\n\n plugins.push(\n swcTransformPlugin({\n pluginImport: transformImport,\n externalHelpers: Boolean(externalHelpers),\n emitDecoratorMetadata:\n userTsconfig?.compilerOptions?.emitDecoratorMetadata,\n useDefineForClassFields,\n }),\n );\n } else {\n if (\n matchEs5PluginCondition({\n sourceType,\n buildType,\n format,\n target,\n disableSwcTransform,\n })\n ) {\n plugins.push(es5Plugin());\n }\n\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n legacyTransformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n }\n\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n\n await checkSwcHelpers({ appDirectory, externalHelpers });\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 redirect,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions,\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"]}
@@ -8,6 +8,7 @@ export interface BundlelessGeneratorDtsConfig {
8
8
  alias: AliasOption;
9
9
  abortOnError?: boolean;
10
10
  }
11
+ export type TsTarget = 'es3' | 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
11
12
  export interface ITsconfig {
12
13
  compilerOptions?: {
13
14
  rootDir?: string;
@@ -20,6 +21,8 @@ export interface ITsconfig {
20
21
  allowJs?: boolean;
21
22
  outDir?: string;
22
23
  paths?: Record<string, string[]>;
24
+ target?: TsTarget;
25
+ useDefineForClassFields?: boolean;
23
26
  } | undefined;
24
27
  include?: string[];
25
28
  exclude?: string[];
@@ -1,4 +1,4 @@
1
- import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildCommandOptions, BaseBuildConfig, BuildType } from '../types';
1
+ import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildCommandOptions, BaseBuildConfig, BuildType, TsTarget } from '../types';
2
2
  export declare const generatorTsConfig: (config: BundlelessGeneratorDtsConfig) => Promise<{
3
3
  tempTsconfigPath: string;
4
4
  tempDistAbsRootPath: string;
@@ -15,4 +15,5 @@ export declare const assignTsConfigPath: (config: BaseBuildConfig, options: Buil
15
15
  export declare const printOrThrowDtsErrors: (error: unknown, options: {
16
16
  abortOnError?: boolean;
17
17
  buildType: BuildType;
18
- }) => Promise<void>;
18
+ }) => Promise<void>;
19
+ export declare const tsTargetAtOrAboveES2022: (target: TsTarget) => boolean;
package/dist/utils/dts.js CHANGED
@@ -24,6 +24,9 @@ _export(exports, {
24
24
  },
25
25
  printOrThrowDtsErrors: function() {
26
26
  return printOrThrowDtsErrors;
27
+ },
28
+ tsTargetAtOrAboveES2022: function() {
29
+ return tsTargetAtOrAboveES2022;
27
30
  }
28
31
  });
29
32
  const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
@@ -131,5 +134,6 @@ const printOrThrowDtsErrors = async (error, options) => {
131
134
  }
132
135
  }
133
136
  };
137
+ const tsTargetAtOrAboveES2022 = (target) => target === "es2022" || target === "esnext";
134
138
 
135
139
  //# sourceMappingURL=dts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAUaA,mBAAiB;WAAjBA;;EAmDAC,eAAa;WAAbA;;EA0BAC,cAAY;WAAZA;;EA6EAC,oBAAkB;WAAlBA;;EAwBAC,uBAAqB;WAArBA;;;;;iEA5LI;AAUV,MAAMJ,oBAAoB,OAC/BK,WACG;AACH,QAAM,EAAEC,IAAIC,OAAM,IAAK,MAAM,iFAAO;AACpC,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAE1C,QAAM,EAAEC,cAAcC,WAAWC,cAAcC,aAAY,IAAKP;AAChE,QAAMQ,sBAAsBC,cAAKC,KAC/BN,cACA,GAAGD,oBAAoBD,UAAU;AAEnC,QAAMS,oBAAoBF,cAAKC,KAC7BF,qBACAC,cAAKG,SAASR,cAAcE;AAG9B,QAAMO,mBAAmBJ,cAAKC,KAC5BF,qBACAC,cAAKK,SAASP;AAEhBN,KAAGc,eAAeF;AAElB,QAAMG,cAAcP,cAAKC,KACvBD,cAAKG,SAASH,cAAKQ,QAAQJ,mBAAmBJ,cAAKQ,QAAQV,gBAC3DE,cAAKK,SAASD;AAGhB,QAAMK,cAAyB;IAC7BC,SAASH;IACTI,iBAAiB;;MAEfC,aAAa;MACbC,qBAAqB;;;;;;MAMrBC,gBAAgBZ;IAClB;EACF;AAEAV,KAAGuB,cAAcX,kBAA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G;AACH,QAAM,EAAEmB,oBAAmB,IAAK,MAAM,iFAAO;AAG7C,MACE,OAAOnB,QAAQoB,aAAa,YAC5BpB,QAAQoB,aAAaD,qBACrB;QAMMzD;AALNA,WAAO2D,MAAM;MACXC,MAAM;MACNC,UAAU;MACVC,cAAc;MACdC,iBAAiB;MACjB,IAAI/D,qBAAO2D,SAAG,QAAV3D,uCAAc,CAAC;MACnBO,cAAc+B,QAAQoB;IACxB;EACF;AAEA,SAAO1D;AACT;AAEO,MAAMD,wBAAwB,OACnCiE,OACA1B,YACG;AACH,QAAM,EAAE2B,QAAQC,MAAK,IAAK,MAAM,iFAAO;AACvC,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAC1C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEN,cAAcO,UAAS,IAAK/B,mDAAW,CAAC;AAChD,MAAI0B,iBAAiB3B,OAAO;AAC1B,QAAIyB,cAAc;AAChB,YAAM,IAAIK,iBAAiBH,OAAO;QAChCK;MACF;IACF,OAAO;AACLJ,aAAOK,KACLJ,MAAMK,eACJH,MAAMI,KAAKC,EAAEL,MAAMM,WAAWC,MAAMhB,IAAIG,YAAY;AAGxDG,aAAOD,MACL,IAAIG,iBAAiBH,OAAO;QAC1BK;MACF;IAEJ;EACF;AACF;","names":["generatorTsConfig","getTscBinPath","resolveAlias","assignTsConfigPath","printOrThrowDtsErrors","config","fs","nanoid","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","globby","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","copy","defaultTsConfigPath","tsconfig","dts","only","distPath","abortOnError","respectExternal","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n respectExternal: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAWaA,mBAAiB;WAAjBA;;EAmDAC,eAAa;WAAbA;;EA0BAC,cAAY;WAAZA;;EA6EAC,oBAAkB;WAAlBA;;EAwBAC,uBAAqB;WAArBA;;EA4BAC,yBAAuB;WAAvBA;;;;;iEAzNI;AAWV,MAAML,oBAAoB,OAC/BM,WACG;AACH,QAAM,EAAEC,IAAIC,OAAM,IAAK,MAAM,iF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,aAAOK,KACLJ,MAAMK,eACJH,MAAMI,KAAKC,EAAEL,MAAMM,WAAWC,MAAMhB,IAAIG,YAAY;AAGxDG,aAAOD,MACL,IAAIG,iBAAiBH,OAAO;QAC1BK;MACF;IAEJ;EACF;AACF;AAEO,MAAMtE,0BAA0B,CAAC6E,WACtCA,WAAW,YAAYA,WAAW;","names":["generatorTsConfig","getTscBinPath","resolveAlias","assignTsConfigPath","printOrThrowDtsErrors","tsTargetAtOrAboveES2022","config","fs","nanoid","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","globby","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","copy","defaultTsConfigPath","tsconfig","dts","only","distPath","abortOnError","respectExternal","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns","target"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n TsTarget,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n respectExternal: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n\nexport const tsTargetAtOrAboveES2022 = (target: TsTarget) =>\n target === 'es2022' || target === 'esnext';\n"]}
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "module-tools",
16
16
  "lib-tools"
17
17
  ],
18
- "version": "2.22.2-beta.0",
18
+ "version": "2.22.2-beta.1",
19
19
  "bin": {
20
20
  "modern": "./bin/modern.js",
21
21
  "modern-module": "./bin/modern.js"
@@ -49,14 +49,14 @@
49
49
  "@modern-js/libuild-plugin-swc": "0.12.5-beta.0",
50
50
  "postcss": "8.4.6",
51
51
  "@swc/helpers": "0.5.1",
52
+ "@modern-js/core": "2.22.1",
53
+ "@modern-js/plugin-i18n": "2.22.1",
52
54
  "@modern-js/new-action": "2.22.1",
53
- "@modern-js/plugin": "2.22.1",
54
55
  "@modern-js/plugin-changeset": "2.22.1",
55
- "@modern-js/plugin-lint": "2.22.1",
56
- "@modern-js/plugin-i18n": "2.22.1",
56
+ "@modern-js/plugin": "2.22.1",
57
57
  "@modern-js/utils": "2.22.1",
58
- "@modern-js/core": "2.22.1",
59
- "@modern-js/upgrade": "2.22.1"
58
+ "@modern-js/upgrade": "2.22.1",
59
+ "@modern-js/plugin-lint": "2.22.1"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/babel__generator": "7.6.4",
@@ -71,7 +71,7 @@
71
71
  "postcss-alias": "2.0.0",
72
72
  "react": "17",
73
73
  "typescript": "^5",
74
- "@modern-js/self": "npm:@modern-js/module-tools@2.22.2-beta.0",
74
+ "@modern-js/self": "npm:@modern-js/module-tools@2.22.2-beta.1",
75
75
  "@modern-js/builder-webpack-provider": "2.22.1",
76
76
  "@scripts/build": "2.22.1",
77
77
  "@scripts/jest-config": "2.22.1"