@modern-js/module-tools 2.12.0 → 2.13.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 2.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ab79a7b]
8
+ - @modern-js/core@2.13.1
9
+ - @modern-js/plugin-changeset@2.13.1
10
+ - @modern-js/plugin-lint@2.13.1
11
+ - @modern-js/plugin-i18n@2.13.1
12
+ - @modern-js/new-action@2.13.1
13
+ - @modern-js/plugin@2.13.1
14
+ - @modern-js/upgrade@2.13.1
15
+ - @modern-js/utils@2.13.1
16
+
17
+ ## 2.13.0
18
+
19
+ ### Patch Changes
20
+
21
+ - 034f36b: feat: set the default language of CLI to English
22
+
23
+ feat: 将命令行的默认语言设置为英文
24
+
25
+ - 88faab3: feat: use `declarationDir` instead of `outDir`
26
+ feat: 使用 `declarationDir` 替换 `outDir`
27
+ - 034f36b: fix(upgrade): i18n of upgrade command not work
28
+
29
+ fix(upgrade): 修复 upgrade 命令的 i18n 配置不生效的问题
30
+
31
+ - 79bc089: fix(module-tools): fix noClear option not work
32
+ fix(module-tools): 修复 noClear 配置不生效
33
+ - Updated dependencies [e9b1656]
34
+ - Updated dependencies [e91ec97]
35
+ - Updated dependencies [034f36b]
36
+ - Updated dependencies [78431f4]
37
+ - Updated dependencies [034f36b]
38
+ - @modern-js/core@2.13.0
39
+ - @modern-js/plugin-changeset@2.13.0
40
+ - @modern-js/plugin-i18n@2.13.0
41
+ - @modern-js/upgrade@2.13.0
42
+ - @modern-js/plugin@2.13.0
43
+ - @modern-js/plugin-lint@2.13.0
44
+ - @modern-js/new-action@2.13.0
45
+ - @modern-js/utils@2.13.0
46
+
3
47
  ## 2.12.0
4
48
 
5
49
  ### Minor Changes
