@modern-js/module-tools 2.19.2-beta.5 → 2.21.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/bin/modern.js +0 -1
  3. package/compiled/postcss-flexbugs-fixes/index.js +1 -1
  4. package/compiled/postcss-font-variant/index.js +1 -1
  5. package/compiled/postcss-initial/index.js +1 -1
  6. package/compiled/postcss-media-minmax/index.js +1 -1
  7. package/compiled/postcss-nesting/index.js +1 -1
  8. package/compiled/postcss-page-break/index.js +1 -1
  9. package/compiled/rollup-plugin-dts/index.js +1 -1
  10. package/dist/build.js.map +1 -1
  11. package/dist/builder/build.js.map +1 -1
  12. package/dist/builder/clear.js.map +1 -1
  13. package/dist/builder/copy.js.map +1 -1
  14. package/dist/builder/dts/index.js.map +1 -1
  15. package/dist/builder/dts/rollup.js.map +1 -1
  16. package/dist/builder/dts/tsc.js.map +1 -1
  17. package/dist/builder/index.js.map +1 -1
  18. package/dist/builder/platform.js.map +1 -1
  19. package/dist/cli.js +7 -2
  20. package/dist/cli.js.map +1 -1
  21. package/dist/command.js.map +1 -1
  22. package/dist/config/defineConfig.d.ts +0 -1
  23. package/dist/config/defineConfig.js.map +1 -1
  24. package/dist/config/legacySchema.js.map +1 -1
  25. package/dist/config/normalize.js.map +1 -1
  26. package/dist/config/schema.js.map +1 -1
  27. package/dist/config/transformLegacyConfig.d.ts +0 -2
  28. package/dist/config/transformLegacyConfig.js.map +1 -1
  29. package/dist/constants/build.js.map +1 -1
  30. package/dist/constants/buildPresets.d.ts +8 -8
  31. package/dist/constants/buildPresets.js.map +1 -1
  32. package/dist/constants/colors.js.map +1 -1
  33. package/dist/constants/dts.js.map +1 -1
  34. package/dist/constants/file.js.map +1 -1
  35. package/dist/constants/legacyBuildPresets.js.map +1 -1
  36. package/dist/constants/log.js.map +1 -1
  37. package/dist/dev.js.map +1 -1
  38. package/dist/error.js.map +1 -1
  39. package/dist/hooks/build.js.map +1 -1
  40. package/dist/hooks/dev.js.map +1 -1
  41. package/dist/hooks/index.js.map +1 -1
  42. package/dist/hooks/misc.js.map +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/locale/en.js.map +1 -1
  45. package/dist/locale/index.js.map +1 -1
  46. package/dist/locale/zh.js.map +1 -1
  47. package/dist/plugins.d.ts +1 -1
  48. package/dist/plugins.js.map +1 -1
  49. package/dist/types/config/index.d.ts +0 -1
  50. package/dist/types/config/index.js.map +1 -1
  51. package/dist/types/index.js.map +1 -1
  52. package/dist/types/legacyConfig/output.d.ts +1 -5
  53. package/dist/types/legacyConfig/source.d.ts +0 -1
  54. package/dist/types/legacyConfig/tools.d.ts +0 -4
  55. package/dist/types/utils.d.ts +0 -2
  56. package/dist/utils/builder.js.map +1 -1
  57. package/dist/utils/common.js.map +1 -1
  58. package/dist/utils/config.js.map +1 -1
  59. package/dist/utils/context.js.map +1 -1
  60. package/dist/utils/dts.js.map +1 -1
  61. package/dist/utils/input.js.map +1 -1
  62. package/dist/utils/language.js.map +1 -1
  63. package/dist/utils/libuildPlugins.js.map +1 -1
  64. package/dist/utils/log.js.map +1 -1
  65. package/dist/utils/onExit.js.map +1 -1
  66. package/dist/utils/path.js.map +1 -1
  67. package/dist/utils/print.js.map +1 -1
  68. package/dist/utils/style.js.map +1 -1
  69. package/dist/utils/tspathsTransform.js +4 -4
  70. package/dist/utils/tspathsTransform.js.map +1 -1
  71. package/package.json +21 -15
  72. package/compiled/@babel/code-frame/index.d.ts +0 -1
  73. package/compiled/@babel/code-frame/index.js +0 -1
  74. package/compiled/@babel/code-frame/license +0 -22
  75. package/compiled/@babel/code-frame/package.json +0 -1
  76. package/compiled/@babel/generator/index.d.ts +0 -1
  77. package/compiled/@babel/generator/index.js +0 -1
  78. package/compiled/@babel/generator/license +0 -22
  79. package/compiled/@babel/generator/package.json +0 -1
  80. package/compiled/@babel/helper-validator-identifier/index.d.ts +0 -1
  81. package/compiled/@babel/helper-validator-identifier/index.js +0 -1
  82. package/compiled/@babel/helper-validator-identifier/license +0 -22
  83. package/compiled/@babel/helper-validator-identifier/package.json +0 -1
  84. package/compiled/@babel/highlight/index.d.ts +0 -1
  85. package/compiled/@babel/highlight/index.js +0 -1
  86. package/compiled/@babel/highlight/license +0 -22
  87. package/compiled/@babel/highlight/package.json +0 -1
  88. package/compiled/@babel/parser/@babel/types/lib/index-legacy.d.ts +0 -2742
  89. package/compiled/@babel/parser/index.js +0 -1
  90. package/compiled/@babel/parser/license +0 -19
  91. package/compiled/@babel/parser/package.json +0 -1
  92. package/compiled/@babel/parser/typings/babel-parser.d.ts +0 -214
  93. package/compiled/@babel/template/index.d.ts +0 -1
  94. package/compiled/@babel/template/index.js +0 -1
  95. package/compiled/@babel/template/license +0 -22
  96. package/compiled/@babel/template/package.json +0 -1
  97. package/compiled/@babel/traverse/index.d.ts +0 -1199
  98. package/compiled/@babel/traverse/index.js +0 -1
  99. package/compiled/@babel/traverse/license +0 -22
  100. package/compiled/@babel/traverse/package.json +0 -1
  101. package/compiled/@babel/types/index.js +0 -1
  102. package/compiled/@babel/types/lib/index-legacy.d.ts +0 -2732
  103. package/compiled/@babel/types/license +0 -22
  104. package/compiled/@babel/types/package.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;uBAQc;uBACA;uBACA;uBACA;uBACA;uBACA;","names":[],"sources":["../../src/types/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/types/index.ts"],"sourcesContent":["import { NormalizedConfig, UserConfig } from '@modern-js/core';\nimport { ModuleToolsHooks } from './hooks';\nimport { ModuleExtraConfig } from './config';\nimport type {\n ModuleToolsLegacyUserConfig,\n ModuleToolsLegacyNormalizedConfig,\n} from './legacyConfig';\n\nexport * from './hooks';\nexport * from './command';\nexport * from './config';\nexport * from './legacyConfig';\nexport * from './dts';\nexport * from './context';\nexport type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';\n\nexport type ModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleExtraConfig;\n normalizedConfig: Required<ModuleExtraConfig>;\n};\nexport type LegacyModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleToolsLegacyUserConfig;\n normalizedConfig: ModuleToolsLegacyNormalizedConfig;\n};\n\nexport type ModuleUserConfig = UserConfig<ModuleTools>;\nexport type ModuleLegacyUserConfig = UserConfig<LegacyModuleTools>;\n\nexport type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;\nexport type ModuleLegacyNormalizedConfig = NormalizedConfig<LegacyModuleTools>;\n\n// params type for defineConfig\nexport type ModuleConfigParams =\n | ModuleUserConfig\n | Promise<ModuleUserConfig>\n | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;uBAQc;uBACA;uBACA;uBACA;uBACA;uBACA;","names":[],"sources":["../../src/types/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/types/index.ts"],"sourcesContent":["import { NormalizedConfig, UserConfig } from '@modern-js/core';\nimport { ModuleToolsHooks } from './hooks';\nimport { ModuleExtraConfig } from './config';\nimport type {\n ModuleToolsLegacyUserConfig,\n ModuleToolsLegacyNormalizedConfig,\n} from './legacyConfig';\n\nexport * from './hooks';\nexport * from './command';\nexport * from './config';\nexport * from './legacyConfig';\nexport * from './dts';\nexport * from './context';\nexport type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';\n\nexport type ModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleExtraConfig;\n normalizedConfig: Required<ModuleExtraConfig>;\n};\nexport type LegacyModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleToolsLegacyUserConfig;\n normalizedConfig: ModuleToolsLegacyNormalizedConfig;\n};\n\nexport type ModuleUserConfig = UserConfig<ModuleTools>;\nexport type ModuleLegacyUserConfig = UserConfig<LegacyModuleTools>;\n\nexport type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;\nexport type ModuleLegacyNormalizedConfig = NormalizedConfig<LegacyModuleTools>;\n\n// params type for defineConfig\nexport type ModuleConfigParams =\n | ModuleUserConfig\n | Promise<ModuleUserConfig>\n | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);\n"]}