package/dist/command.js CHANGED
@@ -134,7 +134,7 @@ const newCommand = (program) => __async(void 0, null, function* () {
134
134
  local.i18n.t(local.localeKeys.command.new.distTag)
135
135
  ).option("--lang <lang>", local.i18n.t(local.localeKeys.command.new.lang)).option("--registry", local.i18n.t(local.localeKeys.command.new.registry)).action((options) => __async(void 0, null, function* () {
136
136
  const { ModuleNewAction } = yield Promise.resolve().then(() => __toESM(require("@modern-js/new-action")));
137
- const { getLocaleLanguage } = yield Promise.resolve().then(() => __toESM(require("./utils/language")));
137
+ const { getLocaleLanguage } = yield Promise.resolve().then(() => __toESM(require("@modern-js/plugin-i18n/language-detector")));
138
138
  const locale = getLocaleLanguage();
139
139
  yield ModuleNewAction(__spreadProps(__spreadValues({}, options), { locale: options.lang || locale }));
140
140
  }));
@@ -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,UAAU;AACrC,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO,iBAAiB;AAE9D,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,QAAQ,MAAM,KAAK,CAAC,EACxE;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ;AAAA,IACpD;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ;AAAA,EACtD,EACC,OAAO,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,EACnE,OAAO,cAAc,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ,MAAM,OAAO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ginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.noClear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.dev.tsconfig),\n defaultTsConfigPath,\n )\n .action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n\n // TODO: watch build\n // const { ensureFirstBuild, watchBuild } = await import('./dev');\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--lang <lang>', local.i18n.t(local.localeKeys.command.new.lang))\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import('./utils/language');\n const locale = getLocaleLanguage();\n\n await ModuleNewAction({ ...options, locale: options.lang || locale });\n });\n};\n\nexport const upgradCommand = async (program: Command) => {\n const { defineCommand } = await import('@modern-js/upgrade');\n defineCommand(program.command('upgrade'));\n};\n"]}
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,UAAU;AACrC,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO,iBAAiB;AAE9D,UACG,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,YAAY,MAAM,KAAK,EAAE,MAAM,WAAW,QAAQ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E,gBAAgB,IAAI,MAAM,6CAAO,uBAAuB;AAChE,UAAM,EAAE,kBAAkB,IAAI,MAAM,6CAClC,0CACF;AAEA,UAAM,SAAS,kBAAkB;AAEjC,UAAM,gBAAgB,iCAAK,UAAL,EAAc,QAAQ,QAAQ,QAAQ,OAAO,EAAC;AAAA,EACtE,EAAC;AACL;AAEO,MAAM,gBAAgB,CAAO,YAAqB;AACvD,QAAM,EAAE,cAAc,IAAI,MAAM,6CAAO,oBAAoB;AAC3D,gBAAc,QAAQ,QAAQ,SAAS,CAAC;AAC1C;;;;;;;;","names":[],"sources":["../src/command.ts"],"sourcesContent":["import type { Command } from '@modern-js/utils';\nimport type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from './types';\nimport type { DevCommandOptions, BuildCommandOptions } from './types/command';\n\nexport const buildCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n\n program\n .command('build')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.build.describe))\n .option('-w, --watch', local.i18n.t(local.localeKeys.command.build.watch))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.build.tsconfig),\n defaultTsConfigPath,\n )\n .option(\n '-p, --platform [platform...]',\n local.i18n.t(local.localeKeys.command.build.platform),\n )\n .option('--no-dts', local.i18n.t(local.localeKeys.command.build.dts))\n .option('--no-clear', local.i18n.t(local.localeKeys.command.build.noClear))\n .option(\n '-c --config <config>',\n local.i18n.t(local.localeKeys.command.build.config),\n )\n .action(async (options: BuildCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { build } = await import('./build');\n await build(api, options, context);\n });\n};\n\nexport const devCommand = async (\n program: Command,\n api: PluginAPI<ModuleTools>,\n) => {\n const local = await import('./locale');\n const { defaultTsConfigPath } = await import('./constants/dts');\n const runner = api.useHookRunners();\n const devToolMetas = await runner.registerDev();\n\n await runner.beforeDev(devToolMetas);\n\n const devProgram = program\n .command('dev')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.dev.describe))\n .option(\n '--tsconfig [tsconfig]',\n local.i18n.t(local.localeKeys.command.dev.tsconfig),\n defaultTsConfigPath,\n )\n .action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n const { dev } = await import('./dev');\n await dev(options, devToolMetas, api, context);\n });\n\n for (const meta of devToolMetas) {\n if (!meta.subCommands) {\n continue;\n }\n\n for (const subCmd of meta.subCommands) {\n devProgram.command(subCmd).action(async (options: DevCommandOptions) => {\n const { initModuleContext } = await import('./utils/context');\n const context = await initModuleContext(api);\n\n // TODO: watch build\n // const { ensureFirstBuild, watchBuild } = await import('./dev');\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n });\n }\n }\n};\n\nexport const newCommand = async (program: Command) => {\n const local = await import('./locale');\n\n program\n .command('new')\n .usage('[options]')\n .description(local.i18n.t(local.localeKeys.command.new.describe))\n .option(\n '-d, --debug',\n local.i18n.t(local.localeKeys.command.new.debug),\n false,\n )\n .option(\n '-c, --config <config>',\n local.i18n.t(local.localeKeys.command.new.config),\n )\n .option(\n '--dist-tag <tag>',\n local.i18n.t(local.localeKeys.command.new.distTag),\n )\n .option('--lang <lang>', local.i18n.t(local.localeKeys.command.new.lang))\n .option('--registry', local.i18n.t(local.localeKeys.command.new.registry))\n .action(async options => {\n const { ModuleNewAction } = await import('@modern-js/new-action');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n\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"]}
@@ -29,7 +29,7 @@ const i18nPlugin = import_utils.Import.lazy(
29
29
  require
30
30
  );
31
31
  const i18n = new i18nPlugin.I18n();
32
- const localeKeys = i18n.init("zh", { zh: import_zh.ZH_LOCALE, en: import_en.EN_LOCALE });
32
+ const localeKeys = i18n.init("en", { zh: import_zh.ZH_LOCALE, en: import_en.EN_LOCALE });
33
33
  // Annotate the CommonJS export names for ESM import in node:
34
34
  0 && (module.exports = {
35
35
  i18n,
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,gBAA0B;AAC1B,gBAA0B;AAE1B,MAAM,aAAsD,oBAAO;AAAA,EACjE;AAAA,EACA;AACF;AAEA,MAAM,OAAO,IAAI,WAAW,KAAK;AAEjC,MAAM,aAAa,KAAK,KAAK,MAAM,EAAE,IAAI,qBAAW,IAAI,oBAAU,CAAC;;;;;;","names":[],"sources":["../../src/locale/index.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nimport { ZH_LOCALE } from './zh';\nimport { EN_LOCALE } from './en';\n\nconst i18nPlugin: typeof import('@modern-js/plugin-i18n') = Import.lazy(\n '@modern-js/plugin-i18n',\n require,\n);\n\nconst i18n = new i18nPlugin.I18n();\n\nconst localeKeys = i18n.init('zh', { zh: ZH_LOCALE, en: EN_LOCALE });\n\nexport { i18n, localeKeys };\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,gBAA0B;AAC1B,gBAA0B;AAE1B,MAAM,aAAsD,oBAAO;AAAA,EACjE;AAAA,EACA;AACF;AAEA,MAAM,OAAO,IAAI,WAAW,KAAK;AAEjC,MAAM,aAAa,KAAK,KAAK,MAAM,EAAE,IAAI,qBAAW,IAAI,oBAAU,CAAC;;;;;;","names":[],"sources":["../../src/locale/index.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nimport { ZH_LOCALE } from './zh';\nimport { EN_LOCALE } from './en';\n\nconst i18nPlugin: typeof import('@modern-js/plugin-i18n') = Import.lazy(\n '@modern-js/plugin-i18n',\n require,\n);\n\nconst i18n = new i18nPlugin.I18n();\n\nconst localeKeys = i18n.init('en', { zh: ZH_LOCALE, en: EN_LOCALE });\n\nexport { i18n, localeKeys };\n"]}
@@ -13,6 +13,7 @@ export interface ITsconfig {
13
13
  rootDir?: string;
14
14
  baseUrl?: string;
15
15
  declaration?: boolean;
16
+ declarationDir?: string;
16
17
  emitDeclarationOnly?: boolean;
17
18
  emitDecoratorMetadata?: boolean;
18
19
  isolatedModules?: boolean;
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/dts.ts"],"sourcesContent":["import type { AliasOption } from './config';\n\nexport interface BundlelessGeneratorDtsConfig {\n appDirectory: string;\n distAbsPath: string;\n tsconfigPath: string;\n watch: boolean;\n sourceDir: string;\n alias: AliasOption;\n abortOnError?: boolean;\n}\n\nexport interface ITsconfig {\n compilerOptions?:\n | {\n rootDir?: string;\n baseUrl?: string;\n declaration?: boolean;\n emitDeclarationOnly?: boolean;\n emitDecoratorMetadata?: boolean;\n isolatedModules?: boolean;\n allowJs?: boolean;\n outDir?: string;\n paths?: Record<string, string[]>;\n }\n | undefined;\n include?: string[];\n exclude?: string[];\n extends?: string;\n}\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/dts.ts"],"sourcesContent":["import type { AliasOption } from './config';\n\nexport interface BundlelessGeneratorDtsConfig {\n appDirectory: string;\n distAbsPath: string;\n tsconfigPath: string;\n watch: boolean;\n sourceDir: string;\n alias: AliasOption;\n abortOnError?: boolean;\n}\n\nexport interface ITsconfig {\n compilerOptions?:\n | {\n rootDir?: string;\n baseUrl?: string;\n declaration?: boolean;\n declarationDir?: string;\n emitDeclarationOnly?: boolean;\n emitDecoratorMetadata?: boolean;\n isolatedModules?: boolean;\n allowJs?: boolean;\n outDir?: string;\n paths?: Record<string, string[]>;\n }\n | undefined;\n include?: string[];\n exclude?: string[];\n extends?: string;\n}\n"]}
package/dist/utils/dts.js CHANGED
@@ -99,7 +99,12 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
99
99
  // Ensure that .d.ts files are created by tsc, but not .js files
100
100
  declaration: true,
101
101
  emitDeclarationOnly: true,
102
- outDir: tempDistAbsOurDir
102
+ // when `outDir` is './dist', `declarationDir` is `./types`
103
+ // tsc will emit:
104
+ // - ./dist/index.js
105
+ // - ./types/index.d.ts
106
+ // we only want to emit declarations
107
+ declarationDir: tempDistAbsOurDir
103
108
  }
104
109
  };
105
110
  fs.writeJSONSync(tempTsconfigPath, resetConfig);
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAaV,MAAM,oBAAoB,CAC/B,WACG;AACH,QAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAE5D,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAAA,EAChC;AACA,QAAM,oBAAoB,oBAAK;AAAA,IAC7B;AAAA,IACA,oBAAK,SAAS,cAAc,YAAY;AAAA,EAC1C;AAEA,QAAM,mBAAmB,oBAAK;AAAA,IAC5B;AAAA,IACA,oBAAK,SAAS,YAAY;AAAA,EAC5B;AACA,KAAG,eAA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ACF;AAAA,EACF;AACF;;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\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 outDir: 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 ...(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(local.i18n.t(local.localeKeys.dts.abortOnError)),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAaV,MAAM,oBAAoB,CAC/B,WACG;AACH,QAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAE5D,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAA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;AAAA,QAChC;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,aAAO;AAAA,QACL,MAAM,eAAe,MAAM,KAAK,EAAE,MAAM,WAAW,IAAI,YAAY,CAAC;AAAA,MACtE;AACA,aAAO;AAAA,QACL,IAAI,iBAAiB,OAAO;AAAA,UAC1B;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\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 ...(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(local.i18n.t(local.localeKeys.dts.abortOnError)),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
@@ -1,2 +1 @@
1
- export declare function getLocaleLanguage(): string;
2
1
  export declare const initLocalLanguage: () => Promise<typeof import("../locale")>;
@@ -47,25 +47,18 @@ var __async = (__this, __arguments, generator) => {
47
47
  };
48
48
  var language_exports = {};
49
49
  __export(language_exports, {
50
- getLocaleLanguage: () => getLocaleLanguage,
51
50
  initLocalLanguage: () => initLocalLanguage
52
51
  });
53
52
  module.exports = __toCommonJS(language_exports);
54
- var import_utils = require("@modern-js/utils");
55
- const i18n = import_utils.Import.lazy("@modern-js/plugin-i18n/language-detector", require);
56
- function getLocaleLanguage() {
57
- const detector = new i18n.I18CLILanguageDetector();
58
- return detector.detect();
59
- }
60
53
  const initLocalLanguage = () => __async(void 0, null, function* () {
61
54
  const local = yield Promise.resolve().then(() => __toESM(require("../locale")));
55
+ const { getLocaleLanguage } = yield Promise.resolve().then(() => __toESM(require("@modern-js/plugin-i18n/language-detector")));
62
56
  const locale = getLocaleLanguage();
63
57
  local.i18n.changeLanguage({ locale });
64
58
  return local;
65
59
  });
66
60
  // Annotate the CommonJS export names for ESM import in node:
67
61
  0 && (module.exports = {
68
- getLocaleLanguage,
69
62
  initLocalLanguage
70
63
  });
71
64
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,MAAM,OACJ,oBAAO,KAAK,4CAA4C,OAAO;AAE1D,SAAS,oBAAoB;AAClC,QAAM,WAAW,IAAI,KAAK,uBAAuB;AACjD,SAAO,SAAS,OAAO;AACzB;AAEO,MAAM,oBAAoB,MAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nconst i18n: typeof import('@modern-js/plugin-i18n/language-detector') =\n Import.lazy('@modern-js/plugin-i18n/language-detector', require);\n\nexport function getLocaleLanguage() {\n const detector = new i18n.I18CLILanguageDetector();\n return detector.detect();\n}\n\nexport const initLocalLanguage = async () => {\n const local = await import('../locale');\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,oBAAoB,MAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAClC,0CACF;AACA,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["export const initLocalLanguage = async () => {\n const local = await import('../locale');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "module-tools",
12
12
  "lib-tools"
13
13
  ],
14
- "version": "2.12.0",
14
+ "version": "2.13.1",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js",
17
17
  "modern-module": "./bin/modern.js"
@@ -39,14 +39,14 @@
39
39
  "@modern-js/libuild": "~0.11.9",
40
40
  "@modern-js/libuild-plugin-svgr": "~0.11.9",
41
41
  "@modern-js/libuild-plugin-swc": "~0.11.9",
42
- "@modern-js/core": "2.12.0",
43
- "@modern-js/new-action": "2.12.0",
44
- "@modern-js/plugin": "2.12.0",
45
- "@modern-js/plugin-changeset": "2.12.0",
46
- "@modern-js/plugin-i18n": "2.12.0",
47
- "@modern-js/plugin-lint": "2.12.0",
48
- "@modern-js/upgrade": "2.12.0",
49
- "@modern-js/utils": "2.12.0"
42
+ "@modern-js/core": "2.13.1",
43
+ "@modern-js/new-action": "2.13.1",
44
+ "@modern-js/plugin": "2.13.1",
45
+ "@modern-js/plugin-changeset": "2.13.1",
46
+ "@modern-js/plugin-i18n": "2.13.1",
47
+ "@modern-js/plugin-lint": "2.13.1",
48
+ "@modern-js/upgrade": "2.13.1",
49
+ "@modern-js/utils": "2.13.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/fs-extra": "9.0.13",
@@ -60,10 +60,10 @@
60
60
  "postcss-alias": "2.0.0",
61
61
  "react": "17",
62
62
  "typescript": "^4",
63
- "@modern-js/builder-webpack-provider": "2.12.0",
64
- "@modern-js/self": "npm:@modern-js/module-tools@2.12.0",
65
- "@scripts/build": "2.12.0",
66
- "@scripts/jest-config": "2.12.0"
63
+ "@modern-js/builder-webpack-provider": "2.13.1",
64
+ "@modern-js/self": "npm:@modern-js/module-tools@2.13.1",
65
+ "@scripts/build": "2.13.1",
66
+ "@scripts/jest-config": "2.13.1"
67
67
  },
68
68
  "publishConfig": {
69
69
  "registry": "https://registry.npmjs.org/",