@@ -16,9 +16,7 @@ export type LegacyBundleOptions = {
16
16
  export type LegacyBundlelessOptions = {
17
17
  sourceDir?: string;
18
18
  style?: {
19
- compileMode?: 'all' | 'only-compiled-code' |
20
- /* may be will be deprecated */
21
- 'only-source-code' | false;
19
+ compileMode?: 'all' | 'only-compiled-code' | /* may be will be deprecated */'only-source-code' | false;
22
20
  path?: string;
23
21
  };
24
22
  static?: {
@@ -52,10 +50,8 @@ export type OutputLegacyUserConfig = {
52
50
  }>;
53
51
  disableTsChecker?: boolean;
54
52
  /** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */
55
-
56
53
  assetsPath?: string;
57
54
  /** @deprecated Use the `buildConfig.sourceMap` instead */
58
-
59
55
  disableSourceMap?: boolean;
60
56
  buildPreset?: LegacyBuildPreset;
61
57
  buildConfig?: LegacyBuildConfig;
@@ -9,6 +9,5 @@ export type SourceLegacyUserConfig = {
9
9
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
10
10
  * @requires `tailwindcss` plugin
11
11
  */
12
-
13
12
  designSystem?: Record<string, any>;
14
13
  };
@@ -18,17 +18,14 @@ export type PostCSSLoaderOptions = {
18
18
  /**
19
19
  * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.
20
20
  */
21
-
22
21
  sourceMap?: boolean;
23
22
  /**
24
23
  * The special implementation option determines which implementation of PostCSS to use.
25
24
  */
26
-
27
25
  implementation?: unknown;
28
26
  /**
29
27
  * Allows to set PostCSS options and plugins.
30
28
  */
31
-
32
29
  postcssOptions?: PostCSSOptions;
33
30
  };
34
31
  export type PostCSSConfigUtils = {
@@ -50,7 +47,6 @@ export type ToolsLegacyUserConfig = {
50
47
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
51
48
  * @requires `tailwindcss` plugin
52
49
  */
53
-
54
50
  tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
55
51
  jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
56
52
  };
@@ -1,7 +1,5 @@
1
1
  export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? DeepPartialArray<U> : T extends object ? DeepPartialObject<T> : T | undefined;
2
2
  /** @private */
3
-
4
3
  export type DeepPartialArray<T> = Array<DeepPartial<T>>;
5
4
  /** @private */
6
-
7
5
  export type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAUaA,mBAAiB,MAAjBA;EA6BAC,YAAU,MAAVA;EA4CAC,iBAAe,MAAfA;EAmBAC,4BAA0B,MAA1BA;EAoCAC,yBAAuB,MAAvBA;;;;iEA1II;wBACM;AAShB,MAAMJ,oBAAoB,OAC/BK,QACAC,YACG;AACH,QAAM,EAAEC,cAAcC,UAAS,IAAKH;AACpC,QAAM,EAAEI,aAAY,IAAKH;AAEzB,MAAI,OAAOC,iBAAiB,WAAW;AACrC,QAAI,CAACA,cAAc;AACjB,aAAOC,aAAa;IACtB;AAEA,UAAME,QAAO,MAAMT,WAAWQ,cAAc;MAC1CE,cAAc;MACdC,kBAAkB;IACpB;AACA,WAAO;SACFF,MAAKG,IAAIC,SAAO,IAAIC,OAAO,IAAID,iBAAiB;SAC/CN,aAAa;;EAErB;AAEA,QAAME,OAAO,MAAMT,WAAWQ,cAAcF;AAC5C,SAAO;OACFG,KAAKG,IAAIC,SAAO,IAAIC,OAAO,IAAID,iBAAiB;OAC/CN,aAAa;;AAErB;AAEO,MAAMP,aAAa,OACxBQ,cACAH,UAII,CAAC,MACF;AACH,QAAM,EAAEU,GAAE,IAAK,MAAM,iFAAO;AAC5B,MAAI;AACF,UAAMC,OAAOC,KAAKC,MAChBH,GAAGI,aAAaC,cAAKC,QAAQb,cAAc,m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AID,qBAAqB;AACvB,WAAO;EACT;AAGA,MAAIH,eAAe,YAAY;AAC7B,WAAO;EACT;AAIA,MAAIC,cAAc,YAAYC,WAAW,OAAO;AAC9C,WAAO;EACT;AAEA,SAAO;AACT;","names":["getFinalExternals","getAllDeps","checkSwcHelpers","matchSwcTransformCondition","matchEs5PluginCondition","config","options","autoExternal","externals","appDirectory","deps","dependencies","peerDependencies","map","dep","RegExp","fs","json","JSON","parse","readFileSync","path","resolve","Object","keys","devDependencies","e","logger","warn","externalHelpers","swcHelpersPkgName","includes","local","Error","i18n","t","localeKeys","errors","condtionOptions","sourceType","buildType","format","disableSwcTransform","target"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type {\n BaseBuildConfig,\n ExternalHelpers,\n BuildType,\n Format,\n Target,\n} from '../types/config';\n\nexport const getFinalExternals = async (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n) => {\n const { autoExternal, externals } = config;\n const { appDirectory } = options;\n\n if (typeof autoExternal === 'boolean') {\n if (!autoExternal) {\n return externals || [];\n }\n\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n peerDependencies: true,\n });\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const deps = await getAllDeps(appDirectory, autoExternal);\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n};\n\nexport const getAllDeps = async <T>(\n appDirectory: string,\n options: {\n dependencies?: boolean;\n devDependencies?: boolean;\n peerDependencies?: boolean;\n } = {},\n) => {\n const { fs } = await import('@modern-js/utils');\n try {\n const json = JSON.parse(\n fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'),\n );\n\n let deps: string[] = [];\n\n if (options.dependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.dependencies as T | undefined) || {}),\n ];\n }\n\n if (options.devDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.devDependencies as T | undefined) || {}),\n ];\n }\n\n if (options.peerDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.peerDependencies as T | undefined) || {}),\n ];\n }\n\n return deps;\n } catch (e) {\n logger.warn('package.json is broken');\n return [];\n }\n};\n\nexport const checkSwcHelpers = async (options: {\n appDirectory: string;\n externalHelpers: ExternalHelpers;\n}) => {\n const { appDirectory, externalHelpers } = options;\n if (externalHelpers === false) {\n return;\n }\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n devDependencies: true,\n });\n const swcHelpersPkgName = '@swc/helpers';\n if (!deps.includes(swcHelpersPkgName)) {\n const local = await import('../locale');\n throw new Error(local.i18n.t(local.localeKeys.errors.externalHelpers));\n }\n};\n\nexport const matchSwcTransformCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, disableSwcTransform } =\n condtionOptions;\n\n if (disableSwcTransform) {\n return false;\n }\n\n // 1. source code is esm\n // 2. bundleless\n // 3. bundle and format is esm\n\n if (sourceType === 'commonjs') {\n return false;\n }\n\n if (buildType === 'bundleless') {\n return true;\n }\n\n if (format === 'esm' || format === 'iife') {\n // when format is iife, swc-transform only transform syntax, esbuild transform js format.\n return true;\n }\n\n // bundle only use esbuild-transform in cjs format, because have some limitations\n // eg: treeshaking\n\n return false;\n};\n\nexport const matchEs5PluginCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n target: Target;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, target, disableSwcTransform } =\n condtionOptions;\n\n // dist is es5\n if (target !== 'es5') {\n return false;\n }\n\n // when use disbaleSwcTransform option, we must be use es5Plugin when target is es5\n if (disableSwcTransform) {\n return true;\n }\n\n // only use esbuild-transform, so need es5Plugin\n if (sourceType === 'commonjs') {\n return true;\n }\n\n // when source code is esm and dist is bundle + cjs, we can`t use swc-transform.\n // so we only use esbuild-transform and es5Plugin\n if (buildType === 'bundle' && format === 'cjs') {\n return true;\n }\n\n return false;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAUaA,mBAAiB,MAAjBA;EA6BAC,YAAU,MAAVA;EA4CAC,iBAAe,MAAfA;EAmBAC,4BAA0B,MAA1BA;EAoCAC,yBAAuB,MAAvBA;;;;iEA1II;wBACM;AAShB,MAAMJ,oBAAoB,OAC/BK,QACAC,YACG;AACH,QAAM,EAAEC,cAAcC,UAAS,IAAKH;AACpC,QAAM,EAAEI,aAAY,IAAKH;AAEzB,MAAI,OAAOC,iBAAiB,WAAW;AACrC,QAAI,CAACA,cAAc;AACjB,aAAOC,aAAa;IACtB;AAEA,UAAME,QAAO,MAAMT,WAAWQ,cAAc;MAC1CE,cAAc;MACdC,kBAAkB;IACpB;AACA,WAAO;SACFF,MAAKG,IAAIC,SAAO,IAAIC,OAAO,IAAID,iBAAiB;SAC/CN,aAAa;;EAErB;AAEA,QAAME,OAAO,MAAMT,WAAWQ,cAAcF;AAC5C,SAAO;OACFG,KAAKG,IAAIC,SAAO,IAAIC,OAAO,IAAID,iBAAiB;OAC/CN,aAAa;;AAErB;AAEO,MAAMP,aAAa,OACxBQ,cACAH,UAII,CAAC,MACF;AACH,QAAM,EAAEU,GAAE,IAAK,MAAM,iFAAO;AAC5B,MAAI;AACF,UAAMC,OAAOC,KAAKC,MAChBH,GAAGI,aAAaC,cAAKC,QAAQb,cAAc,mBAAmB;AAGhE,QAAIC,OAAiB;AAErB,QAAIJ,QAAQK,cAAc;AACxBD,aAAO;WACFA;WACAa,OAAOC,KAAMP,KAAKN,gBAAkC,CAAC;;IAE5D;AAEA,QAAIL,QAAQmB,iBAAiB;AAC3Bf,aAAO;WACFA;WACAa,OAAOC,KAAMP,KAAKQ,mBAAqC,CAAC;;IAE/D;AAEA,QAAInB,QAAQM,kBAAkB;AAC5BF,aAAO;WACFA;WACAa,OAAOC,KAAMP,KAAKL,oBAAsC,CAAC;;IAEhE;AAEA,WAAOF;EACT,SAASgB,GAAP;AACAC,mBAAOC,KAAK;AACZ,WAAO;EACT;AACF;AAEO,MAAM1B,kBAAkB,OAAOI,YAGhC;AACJ,QAAM,EAAEG,cAAcoB,gBAAe,IAAKvB;AAC1C,MAAIuB,oBAAoB,OAAO;AAC7B;EACF;AACA,QAAMnB,OAAO,MAAMT,WAAWQ,cAAc;IAC1CE,cAAc;IACdc,iBAAiB;EACnB;AACA,QAAMK,oBAAoB;AAC1B,MAAI,CAACpB,KAAKqB,SAASD,oBAAoB;AACrC,UAAME,QAAQ,MAAM,iFAAO;AAC3B,UAAM,IAAIC,MAAMD,MAAME,KAAKC,EAAEH,MAAMI,WAAWC,OAAOR,eAAe;EACtE;AACF;AAEO,MAAM1B,6BAA6B,CAACmC,oBAKrC;AACJ,QAAM,EAAEC,YAAYC,WAAWC,QAAQC,oBAAmB,IACxDJ;AAEF,MAAII,qBAAqB;AACvB,WAAO;EACT;AAMA,MAAIH,eAAe,YAAY;AAC7B,WAAO;EACT;AAEA,MAAIC,cAAc,cAAc;AAC9B,WAAO;EACT;AAEA,MAAIC,WAAW,SAASA,WAAW,QAAQ;AAEzC,WAAO;EACT;AAKA,SAAO;AACT;AAEO,MAAMrC,0BAA0B,CAACkC,oBAMlC;AACJ,QAAM,EAAEC,YAAYC,WAAWC,QAAQE,QAAQD,oBAAmB,IAChEJ;AAGF,MAAIK,WAAW,OAAO;AACpB,WAAO;EACT;AAGA,MAAID,qBAAqB;AACvB,WAAO;EACT;AAGA,MAAIH,eAAe,YAAY;AAC7B,WAAO;EACT;AAIA,MAAIC,cAAc,YAAYC,WAAW,OAAO;AAC9C,WAAO;EACT;AAEA,SAAO;AACT;","names":["getFinalExternals","getAllDeps","checkSwcHelpers","matchSwcTransformCondition","matchEs5PluginCondition","config","options","autoExternal","externals","appDirectory","deps","dependencies","peerDependencies","map","dep","RegExp","fs","json","JSON","parse","readFileSync","path","resolve","Object","keys","devDependencies","e","logger","warn","externalHelpers","swcHelpersPkgName","includes","local","Error","i18n","t","localeKeys","errors","condtionOptions","sourceType","buildType","format","disableSwcTransform","target"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type {\n BaseBuildConfig,\n ExternalHelpers,\n BuildType,\n Format,\n Target,\n} from '../types/config';\n\nexport const getFinalExternals = async (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n) => {\n const { autoExternal, externals } = config;\n const { appDirectory } = options;\n\n if (typeof autoExternal === 'boolean') {\n if (!autoExternal) {\n return externals || [];\n }\n\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n peerDependencies: true,\n });\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const deps = await getAllDeps(appDirectory, autoExternal);\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n};\n\nexport const getAllDeps = async <T>(\n appDirectory: string,\n options: {\n dependencies?: boolean;\n devDependencies?: boolean;\n peerDependencies?: boolean;\n } = {},\n) => {\n const { fs } = await import('@modern-js/utils');\n try {\n const json = JSON.parse(\n fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'),\n );\n\n let deps: string[] = [];\n\n if (options.dependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.dependencies as T | undefined) || {}),\n ];\n }\n\n if (options.devDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.devDependencies as T | undefined) || {}),\n ];\n }\n\n if (options.peerDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.peerDependencies as T | undefined) || {}),\n ];\n }\n\n return deps;\n } catch (e) {\n logger.warn('package.json is broken');\n return [];\n }\n};\n\nexport const checkSwcHelpers = async (options: {\n appDirectory: string;\n externalHelpers: ExternalHelpers;\n}) => {\n const { appDirectory, externalHelpers } = options;\n if (externalHelpers === false) {\n return;\n }\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n devDependencies: true,\n });\n const swcHelpersPkgName = '@swc/helpers';\n if (!deps.includes(swcHelpersPkgName)) {\n const local = await import('../locale');\n throw new Error(local.i18n.t(local.localeKeys.errors.externalHelpers));\n }\n};\n\nexport const matchSwcTransformCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, disableSwcTransform } =\n condtionOptions;\n\n if (disableSwcTransform) {\n return false;\n }\n\n // 1. source code is esm\n // 2. bundleless\n // 3. bundle and format is esm\n\n if (sourceType === 'commonjs') {\n return false;\n }\n\n if (buildType === 'bundleless') {\n return true;\n }\n\n if (format === 'esm' || format === 'iife') {\n // when format is iife, swc-transform only transform syntax, esbuild transform js format.\n return true;\n }\n\n // bundle only use esbuild-transform in cjs format, because have some limitations\n // eg: treeshaking\n\n return false;\n};\n\nexport const matchEs5PluginCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n target: Target;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, target, disableSwcTransform } =\n condtionOptions;\n\n // dist is es5\n if (target !== 'es5') {\n return false;\n }\n\n // when use disbaleSwcTransform option, we must be use es5Plugin when target is es5\n if (disableSwcTransform) {\n return true;\n }\n\n // only use esbuild-transform, so need es5Plugin\n if (sourceType === 'commonjs') {\n return true;\n }\n\n // when source code is esm and dist is bundle + cjs, we can`t use swc-transform.\n // so we only use esbuild-transform and es5Plugin\n if (buildType === 'bundle' && format === 'cjs') {\n return true;\n }\n\n return false;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;+BAGaA;;aAAAA;;AAAN,MAAMA,0BAA0B,CACrCC,QAC8B;AAC9B,SAAOA,IAAIC,OAAO,CAACC,GAAGC,QAAQ;AAC5B,WAAO;MACL,GAAGD;MACH,CAACC,MAAMC;IACT;EACF,GAAG,CAAC;AACN;","names":["transformUndefineObject","arr","reduce","o","key","undefined"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/common.ts"],"sourcesContent":["/**\n * transform ['a', 'b'] to {a: undefined, b: undefined}\n */\nexport const transformUndefineObject = (\n arr: string[],\n): Record<string, undefined> => {\n return arr.reduce((o, key) => {\n return {\n ...o,\n [key]: undefined,\n };\n }, {});\n};\n"]}
1
+ {"version":3,"mappings":";;;;+BAGaA;;aAAAA;;AAAN,MAAMA,0BAA0B,CACrCC,QAC8B;AAC9B,SAAOA,IAAIC,OAAO,CAACC,GAAGC,QAAQ;AAC5B,WAAO;MACL,GAAGD;MACH,CAACC,MAAMC;IACT;EACF,GAAG,CAAC;AACN;","names":["transformUndefineObject","arr","reduce","o","key","undefined"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/common.ts"],"sourcesContent":["/**\n * transform ['a', 'b'] to {a: undefined, b: undefined}\n */\nexport const transformUndefineObject = (\n arr: string[],\n): Record<string, undefined> => {\n return arr.reduce((o, key) => {\n return {\n ...o,\n [key]: undefined,\n };\n }, {});\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,yBAAuB,MAAvBA;EAUAC,yBAAuB,MAAvBA;EAWAC,wBAAsB,MAAtBA;EAyGAC,cAAY,MAAZA;EAsBAC,oBAAkB,MAAlBA;;;AApJN,MAAMJ,0BAA0B,CAACK,WAA+B;AACrE,MAAIC,MAAMC,QAAQF,SAAS;AACzB,eAAWG,KAAKH,QAAQ;AACtBJ,8BAAwBO;IAC1B;EACF,OAAO;AACLP,4BAAwBI;EAC1B;AACF;AAEO,MAAMJ,0BAA0B,CAACI,WAAmC;MAG9CA;AAF3B,MACEA,OAAOI,cAAc,gBACrB;IAAC;IAAQ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ACT;AAEO,MAAMnE,qBAAqB,CAACC,WAEKsE,QAAQtE,OAAOuE,MAAM;","names":["validPartialBuildConfig","validBuildTypeAndFormat","mergeDefaultBaseConfig","getDtsConfig","isLegacyUserConfig","config","Array","isArray","c","buildType","includes","format","Error","pConfig","context","defaultBuildConfig","defaultConfig","cloneDeep","applyOptionsChain","ensureAbsolutePath","slash","getDefaultIndexEntry","getStyleConfig","defaultAlias","srcDirectory","mergedAlias","alias","Object","keys","reduce","prev","name","formattedValue","value","startsWith","appDirectory","styleConfig","sourceDir","metafile","input","userDefine","define","memo","JSON","stringify","esbuildOptions","asset","target","sourceMap","copy","outDir","dts","jsx","platform","splitting","minify","autoExternal","umdGlobals","umdModuleName","sideEffects","externals","style","inject","modules","autoModules","tailwindcss","redirect","externalHelpers","transformImport","sourceType","disableSwcTransform","userDTS","defaultDTS","isUndefined","isObject","Boolean","legacy"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n} from '../types';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n const esbuildOptions = pConfig.esbuildOptions ?? defaultConfig.esbuildOptions;\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n sideEffects: pConfig.sideEffects ?? defaultConfig.sideEffects,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindcss:\n pConfig.style?.tailwindcss ?? defaultConfig.style.tailwindcss,\n },\n redirect: {\n ...defaultConfig.redirect,\n ...pConfig.redirect,\n },\n esbuildOptions,\n externalHelpers: pConfig.externalHelpers ?? defaultConfig.externalHelpers,\n transformImport: pConfig.transformImport ?? defaultConfig.transformImport,\n sourceType: pConfig.sourceType ?? defaultConfig.sourceType,\n disableSwcTransform:\n pConfig.disableSwcTransform ?? defaultConfig.disableSwcTransform,\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,yBAAuB,MAAvBA;EAUAC,yBAAuB,MAAvBA;EAWAC,wBAAsB,MAAtBA;EAyGAC,cAAY,MAAZA;EAsBAC,oBAAkB,MAAlBA;;;AApJN,MAAMJ,0BAA0B,CAACK,WAA+B;AACrE,MAAIC,MAAMC,QAAQF,SAAS;A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AAWwD,aAAaC,SAAQ,IAAK,MAAM,iFACjD;AAGF,MAAID,YAAYF,UAAU;AACxB,WAAOtD,UAAUuD;EACnB;AAEA,MAAIE,SAASH,UAAU;AACrB,WAAO;MACL,GAAGC;MACH,GAAGD;IACL;EACF;AAEA,SAAOA;AACT;AAEO,MAAMnE,qBAAqB,CAACC,WAEKsE,QAAQtE,OAAOuE,MAAM;","names":["validPartialBuildConfig","validBuildTypeAndFormat","mergeDefaultBaseConfig","getDtsConfig","isLegacyUserConfig","config","Array","isArray","c","buildType","includes","format","Error","pConfig","context","defaultBuildConfig","defaultConfig","cloneDeep","applyOptionsChain","ensureAbsolutePath","slash","getDefaultIndexEntry","getStyleConfig","defaultAlias","srcDirectory","mergedAlias","alias","Object","keys","reduce","prev","name","formattedValue","value","startsWith","appDirectory","styleConfig","sourceDir","metafile","input","userDefine","define","memo","JSON","stringify","esbuildOptions","asset","target","sourceMap","copy","outDir","dts","jsx","platform","splitting","minify","autoExternal","umdGlobals","umdModuleName","sideEffects","externals","style","inject","modules","autoModules","tailwindcss","redirect","externalHelpers","transformImport","sourceType","disableSwcTransform","userDTS","defaultDTS","isUndefined","isObject","Boolean","legacy"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n} from '../types';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n const esbuildOptions = pConfig.esbuildOptions ?? defaultConfig.esbuildOptions;\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n sideEffects: pConfig.sideEffects ?? defaultConfig.sideEffects,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindcss:\n pConfig.style?.tailwindcss ?? defaultConfig.style.tailwindcss,\n },\n redirect: {\n ...defaultConfig.redirect,\n ...pConfig.redirect,\n },\n esbuildOptions,\n externalHelpers: pConfig.externalHelpers ?? defaultConfig.externalHelpers,\n transformImport: pConfig.transformImport ?? defaultConfig.transformImport,\n sourceType: pConfig.sourceType ?? defaultConfig.sourceType,\n disableSwcTransform:\n pConfig.disableSwcTransform ?? defaultConfig.disableSwcTransform,\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAGaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,OAAOC,QAAgC;AACtE,QAAM,EAAEC,aAAY,IAAK,MAAM,iFAAO;AACtC,QAAM,EAAEC,cAAcC,aAAY,IAAKH,IAAII,cAAa;AACxD,QAAMC,cAAcJ,aAAaC;AAEjC,SAAO;IAAEG;IAAaH;IAAcC;EAAa;AACnD;","names":["initModuleContext","api","isTypescript","appDirectory","srcDirectory","useAppContext","isTsProject"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAGaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,OAAOC,QAAgC;AACtE,QAAM,EAAEC,aAAY,IAAK,MAAM,iFAAO;AACtC,QAAM,EAAEC,cAAcC,aAAY,IAAKH,IAAII,cAAa;AACxD,QAAMC,cAAcJ,aAAaC;AAEjC,SAAO;IAAEG;IAAaH;IAAcC;EAAa;AACnD;","names":["initModuleContext","api","isTypescript","appDirectory","srcDirectory","useAppContext","isTsProject"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAaaA,mBAAiB,MAAjBA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O;AAC3B,QAAM,EAAEL,cAAcM,UAAS,IAAK9B,mDAAW,CAAC;AAChD,MAAIyB,iBAAiB1B,OAAO;AAC1B,QAAIyB,cAAc;AAChB,YAAM,IAAII,iBAAiBH,OAAO;QAChCK;MACF;IACF,OAAO;AACLJ,aAAOK,KACLJ,MAAMK,eACJH,MAAMI,KAAKC,EAAEL,MAAMM,WAAWC,MAAMf,IAAIG,YAAY;AAGxDE,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","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';\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(\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":";;;;;;;;;;;;EAUaA,mBAAiB,MAAjBA;EAmDAC,eAAa,MAAbA;EA0BAC,cAAY,MAAZA;EA6EAC,oBAAkB,MAAlBA;EAuBAC,uBAAqB,MAArBA;;;;iEA3LI;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;AAG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AAGqD,cAAcD,EAAE5C,MAAM4C,EAAEE,OAAO;EACpC;AAEA,QAAMtD,GAAGuD,KAAK/B,oBAAoBkB;AACpC;AAgDO,MAAM7C,qBAAqB,OAChCE,QACAsC,YACG;AACH,QAAM,EAAEmB,oBAAmB,IAAK,MAAM,iFAAO;AAG7C,MACE,OAAOnB,QAAQoB,aAAa,YAC5BpB,QAAQoB,aAAaD,qBACrB;QAKMzD;AAJNA,WAAO2D,MAAM;MACXC,MAAM;MACNC,UAAU;MACVC,cAAc;MACd,IAAI9D,qBAAO2D,SAAG,QAAV3D,uCAAc,CAAC;MACnBO,cAAc+B,QAAQoB;IACxB;EACF;AAEA,SAAO1D;AACT;AAEO,MAAMD,wBAAwB,OACnCgE,OACAzB,YACG;AACH,QAAM,EAAE0B,QAAQC,MAAK,IAAK,MAAM,iFAAO;AACvC,QAAM,EAAEC,iBAAgB,IAAK,MAAM,iFAAO;AAC1C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEL,cAAcM,UAAS,IAAK9B,mDAAW,CAAC;AAChD,MAAIyB,iBAAiB1B,OAAO;AAC1B,QAAIyB,cAAc;AAChB,YAAM,IAAII,iBAAiBH,OAAO;QAChCK;MACF;IACF,OAAO;AACLJ,aAAOK,KACLJ,MAAMK,eACJH,MAAMI,KAAKC,EAAEL,MAAMM,WAAWC,MAAMf,IAAIG,YAAY;AAGxDE,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","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns"],"sources":["../../src/utils/home/runner/work/modern.js/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 ...(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 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB,MAAlBA;EAUAC,aAAW,MAAXA;EAsBAC,kBAAgB,MAAhBA;EAqBAC,sBAAoB,MAApBA;EAyBAC,gBAAc,MAAdA;;;;iEA1F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AAC5B,MAAIrB,QAAQoB,cACRvB,cAAKC,KAAKK,cAAc,oBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEAA,UAAQoB,cACJvB,cAAKC,KAAKK,cAAc,qBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEA,SAAO;AACT;AAEO,MAAMV,iBAAiB,OAC5BkC,YACAvB,YACG;AACH,MAAIuB,WAAWP,cAAc,gBAAgB,CAACO,WAAWN,OAAO;AAC9D,UAAM,EAAEhB,MAAK,IAAK,MAAM,iFAAO;AAC/B,WAAO;MAACA,MAAMsB,WAAWL,SAAS;;EACpC;AACA,SAAOhC,YAAYqC,WAAWN,OAAOjB;AACvC;","names":["joinPathWithPrefix","getAbsInput","addInputToPreset","getDefaultIndexEntry","normalizeInput","flag","p1","globPath","haveFlag","trim","startsWith","path","join","replace","entry","options","slash","appDirectory","resolvePathWithNoMatchFlag","Array","isArray","map","p","isAbsolute","newEntry","key","Object","keys","config","context","c","buildType","input","sourceDir","isTsProject","fs","existsSync","relative","baseConfig"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB,MAAlBA;EAUAC,aAAW,MAAXA;EAsBAC,kBAAgB,MAAhBA;E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AY,MAIR;AACJ,QAAM,EAAEkB,GAAE,IAAK,MAAM,iFAAO;AAC5B,MAAIrB,QAAQoB,cACRvB,cAAKC,KAAKK,cAAc,oBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEAA,UAAQoB,cACJvB,cAAKC,KAAKK,cAAc,qBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEA,SAAO;AACT;AAEO,MAAMV,iBAAiB,OAC5BkC,YACAvB,YACG;AACH,MAAIuB,WAAWP,cAAc,gBAAgB,CAACO,WAAWN,OAAO;AAC9D,UAAM,EAAEhB,MAAK,IAAK,MAAM,iFAAO;AAC/B,WAAO;MAACA,MAAMsB,WAAWL,SAAS;;EACpC;AACA,SAAOhC,YAAYqC,WAAWN,OAAOjB;AACvC;","names":["joinPathWithPrefix","getAbsInput","addInputToPreset","getDefaultIndexEntry","normalizeInput","flag","p1","globPath","haveFlag","trim","startsWith","path","join","replace","entry","options","slash","appDirectory","resolvePathWithNoMatchFlag","Array","isArray","map","p","isAbsolute","newEntry","key","Object","keys","config","context","c","buildType","input","sourceDir","isTsProject","fs","existsSync","relative","baseConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,YAAY;AAC3C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAEF,QAAMC,SAASD;AACfD,QAAMG,KAAKC,eAAe;IAAEF;EAAO;AACnC,SAAOF;AACT;","names":["initLocalLanguage","local","getLocaleLanguage","locale","i18n","changeLanguage"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/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"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,oBAAoB,YAAY;AAC3C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAEF,QAAMC,SAASD;AACfD,QAAMG,KAAKC,eAAe;IAAEF;EAAO;AACnC,SAAOF;AACT;","names":["initLocalLanguage","local","getLocaleLanguage","locale","i18n","changeLanguage"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAIaA,aAAW,MAAXA;EAuBAC,gBAAc,MAAdA;;;wBA3BU;AAIhB,MAAMD,cAAc,CACzBE,KACAC,WACkB;AAClB,SAAO;IACLC,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMC,YAAYC,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,cAAMC,YAAY,IAChBT,OAAOU,cAAc,WAAW,WAAW,gBACzCV,OAAOW,UAAUX,OAAOY;AAE5BC,uBAAOC,KAAK,MAAMP,kBAAkBE,WAAWD,mBAAmBO,GAAG;AAErE,cAAMC,SAASjB,IAAIkB,eAAc;AACjCD,eAAOE,aAAa;UAAEC,aAAanB;QAAO;MAC5C;IACF;EACF;AACF;AAEO,MAAMF,iBAAiB,CAC5BE,QACAoB,YACkB;AAClB,SAAO;IACLnB,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMiB,WAAWC,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAMC,iBAAiB,MAAMD,kBAAkBvB,QAAQoB;AACvDjB,iBAASH,OAAOyB,WAAWD;MAC7B;IACF;EACF;AACF;","names":["watchPlugin","externalPlugin","api","config","name","apply","compiler","hooks","watchChange","tap","watchSectionTitle","SectionTitleStatus","titleText","buildType","format","target","logger","info","Log","runner","useHookRunners","buildWatchJs","buildConfig","options","initialize","tapPromise","getFinalExternals","finalExternals","external"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/libuildPlugins.ts"],"sourcesContent":["import { logger } from '@modern-js/utils/logger';\nimport 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\n logger.info(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"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAIaA,aAAW,MAAXA;EAuBAC,gBAAc,MAAdA;;;wBA3BU;AAIhB,MAAMD,cAAc,CACzBE,KACAC,WACkB;AAClB,SAAO;IACLC,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMC,YAAYC,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,cAAMC,YAAY,IAChBT,OAAOU,cAAc,WAAW,WAAW,gBACzCV,OAAOW,UAAUX,OAAOY;AAE5BC,uBAAOC,KAAK,MAAMP,kBAAkBE,WAAWD,mBAAmBO,GAAG;AAErE,cAAMC,SAASjB,IAAIkB,eAAc;AACjCD,eAAOE,aAAa;UAAEC,aAAanB;QAAO;MAC5C;IACF;EACF;AACF;AAEO,MAAMF,iBAAiB,CAC5BE,QACAoB,YACkB;AAClB,SAAO;IACLnB,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMiB,WAAWC,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAMC,iBAAiB,MAAMD,kBAAkBvB,QAAQoB;AACvDjB,iBAASH,OAAOyB,WAAWD;MAC7B;IACF;EACF;AACF;","names":["watchPlugin","externalPlugin","api","config","name","apply","compiler","hooks","watchChange","tap","watchSectionTitle","SectionTitleStatus","titleText","buildType","format","target","logger","info","Log","runner","useHookRunners","buildWatchJs","buildConfig","options","initialize","tapPromise","getFinalExternals","finalExternals","external"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/libuildPlugins.ts"],"sourcesContent":["import { logger } from '@modern-js/utils/logger';\nimport 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\n logger.info(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"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;qBAFsB;AAE5B,MAAMA,oBAAoB,OAC/BC,KACAC,QACAC,cACG;AACH,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,MAAIF,WAAWG,wBAAmBC,SAAS;AACzC,WAAO,GAAGF,MAAMG,KAAKN,QAAQG,MAAMI,MAAM;EAC3C,WAAWN,WAAWG,wBAAmBI,MAAM;AAC7C,WAAO,GAAGL,MAAMG,KAAKN,QAAQG,MAAMM,IAAI;EACzC;AAEA,SAAO,GAAGN,MAAMG,KAAKN,QAAQE,YAAYA,YAAY;AACvD;","names":["watchSectionTitle","str","status","detailLog","chalk","SectionTitleStatus","Success","gray","green","Fail","red"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.gray(str)} ${chalk.green('Successful')}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.gray(str)} ${chalk.red('Build Failed')}`;\n }\n\n return `${chalk.gray(str)} ${detailLog ? detailLog : 'Log:'}`;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;qBAFsB;AAE5B,MAAMA,oBAAoB,OAC/BC,KACAC,QACAC,cACG;AACH,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,MAAIF,WAAWG,wBAAmBC,SAAS;AACzC,WAAO,GAAGF,MAAMG,KAAKN,QAAQG,MAAMI,MAAM;EAC3C,WAAWN,WAAWG,wBAAmBI,MAAM;AAC7C,WAAO,GAAGL,MAAMG,KAAKN,QAAQG,MAAMM,IAAI;EACzC;AAEA,SAAO,GAAGN,MAAMG,KAAKN,QAAQE,YAAYA,YAAY;AACvD;","names":["watchSectionTitle","str","status","detailLog","chalk","SectionTitleStatus","Success","gray","green","Fail","red"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.gray(str)} ${chalk.green('Successful')}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.gray(str)} ${chalk.red('Build Failed')}`;\n }\n\n return `${chalk.gray(str)} ${detailLog ? detailLog : 'Log:'}`;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,kBAAkB,OAAOC,OAA4B;AAChE,QAAM,EAAEC,SAASC,OAAM,IAAK,MAAM,iFAAO;AAEzCA,SAAO,OAAMC,SAAQ;AACnB,QAAIA,SAAS,GAAG;AACd;IACF;AAEA,UAAMH;EACR;AACF;","names":["addExitListener","fn","default","onExit","code"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAAaA;;aAAAA;;;AAAN,MAAMA,kBAAkB,OAAOC,OAA4B;AAChE,QAAM,EAAEC,SAASC,OAAM,IAAK,MAAM,iFAAO;AAEzCA,SAAO,OAAMC,SAAQ;AACnB,QAAIA,SAAS,GAAG;AACd;IACF;AAEA,UAAMH;EACR;AACF;","names":["addExitListener","fn","default","onExit","code"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;;iEAFI;AAEV,MAAMA,kBAAkB,OAAOC,gBAAwB;AAC5D,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,SAAOA,MAAMC,cAAKC,KAAKC,WAAW,kBAAkBJ;AACtD;","names":["getCompiledPath","packageName","slash","path","join","__dirname"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAEaA;;aAAAA;;;;iEAFI;AAEV,MAAMA,kBAAkB,OAAOC,gBAAwB;AAC5D,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,SAAOA,MAAMC,cAAKC,KAAKC,WAAW,kBAAkBJ;AACtD;","names":["getCompiledPath","packageName","slash","path","join","__dirname"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAkBaA,aAAW,MAAXA;EAEAC,iBAAe,MAAfA;EAEAC,gBAAc,MAAdA;EAmBAC,gBAAc,MAAdA;EAiBAC,aAAW,MAAXA;EAeAC,eAAa,MAAbA;EAKAC,cAAY,MAAZA;;;sBA9EqB;uBAEJ;qBASvB;AAOA,MAAMN,cAAuB;AAE7B,MAAMC,kBAA2B;AAEjC,MAAMC,iBAAiB,CAC5BK,aACAC,cACAC,aACG;AACH,QAAMC,QAAQC,MAAMC,KAAKL,aAAaM,IAAIC,SAAO;AAC/C,UAAM,CAACC,MAAMC,SAASF;AACtB,WAAO;MACLG,OAAMC,mBAASV,cAAcO;MAC7BI,MAAMH,MAAMI,SAASC;IACvB;EACF;AACA,MAAIZ,UAAU;AACZT,gBAAYsB,KAAI,GAAIZ;EACtB,OAAO;AACLT,oBAAgBqB,KAAI,GAAIZ;EAC1B;AACF;AAEO,MAAMP,iBAAiB,CAC5BoB,cACAf,cACAgB,YACG;AACH,QAAM,EAAEC,OA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AK,oBAAoBzC,YAAYqB;CAAgB;AAE5D,QAAMoC,YACJD,2BACA,IAAIE,OAAON,oBAAoB,MAC/BO;AACFnB,gBAAOS,IAAIX,aAAMsB,KAAKtB,aAAMuB,MAAMJ;AAElCzD,cAAY8D,QAAQ,CAAC,EAAE7C,MAAME,KAAI,MAAO;AACtC,UAAM4C,UAAU,GAAG9C,OAAO,IAAIyC,OAC5BN,oBAAoBnC,KAAKI,SAAS,KAChCsB,YAAYxB;AAChBqB,kBAAOS,IAAIc;EACb;AACF;AAEA,MAAM7B,sBAAsB,MAAM;AAChC,MAAIjC,gBAAgBoB,WAAW,GAAG;AAChC;EACF;AAEA,QAAM2C,QAAQ/D,gBAAgBoB;AAC9B,QAAM4C,YAAYhE,gBAAgBoD,OAAO,CAACa,OAAOjC,SAAS;AACxD,WAAOiC,QAAQjC,KAAKd;EACtB,GAAG;AACH,QAAMsB,OAAO,wBAAwBuB,kCAAkC1B,aAAMC,KAC3EI,YAAYsB;AAEdzB,gBAAOC,KAAKA;AACd;","names":["bundleFiles","bundlelessFiles","addOutputChunk","addRollupChunk","addDtsFiles","printFileSize","printSucceed","outputChunk","appDirectory","isBundle","files","Array","from","map","val","path","chunk","name","relative","size","contents","length","push","rollupOutput","distDir","output","o","resolve","fileName","code","fastGlob","slash","stats","file","printBundlelessInfo","printBundleFiles","totalDuration","time","chalk","cyan","logger","info","buildSuccessText","prettyBytes","bytes","unit","exp","Math","floor","log","pow","toFixed","longestFileLength","reduce","max","str","reportFile1LineText","headerRow","repeat","reportFile2LineText","bold","green","forEach","infoRow","count","totalSize","total"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/print.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport type { ILibuilder } from '@modern-js/libuild';\nimport { chalk, logger } from '@modern-js/utils';\nimport type {\n RollupOutput,\n OutputChunk,\n} from '../../compiled/rollup/types/rollup';\nimport {\n buildSuccessText,\n reportFile1LineText,\n reportFile2LineText,\n} from '../constants/log';\n\ntype Files = {\n name: string;\n size: number;\n};\n\nexport const bundleFiles: Files[] = [];\n\nexport const bundlelessFiles: Files[] = [];\n\nexport const addOutputChunk = (\n outputChunk: ILibuilder['outputChunk'],\n appDirectory: string,\n isBundle: boolean,\n) => {\n const files = Array.from(outputChunk).map(val => {\n const [path, chunk] = val;\n return {\n name: relative(appDirectory, path),\n size: chunk.contents.length,\n };\n });\n if (isBundle) {\n bundleFiles.push(...files);\n } else {\n bundlelessFiles.push(...files);\n }\n};\n\nexport const addRollupChunk = (\n rollupOutput: RollupOutput,\n appDirectory: string,\n distDir: string,\n) => {\n const { output } = rollupOutput;\n bundleFiles.push(\n ...output.map(o => {\n return {\n name: relative(appDirectory, resolve(distDir, o.fileName)),\n // only d.ts, is outputChunk not outputAsset\n size: (o as OutputChunk).code.length,\n };\n }),\n );\n};\n\nexport const addDtsFiles = async (distDir: string, appDirectory: string) => {\n const { fastGlob, slash } = await import('@modern-js/utils');\n const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {\n stats: true,\n });\n bundlelessFiles.push(\n ...files.map(file => {\n return {\n name: relative(appDirectory, file.path),\n size: file.stats.size,\n };\n }),\n );\n};\n\nexport const printFileSize = () => {\n printBundlelessInfo();\n printBundleFiles();\n};\n\nexport const printSucceed = (totalDuration: number) => {\n const time = chalk.cyan(`${totalDuration / 1000}s`);\n logger.info(`${buildSuccessText} in ${time}`);\n};\n\nconst prettyBytes = (bytes: number) => {\n if (bytes === 0) {\n return '0 B';\n }\n const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const exp = Math.floor(Math.log(bytes) / Math.log(1024));\n return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;\n};\n\nconst printBundleFiles = () => {\n if (bundleFiles.length === 0) {\n return;\n }\n const longestFileLength = bundleFiles.reduce(\n (max, str) => Math.max(max, str.name.length),\n reportFile1LineText.length,\n );\n\n logger.info(`Bundle generated ${bundleFiles.length} files\\n`);\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n logger.log(chalk.bold(chalk.green(headerRow)));\n\n bundleFiles.forEach(({ name, size }) => {\n const infoRow = `${name}${' '.repeat(\n longestFileLength - name.length + 2,\n )}${prettyBytes(size)}`;\n logger.log(infoRow);\n });\n};\n\nconst printBundlelessInfo = () => {\n if (bundlelessFiles.length === 0) {\n return;\n }\n\n const count = bundlelessFiles.length;\n const totalSize = bundlelessFiles.reduce((total, file) => {\n return total + file.size;\n }, 0);\n const info = `Bundleless generated ${count} files, the total size is ${chalk.cyan(\n prettyBytes(totalSize),\n )}`;\n logger.info(info);\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EAkBaA,aAAW,MAAXA;EAEAC,iBAAe,MAAfA;EAEAC,gBAAc,MAAdA;EAmBAC,gBAAc,MAAdA;EAiBAC,aAAW,MAAXA;EAeAC,eAAa,MAAbA;EAKAC,cAAY,MAAZA;;;sBA9EqB;uBAEJ;qBASvB;AAOA,MAAMN,cAAuB;AAE7B,MAAMC,kBAA2B;AAEjC,MAAMC,iBAAiB,CAC5BK,aACAC,cACAC,aACG;AACH,QAAMC,QAAQC,MAAMC,KAAKL,aAAaM,IAAIC,SAAO;AAC/C,UAAM,CAACC,MAAMC,SAASF;AACtB,WAAO;MACLG,OAAMC,mBAASV,cAAcO;MAC7BI,MAAMH,MAAMI,SAASC;IACvB;EACF;AACA,MAAIZ,UAAU;AACZT,gBAAYsB,KAAI,GAAIZ;EACtB,OAAO;AACLT,oBAAgBqB,KAAI,GAAIZ;EAC1B;AACF;AAEO,MAAMP,iBAAiB,CAC5BoB,cACAf,cACAgB,YACG;AACH,QAAM,EAAEC,OAAM,IAAKF;AACnBvB,cAAYsB,KAAI,GACXG,OAAOZ,IAAIa,OAAK;AACjB,WAAO;MACLT,OAAMC,mBAASV,eAAcmB,kBAAQH,SAASE,EAAEE,QAAQ;;MAExDT,MAAO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AAElCzD,cAAY8D,QAAQ,CAAC,EAAE7C,MAAME,KAAI,MAAO;AACtC,UAAM4C,UAAU,GAAG9C,OAAO,IAAIyC,OAC5BN,oBAAoBnC,KAAKI,SAAS,KAChCsB,YAAYxB;AAChBqB,kBAAOS,IAAIc;EACb;AACF;AAEA,MAAM7B,sBAAsB,MAAM;AAChC,MAAIjC,gBAAgBoB,WAAW,GAAG;AAChC;EACF;AAEA,QAAM2C,QAAQ/D,gBAAgBoB;AAC9B,QAAM4C,YAAYhE,gBAAgBoD,OAAO,CAACa,OAAOjC,SAAS;AACxD,WAAOiC,QAAQjC,KAAKd;EACtB,GAAG;AACH,QAAMsB,OAAO,wBAAwBuB,kCAAkC1B,aAAMC,KAC3EI,YAAYsB;AAEdzB,gBAAOC,KAAKA;AACd;","names":["bundleFiles","bundlelessFiles","addOutputChunk","addRollupChunk","addDtsFiles","printFileSize","printSucceed","outputChunk","appDirectory","isBundle","files","Array","from","map","val","path","chunk","name","relative","size","contents","length","push","rollupOutput","distDir","output","o","resolve","fileName","code","fastGlob","slash","stats","file","printBundlelessInfo","printBundleFiles","totalDuration","time","chalk","cyan","logger","info","buildSuccessText","prettyBytes","bytes","unit","exp","Math","floor","log","pow","toFixed","longestFileLength","reduce","max","str","reportFile1LineText","headerRow","repeat","reportFile2LineText","bold","green","forEach","infoRow","count","totalSize","total"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/print.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport type { ILibuilder } from '@modern-js/libuild';\nimport { chalk, logger } from '@modern-js/utils';\nimport type {\n RollupOutput,\n OutputChunk,\n} from '../../compiled/rollup/types/rollup';\nimport {\n buildSuccessText,\n reportFile1LineText,\n reportFile2LineText,\n} from '../constants/log';\n\ntype Files = {\n name: string;\n size: number;\n};\n\nexport const bundleFiles: Files[] = [];\n\nexport const bundlelessFiles: Files[] = [];\n\nexport const addOutputChunk = (\n outputChunk: ILibuilder['outputChunk'],\n appDirectory: string,\n isBundle: boolean,\n) => {\n const files = Array.from(outputChunk).map(val => {\n const [path, chunk] = val;\n return {\n name: relative(appDirectory, path),\n size: chunk.contents.length,\n };\n });\n if (isBundle) {\n bundleFiles.push(...files);\n } else {\n bundlelessFiles.push(...files);\n }\n};\n\nexport const addRollupChunk = (\n rollupOutput: RollupOutput,\n appDirectory: string,\n distDir: string,\n) => {\n const { output } = rollupOutput;\n bundleFiles.push(\n ...output.map(o => {\n return {\n name: relative(appDirectory, resolve(distDir, o.fileName)),\n // only d.ts, is outputChunk not outputAsset\n size: (o as OutputChunk).code.length,\n };\n }),\n );\n};\n\nexport const addDtsFiles = async (distDir: string, appDirectory: string) => {\n const { fastGlob, slash } = await import('@modern-js/utils');\n const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {\n stats: true,\n });\n bundlelessFiles.push(\n ...files.map(file => {\n return {\n name: relative(appDirectory, file.path),\n size: file.stats.size,\n };\n }),\n );\n};\n\nexport const printFileSize = () => {\n printBundlelessInfo();\n printBundleFiles();\n};\n\nexport const printSucceed = (totalDuration: number) => {\n const time = chalk.cyan(`${totalDuration / 1000}s`);\n logger.info(`${buildSuccessText} in ${time}`);\n};\n\nconst prettyBytes = (bytes: number) => {\n if (bytes === 0) {\n return '0 B';\n }\n const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const exp = Math.floor(Math.log(bytes) / Math.log(1024));\n return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;\n};\n\nconst printBundleFiles = () => {\n if (bundleFiles.length === 0) {\n return;\n }\n const longestFileLength = bundleFiles.reduce(\n (max, str) => Math.max(max, str.name.length),\n reportFile1LineText.length,\n );\n\n logger.info(`Bundle generated ${bundleFiles.length} files\\n`);\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n logger.log(chalk.bold(chalk.green(headerRow)));\n\n bundleFiles.forEach(({ name, size }) => {\n const infoRow = `${name}${' '.repeat(\n longestFileLength - name.length + 2,\n )}${prettyBytes(size)}`;\n logger.log(infoRow);\n });\n};\n\nconst printBundlelessInfo = () => {\n if (bundlelessFiles.length === 0) {\n return;\n }\n\n const count = bundlelessFiles.length;\n const totalSize = bundlelessFiles.reduce((total, file) => {\n return total + file.size;\n }, 0);\n const info = `Bundleless generated ${count} files, the total size is ${chalk.cyan(\n prettyBytes(totalSize),\n )}`;\n logger.info(info);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,eAAa,MAAbA;EAeAC,eAAa,MAAbA;EAcAC,kBAAgB,MAAhBA;EA0CAC,gBAAc,MAAdA;;;AAvEN,MAAMH,gBAAgB,OAAOI,WAAmC;MASnEA;AARF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AAEzC,QAAMC,gBAAgBF,kBACpB;IACEG,aAAa;MAAEC,mBAAmB;IAAK;IACvCC,gBAAgB,MAAMJ,gBAAgB;EACxC,IACAF,wEAAQO,WAAK,QAAbP,kDAAeQ,SAAQ,CAAC;AAG1B,SAAOL;AACT;AAEO,MAAMN,gBAAgB,OAAOG,WAAmC;MAQnEA;AAPF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AAEzC,QAAMC,gBAAgBF,kBACpB;IACEK,gBAAgB,MAAMJ,gBAAgB;EACxC,IACAF,wEAAQO,WAAK,QAAbP,kDAAeS,SAAQ,CAAC;AAG1B,SAAON;AACT;AAEO,MAAML,mBAAmB,OAAOE,WAAmC;MAgCtEA;AA/BF,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,QAAM,EAAEC,gBAAe,IAAK,MAAM,iFAAO;AACzC,QAAMQ,eAAiC;AAEvC,QAAMC,QAAQ;IACZC,WAAWC,SAA4C;AACrD,UAAIC,MAAMC,QAAQF,UAAU;AAC1BH,qBAAaM,KAAI,GAAIH;MACvB,OAAO;AACLH,qBAAaM,KAAKH;MACpB;IACF;EACF;AAEA,QAAMI,eAAehB,kBAInB;;;IAGEY,SAAS;MACPK,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BgB,QAAQ,MAAMhB,gBAAgB;MAC9BiB,OAAOC;EACX,IACApB,wEAAQO,WAAK,QAAbP,kDAAeqB,YAAW,CAAC,GAC3BV;AAEF,MAAID,aAAaY,QAAQ;AACvBL,iBAAaJ,QAASG,KAAI,GAAIN;EAChC;AAEA,SAAOO;AACT;AAEO,MAAMlB,iBAAiB,OAAOC,WAAmC;AACtE,QAAMuB,gBAAgB,MAAMzB,iBAAiBE;AAC7C,QAAMwB,aAAa,MAAM5B,cAAcI;AACvC,QAAMyB,aAAa,MAAM5B,cAAcG;AACvC,SAAO;IACLQ,MAAMgB;IACNf,MAAMgB;IACNJ,SAASE;EACX;AACF;","names":["getLessConfig","getSassConfig","getPostcssConfig","getStyleConfig","config","applyOptionsChain","getCompiledPath","mergedOptions","lessOptions","javascriptEnabled","implementation","style","less","sass","extraPlugins","utils","addPlugins","plugins","Array","isArray","push","mergedConfig","require","filter","Boolean","postcss","length","postcssConfig","lessConfig","sassConfig"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/style.ts"],"sourcesContent":["import type { AcceptedPlugin } from 'postcss';\nimport type { PostcssOptions } from '@modern-js/libuild';\nimport type {\n PartialBaseBuildConfig,\n PostCSSConfigUtils,\n LessOptions,\n SassOptions,\n} from '../types';\n\nexport const getLessConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<LessOptions, never>(\n {\n lessOptions: { javascriptEnabled: true },\n implementation: await getCompiledPath('less'),\n },\n config?.style?.less || {},\n );\n\n return mergedOptions;\n};\n\nexport const getSassConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<SassOptions, never>(\n {\n implementation: await getCompiledPath('sass'),\n },\n config?.style?.sass || {},\n );\n\n return mergedOptions;\n};\n\nexport const getPostcssConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n const extraPlugins: AcceptedPlugin[] = [];\n\n const utils = {\n addPlugins(plugins: AcceptedPlugin | AcceptedPlugin[]) {\n if (Array.isArray(plugins)) {\n extraPlugins.push(...plugins);\n } else {\n extraPlugins.push(plugins);\n }\n },\n };\n\n const mergedConfig = applyOptionsChain<\n PostcssOptions & { $$tools?: string },\n PostCSSConfigUtils\n >(\n {\n // TODO: when schema support redefine\n // $$tools: 'module-tools',\n plugins: [\n require(await getCompiledPath('postcss-flexbugs-fixes')),\n require(await getCompiledPath('postcss-custom-properties')),\n require(await getCompiledPath('postcss-initial')),\n require(await getCompiledPath('postcss-page-break')),\n require(await getCompiledPath('postcss-font-variant')),\n require(await getCompiledPath('postcss-media-minmax')),\n require(await getCompiledPath('postcss-nesting')),\n ].filter(Boolean),\n },\n config?.style?.postcss || {},\n utils,\n );\n if (extraPlugins.length) {\n mergedConfig.plugins!.push(...extraPlugins);\n }\n\n return mergedConfig;\n};\n\nexport const getStyleConfig = async (config: PartialBaseBuildConfig) => {\n const postcssConfig = await getPostcssConfig(config);\n const lessConfig = await getLessConfig(config);\n const sassConfig = await getSassConfig(config);\n return {\n less: lessConfig,\n sass: sassConfig,\n postcss: postcssConfig,\n };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA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BgB,QAAQ,MAAMhB,gBAAgB;MAC9BiB,OAAOC;EACX,IACApB,wEAAQO,WAAK,QAAbP,kDAAeqB,YAAW,CAAC,GAC3BV;AAEF,MAAID,aAAaY,QAAQ;AACvBL,iBAAaJ,QAASG,KAAI,GAAIN;EAChC;AAEA,SAAOO;AACT;AAEO,MAAMlB,iBAAiB,OAAOC,WAAmC;AACtE,QAAMuB,gBAAgB,MAAMzB,iBAAiBE;AAC7C,QAAMwB,aAAa,MAAM5B,cAAcI;AACvC,QAAMyB,aAAa,MAAM5B,cAAcG;AACvC,SAAO;IACLQ,MAAMgB;IACNf,MAAMgB;IACNJ,SAASE;EACX;AACF;","names":["getLessConfig","getSassConfig","getPostcssConfig","getStyleConfig","config","applyOptionsChain","getCompiledPath","mergedOptions","lessOptions","javascriptEnabled","implementation","style","less","sass","extraPlugins","utils","addPlugins","plugins","Array","isArray","push","mergedConfig","require","filter","Boolean","postcss","length","postcssConfig","lessConfig","sassConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/style.ts"],"sourcesContent":["import type { AcceptedPlugin } from 'postcss';\nimport type { PostcssOptions } from '@modern-js/libuild';\nimport type {\n PartialBaseBuildConfig,\n PostCSSConfigUtils,\n LessOptions,\n SassOptions,\n} from '../types';\n\nexport const getLessConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<LessOptions, never>(\n {\n lessOptions: { javascriptEnabled: true },\n implementation: await getCompiledPath('less'),\n },\n config?.style?.less || {},\n );\n\n return mergedOptions;\n};\n\nexport const getSassConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<SassOptions, never>(\n {\n implementation: await getCompiledPath('sass'),\n },\n config?.style?.sass || {},\n );\n\n return mergedOptions;\n};\n\nexport const getPostcssConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n const extraPlugins: AcceptedPlugin[] = [];\n\n const utils = {\n addPlugins(plugins: AcceptedPlugin | AcceptedPlugin[]) {\n if (Array.isArray(plugins)) {\n extraPlugins.push(...plugins);\n } else {\n extraPlugins.push(plugins);\n }\n },\n };\n\n const mergedConfig = applyOptionsChain<\n PostcssOptions & { $$tools?: string },\n PostCSSConfigUtils\n >(\n {\n // TODO: when schema support redefine\n // $$tools: 'module-tools',\n plugins: [\n require(await getCompiledPath('postcss-flexbugs-fixes')),\n require(await getCompiledPath('postcss-custom-properties')),\n require(await getCompiledPath('postcss-initial')),\n require(await getCompiledPath('postcss-page-break')),\n require(await getCompiledPath('postcss-font-variant')),\n require(await getCompiledPath('postcss-media-minmax')),\n require(await getCompiledPath('postcss-nesting')),\n ].filter(Boolean),\n },\n config?.style?.postcss || {},\n utils,\n );\n if (extraPlugins.length) {\n mergedConfig.plugins!.push(...extraPlugins);\n }\n\n return mergedConfig;\n};\n\nexport const getStyleConfig = async (config: PartialBaseBuildConfig) => {\n const postcssConfig = await getPostcssConfig(config);\n const lessConfig = await getLessConfig(config);\n const sassConfig = await getSassConfig(config);\n return {\n less: lessConfig,\n sass: sassConfig,\n postcss: postcssConfig,\n };\n};\n"]}
@@ -11,10 +11,10 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
11
11
  const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
12
12
  const _tsconfigpaths = require("@modern-js/utils/tsconfig-paths");
13
13
  const _utils = require("@modern-js/utils");
14
- const _parser = /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/@babel/parser"));
15
- const _generator = /* @__PURE__ */ _interop_require_default._(require("../../compiled/@babel/generator"));
16
- const _types = /* @__PURE__ */ _interop_require_wildcard._(require("../../compiled/@babel/types"));
17
- const _traverse = /* @__PURE__ */ _interop_require_default._(require("../../compiled/@babel/traverse"));
14
+ const _parser = /* @__PURE__ */ _interop_require_wildcard._(require("@babel/parser"));
15
+ const _generator = /* @__PURE__ */ _interop_require_default._(require("@babel/generator"));
16
+ const _types = /* @__PURE__ */ _interop_require_wildcard._(require("@babel/types"));
17
+ const _traverse = /* @__PURE__ */ _interop_require_default._(require("@babel/traverse"));
18
18
  const _file = require("../constants/file");
19
19
  function mapPathString(nodePath, { filename, baseUrl, paths }) {
20
20
  if (!_types.isStringLiteral(nodePath)) {
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;+BAmHaA;;aAAAA;;;;kEAnHS;+BACU;uBACb;oEACK;sEACF;mEACH;qEACgB;sBACN;AAU7B,SAASC,cACPC,UACA,EAAEC,UAAUC,SAASC,MAAK,GAC1B;AACA,MAAI,CAACC,OAAEC,gBAAgBL,WAAW;AAChC;EACF;AAEA,QAAMM,aAAaN,SAASO,KAAKC;AACjC,QAAMC,cAAcR;AACpB,QAAMS,aAAYC,mCAChBT,SACAC,OACA;IAAC;GAAQ;AAEX,QAAMS,SAASF,UACbJ,YACAO,qBAAmB;AACjB,QAAI,CAACC,UAAGC,WAAWF,kBAAkB;AACnC,aAAOG;IACT;AACA,WAAOF,UAAGG,aAAaJ;EACzB,GACAK,cAAYJ,UAAGC,WAAWG,WAC1BC,kBAAY;AAEd,MAAIP,QAAQ;AACV,UAAMQ,eAAeC,MAAKC,SACxBD,MAAKE,QAAQd,cACbY,MAAKE,QAAQX;AAEf,UAAMY,WAAWH,MAAKI,SAASb;AAE/B,UAAMM,WAAWG,MAAKK,UACpB,GAAGN,aAAaO,WAAW,IAAI,MAAMP,gBAAgBI,UAAU;AAEjE,UAAMI,gBAAgBV,SAASW,WAAW,OAAOX,WAAW,KAAKA;AACjElB,aAAS8B,YAAY1B,OAAE2B,cAAcH;EACvC;AACF;AAgBA,MAAMI,kBACJ,CAACC,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAWD;AACxC;AAEF,MAAME,kBACJ,CAACF,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAwCD;AACrE;AAEF,MAAMG,2BAA2B,CAAC,EAChCnC,UACAC,SACAC,MAAK,MACgB;AACrB,QAAMkC,aAAavB,UAAGwB,aAAarC,UAAU;AAC7C,QAAMsC,MAAMC,QAAOC,MAAMJ,YAAY;IACnCK,YAAY;IACZC,eAAe;IACfC,SAAS;MAAC;;EACZ;AACAC,yBAASN,KAAK;;;IAGZO,mBAAmBd,gBAAgB;MACjC/B;MACAC;MACAC;IACF;IACA4C,mBAAmBZ,gBAAgB;MACjClC;MACAC;MACAC;IACF;EACF;AACA,UAAO6C,uBAAUT,KAAKU;AACxB;AAOO,MAAMnD,oBAAoB,CAACmC,WAAoC;AACpE,QAAM,EAAEiB,YAAY,IAAIhD,SAASC,MAAK,IAAK8B;AAC3C,QAAMkB,kBAAuD;AAC7D,aAAWlD,YAAYiD,WAAW;AAChCC,oBAAgBC,KAAK;MACnB/B,MAAMpB;MACNoD,SAASjB,yBAAyB;QAAEnC;QAAUC;QAASC;MAAM;IAC/D;EACF;AACA,SAAOgD;AACT;","names":["transformDtsAlias","mapPathString","nodePath","filename","baseUrl","paths","t","isStringLiteral","sourcePath","node","value","currentFile","matchPath","createMatchPath","result","packageJsonPath","fs","existsSync","undefined","readJSONSync","filePath","dtsAliasExts","relativePath","path","relative","dirname","fileName","basename","normalize","length","replaceString","startsWith","replaceWith","stringLiteral","transformImport","option","get","transformExport","transformSingleFileAlias","sourceCode","readFileSync","ast","parser","parse","sourceType","errorRecovery","plugins","traverse","ImportDeclaration","ExportDeclaration","generator","code","filenames","transformResult","push","content"],"sources":["../../src/utils/Users/bytedance/github/targeral/modern-js/packages/solutions/module-tools/src/utils/tspathsTransform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '../../compiled/@babel/parser';\nimport generator from '../../compiled/@babel/generator';\nimport * as t from '../../compiled/@babel/types';\nimport traverse, { NodePath } from '../../compiled/@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<t.StringLiteral>,\n { filename, baseUrl, paths }: TransformOption,\n) {\n if (!t.isStringLiteral(nodePath)) {\n return;\n }\n\n const sourcePath = nodePath.node.value;\n const currentFile = filename;\n const matchPath = createMatchPath(\n baseUrl,\n paths as { [key: string]: Array<string> },\n ['index'],\n );\n const result = matchPath(\n sourcePath,\n packageJsonPath => {\n if (!fs.existsSync(packageJsonPath)) {\n return undefined;\n }\n return fs.readJSONSync(packageJsonPath);\n },\n filePath => fs.existsSync(filePath),\n dtsAliasExts,\n );\n if (result) {\n const relativePath = path.relative(\n path.dirname(currentFile),\n path.dirname(result),\n );\n const fileName = path.basename(result);\n // 如果是同级文件,则返回的是 ''\n const filePath = path.normalize(\n `${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,\n );\n const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;\n nodePath.replaceWith(t.stringLiteral(replaceString));\n }\n}\n\n// const transformCall =\n// (option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {\n// const calleePath = nodePath.get('callee') as NodePath;\n// const isNormalCall = defaultTransformedFunctions.some(pattern =>\n// matchesPattern(calleePath, pattern),\n// );\n// if (isNormalCall || isImportCall(nodePath)) {\n// mapPathString(\n// nodePath.get('arguments.0') as NodePath<t.StringLiteral>,\n// option,\n// );\n// }\n// };\n\nconst transformImport =\n (option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {\n mapPathString(nodePath.get('source'), option);\n };\n\nconst transformExport =\n (option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {\n mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);\n };\n\nconst transformSingleFileAlias = ({\n filename,\n baseUrl,\n paths,\n}: TransformOption) => {\n const sourceCode = fs.readFileSync(filename, 'utf-8');\n const ast = parser.parse(sourceCode, {\n sourceType: 'module',\n errorRecovery: true, // 防止typescript不支持的语法出现而报错\n plugins: ['typescript'],\n });\n traverse(ast, {\n // d.ts file content not have callExpression which can be parsed;\n // CallExpression: transformCall({ filename, baseUrl, paths }) as any,\n ImportDeclaration: transformImport({\n filename,\n baseUrl,\n paths,\n }) as any,\n ExportDeclaration: transformExport({\n filename,\n baseUrl,\n paths,\n }) as any,\n });\n return generator(ast).code;\n};\n\ninterface TransformDtsAliasOption {\n filenames?: string[];\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\nexport const transformDtsAlias = (option: TransformDtsAliasOption) => {\n const { filenames = [], baseUrl, paths } = option;\n const transformResult: { path: string; content: string }[] = [];\n for (const filename of filenames) {\n transformResult.push({\n path: filename,\n content: transformSingleFileAlias({ filename, baseUrl, paths }),\n });\n }\n return transformResult;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;+BAmHaA;;aAAAA;;;;kEAnHS;+BACU;uBACb;oEACK;sEACF;mEACH;qEACgB;sBACN;AAU7B,SAASC,cACPC,UACA,EAAEC,UAAUC,SAASC,MAAK,GAC1B;AACA,MAAI,CAACC,OAAEC,gBAAgBL,WAAW;AAChC;EACF;AAEA,QAAMM,aAAaN,SAASO,KAAKC;AACjC,QAAMC,cAAcR;AACpB,QAAMS,aAAYC,mCAChBT,SACAC,OACA;IAAC;GAAQ;AAEX,QAAMS,SAASF,UACbJ,YACAO,qBAAmB;AACjB,QAAI,CAACC,UAAGC,WAAWF,kBAAkB;AACnC,aAAOG;IACT;AACA,WAAOF,UAAGG,aAAaJ;EACzB,GACAK,cAAYJ,UAAGC,WAAWG,WAC1BC,kBAAY;AAEd,MAAIP,QAAQ;AACV,UAAMQ,eAAeC,MAAKC,SACxBD,MAAKE,QAAQd,cACbY,MAAKE,QAAQX;AAEf,UAAMY,WAAWH,MAAKI,SAASb;AAE/B,UAAMM,WAAWG,MAAKK,UACpB,GAAGN,aAAaO,WAAW,IAAI,MAAMP,gBAAgBI,UAAU;AAEjE,UAAMI,gBAAgBV,SAASW,WAAW,OAAOX,WAAW,KAAKA;AACjElB,aAAS8B,YAAY1B,OAAE2B,cAAcH;EACvC;AACF;AAgBA,MAAMI,kBACJ,CAACC,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAWD;AACxC;AAEF,MAAME,kBACJ,CAACF,WAA4B,CAACjC,aAA4C;AACxED,gBAAcC,SAASkC,IAAI,WAAwCD;AACrE;AAEF,MAAMG,2BAA2B,CAAC,EAChCnC,UACAC,SACAC,MAAK,MACgB;AACrB,QAAMkC,aAAavB,UAAGwB,aAAarC,UAAU;AAC7C,QAAMsC,MAAMC,QAAOC,MAAMJ,YAAY;IACnCK,YAAY;IACZC,eAAe;IACfC,SAAS;MAAC;;EACZ;AACAC,yBAASN,KAAK;;;IAGZO,mBAAmBd,gBAAgB;MACjC/B;MACAC;MACAC;IACF;IACA4C,mBAAmBZ,gBAAgB;MACjClC;MACAC;MACAC;IACF;EACF;AACA,UAAO6C,uBAAUT,KAAKU;AACxB;AAOO,MAAMnD,oBAAoB,CAACmC,WAAoC;AACpE,QAAM,EAAEiB,YAAY,IAAIhD,SAASC,MAAK,IAAK8B;AAC3C,QAAMkB,kBAAuD;AAC7D,aAAWlD,YAAYiD,WAAW;AAChCC,oBAAgBC,KAAK;MACnB/B,MAAMpB;MACNoD,SAASjB,yBAAyB;QAAEnC;QAAUC;QAASC;MAAM;IAC/D;EACF;AACA,SAAOgD;AACT;","names":["transformDtsAlias","mapPathString","nodePath","filename","baseUrl","paths","t","isStringLiteral","sourcePath","node","value","currentFile","matchPath","createMatchPath","result","packageJsonPath","fs","existsSync","undefined","readJSONSync","filePath","dtsAliasExts","relativePath","path","relative","dirname","fileName","basename","normalize","length","replaceString","startsWith","replaceWith","stringLiteral","transformImport","option","get","transformExport","transformSingleFileAlias","sourceCode","readFileSync","ast","parser","parse","sourceType","errorRecovery","plugins","traverse","ImportDeclaration","ExportDeclaration","generator","code","filenames","transformResult","push","content"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/tspathsTransform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '@babel/parser';\nimport generator from '@babel/generator';\nimport * as t from '@babel/types';\nimport traverse, { NodePath } from '@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<t.StringLiteral>,\n { filename, baseUrl, paths }: TransformOption,\n) {\n if (!t.isStringLiteral(nodePath)) {\n return;\n }\n\n const sourcePath = nodePath.node.value;\n const currentFile = filename;\n const matchPath = createMatchPath(\n baseUrl,\n paths as { [key: string]: Array<string> },\n ['index'],\n );\n const result = matchPath(\n sourcePath,\n packageJsonPath => {\n if (!fs.existsSync(packageJsonPath)) {\n return undefined;\n }\n return fs.readJSONSync(packageJsonPath);\n },\n filePath => fs.existsSync(filePath),\n dtsAliasExts,\n );\n if (result) {\n const relativePath = path.relative(\n path.dirname(currentFile),\n path.dirname(result),\n );\n const fileName = path.basename(result);\n // 如果是同级文件,则返回的是 ''\n const filePath = path.normalize(\n `${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,\n );\n const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;\n nodePath.replaceWith(t.stringLiteral(replaceString));\n }\n}\n\n// const transformCall =\n// (option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {\n// const calleePath = nodePath.get('callee') as NodePath;\n// const isNormalCall = defaultTransformedFunctions.some(pattern =>\n// matchesPattern(calleePath, pattern),\n// );\n// if (isNormalCall || isImportCall(nodePath)) {\n// mapPathString(\n// nodePath.get('arguments.0') as NodePath<t.StringLiteral>,\n// option,\n// );\n// }\n// };\n\nconst transformImport =\n (option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {\n mapPathString(nodePath.get('source'), option);\n };\n\nconst transformExport =\n (option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {\n mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);\n };\n\nconst transformSingleFileAlias = ({\n filename,\n baseUrl,\n paths,\n}: TransformOption) => {\n const sourceCode = fs.readFileSync(filename, 'utf-8');\n const ast = parser.parse(sourceCode, {\n sourceType: 'module',\n errorRecovery: true, // 防止typescript不支持的语法出现而报错\n plugins: ['typescript'],\n });\n traverse(ast, {\n // d.ts file content not have callExpression which can be parsed;\n // CallExpression: transformCall({ filename, baseUrl, paths }) as any,\n ImportDeclaration: transformImport({\n filename,\n baseUrl,\n paths,\n }) as any,\n ExportDeclaration: transformExport({\n filename,\n baseUrl,\n paths,\n }) as any,\n });\n return generator(ast).code;\n};\n\ninterface TransformDtsAliasOption {\n filenames?: string[];\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\nexport const transformDtsAlias = (option: TransformDtsAliasOption) => {\n const { filenames = [], baseUrl, paths } = option;\n const transformResult: { path: string; content: string }[] = [];\n for (const filename of filenames) {\n transformResult.push({\n path: filename,\n content: transformSingleFileAlias({ filename, baseUrl, paths }),\n });\n }\n return transformResult;\n};\n"]}
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "module-tools",
16
16
  "lib-tools"
17
17
  ],
18
- "version": "2.19.2-beta.5",
18
+ "version": "2.21.0",
19
19
  "bin": {
20
20
  "modern": "./bin/modern.js",
21
21
  "modern-module": "./bin/modern.js"
@@ -40,21 +40,27 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
+ "@babel/parser": "^7.21.8",
44
+ "@babel/generator": "^7.21.5",
45
+ "@babel/types": "^7.21.5",
46
+ "@babel/traverse": "^7.21.5",
43
47
  "@modern-js/libuild": "0.12.2",
44
48
  "@modern-js/libuild-plugin-svgr": "0.12.2",
45
49
  "@modern-js/libuild-plugin-swc": "0.12.2",
46
50
  "postcss": "8.4.6",
47
51
  "@swc/helpers": "0.5.1",
48
- "@modern-js/plugin-i18n": "2.19.1",
49
- "@modern-js/core": "2.19.1",
50
- "@modern-js/new-action": "2.19.1",
51
- "@modern-js/plugin": "2.19.1",
52
- "@modern-js/plugin-lint": "2.19.1",
53
- "@modern-js/upgrade": "2.19.1",
54
- "@modern-js/utils": "2.19.1",
55
- "@modern-js/plugin-changeset": "2.19.1"
52
+ "@modern-js/core": "2.21.0",
53
+ "@modern-js/new-action": "2.21.0",
54
+ "@modern-js/plugin": "2.21.0",
55
+ "@modern-js/plugin-changeset": "2.21.0",
56
+ "@modern-js/plugin-i18n": "2.21.0",
57
+ "@modern-js/plugin-lint": "2.21.0",
58
+ "@modern-js/upgrade": "2.21.0",
59
+ "@modern-js/utils": "2.21.0"
56
60
  },
57
61
  "devDependencies": {
62
+ "@types/babel__generator": "7.6.4",
63
+ "@types/babel__traverse": "7.18.5",
58
64
  "@types/fs-extra": "9.0.13",
59
65
  "@types/jest": "^29",
60
66
  "@types/node": "^14",
@@ -64,11 +70,11 @@
64
70
  "path-browserify": "1.0.1",
65
71
  "postcss-alias": "2.0.0",
66
72
  "react": "17",
67
- "typescript": "^4",
68
- "@modern-js/builder-webpack-provider": "2.19.1",
69
- "@modern-js/self": "npm:@modern-js/module-tools@2.19.2-beta.5",
70
- "@scripts/build": "2.19.1",
71
- "@scripts/jest-config": "2.19.1"
73
+ "typescript": "^5",
74
+ "@modern-js/builder-webpack-provider": "2.21.0",
75
+ "@modern-js/self": "npm:@modern-js/module-tools@2.21.0",
76
+ "@scripts/jest-config": "2.21.0",
77
+ "@scripts/build": "2.21.0"
72
78
  },
73
79
  "publishConfig": {
74
80
  "registry": "https://registry.npmjs.org/",
@@ -80,7 +86,7 @@
80
86
  }
81
87
  },
82
88
  "peerDependencies": {
83
- "typescript": "^4"
89
+ "typescript": "^4 || ^5"
84
90
  },
85
91
  "scripts": {
86
92
  "build": "modern-lib build",
@@ -1 +0,0 @@
1
- export = any;
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e={367:e=>{e.exports=require("../highlight")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var s=t[r]={exports:{}};var o=true;try{e[r](s,s.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:true});e.codeFrameColumns=codeFrameColumns;e["default"]=_default;var t=__nccwpck_require__(367);let n=false;function getDefs(e){return{gutter:e.grey,marker:e.red.bold,message:e.red.bold}}const s=/\r\n|[\n\r\u2028\u2029]/;function getMarkerLines(e,t,r){const n=Object.assign({column:0,line:-1},e.start);const s=Object.assign({},n,e.end);const{linesAbove:o=2,linesBelow:a=3}=r||{};const i=n.line;const l=n.column;const c=s.line;const u=s.column;let f=Math.max(i-(o+1),0);let m=Math.min(t.length,c+a);if(i===-1){f=0}if(c===-1){m=t.length}const g=c-i;const d={};if(g){for(let e=0;e<=g;e++){const r=e+i;if(!l){d[r]=true}else if(e===0){const e=t[r-1].length;d[r]=[l,e-l+1]}else if(e===g){d[r]=[0,u]}else{const n=t[r-e].length;d[r]=[0,n]}}}else{if(l===u){if(l){d[i]=[l,0]}else{d[i]=true}}else{d[i]=[l,u-l]}}return{start:f,end:m,markerLines:d}}function codeFrameColumns(e,r,n={}){const o=(n.highlightCode||n.forceColor)&&(0,t.shouldHighlight)(n);const a=(0,t.getChalk)(n);const i=getDefs(a);const maybeHighlight=(e,t)=>o?e(t):t;const l=e.split(s);const{start:c,end:u,markerLines:f}=getMarkerLines(r,l,n);const m=r.start&&typeof r.start.column==="number";const g=String(u).length;const d=o?(0,t.default)(e,n):e;let _=d.split(s,u).slice(c,u).map(((e,t)=>{const r=c+1+t;const s=` ${r}`.slice(-g);const o=` ${s} |`;const a=f[r];const l=!f[r+1];if(a){let t="";if(Array.isArray(a)){const r=e.slice(0,Math.max(a[0]-1,0)).replace(/[^\t]/g," ");const s=a[1]||1;t=["\n ",maybeHighlight(i.gutter,o.replace(/\d/g," "))," ",r,maybeHighlight(i.marker,"^").repeat(s)].join("");if(l&&n.message){t+=" "+maybeHighlight(i.message,n.message)}}return[maybeHighlight(i.marker,">"),maybeHighlight(i.gutter,o),e.length>0?` ${e}`:"",t].join("")}else{return` ${maybeHighlight(i.gutter,o)}${e.length>0?` ${e}`:""}`}})).join("\n");if(n.message&&!m){_=`${" ".repeat(g+1)}${n.message}\n${_}`}if(o){return a.reset(_)}else{return _}}function _default(e,t,r,s={}){if(!n){n=true;const e="Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";if(process.emitWarning){process.emitWarning(e,"DeprecationWarning")}else{const t=new Error(e);t.name="DeprecationWarning";console.warn(new Error(e))}}r=Math.max(r,0);const o={start:{column:r,line:t}};return codeFrameColumns(e,o,s)}})();module.exports=r})();
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2014-present Sebastian McKenzie and other contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1 +0,0 @@
1
- {"name":"@babel/code-frame","author":"The Babel Team (https://babel.dev/team)","version":"7.16.7","license":"MIT","types":"index.d.ts"}
@@ -1 +0,0 @@
1
- export = any;