@modern-js/module-tools 2.15.0 → 2.16.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 (135) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/compiled/postcss-custom-properties/index.js +1 -1
  3. package/compiled/postcss-custom-properties/package.json +1 -1
  4. package/dist/build.js +23 -66
  5. package/dist/build.js.map +1 -1
  6. package/dist/builder/build.js +114 -170
  7. package/dist/builder/build.js.map +1 -1
  8. package/dist/builder/clear.js +23 -65
  9. package/dist/builder/clear.js.map +1 -1
  10. package/dist/builder/copy.js +83 -164
  11. package/dist/builder/copy.js.map +1 -1
  12. package/dist/builder/dts/index.js +15 -28
  13. package/dist/builder/dts/index.js.map +1 -1
  14. package/dist/builder/dts/rollup.js +46 -120
  15. package/dist/builder/dts/rollup.js.map +1 -1
  16. package/dist/builder/dts/tsc.js +82 -141
  17. package/dist/builder/dts/tsc.js.map +1 -1
  18. package/dist/builder/index.js +34 -85
  19. package/dist/builder/index.js.map +1 -1
  20. package/dist/builder/platform.js +40 -93
  21. package/dist/builder/platform.js.map +1 -1
  22. package/dist/cli.js +35 -84
  23. package/dist/cli.js.map +1 -1
  24. package/dist/command.js +56 -136
  25. package/dist/command.js.map +1 -1
  26. package/dist/config/defineConfig.js +13 -42
  27. package/dist/config/defineConfig.js.map +1 -1
  28. package/dist/config/legacySchema.js +96 -52
  29. package/dist/config/legacySchema.js.map +1 -1
  30. package/dist/config/normalize.js +73 -149
  31. package/dist/config/normalize.js.map +1 -1
  32. package/dist/config/schema.d.ts +36 -0
  33. package/dist/config/schema.js +118 -56
  34. package/dist/config/schema.js.map +1 -1
  35. package/dist/config/transformLegacyConfig.js +152 -203
  36. package/dist/config/transformLegacyConfig.js.map +1 -1
  37. package/dist/constants/build.js +15 -27
  38. package/dist/constants/build.js.map +1 -1
  39. package/dist/constants/buildPresets.js +71 -84
  40. package/dist/constants/buildPresets.js.map +1 -1
  41. package/dist/constants/colors.js +28 -30
  42. package/dist/constants/colors.js.map +1 -1
  43. package/dist/constants/dts.js +13 -28
  44. package/dist/constants/dts.js.map +1 -1
  45. package/dist/constants/file.js +27 -30
  46. package/dist/constants/file.js.map +1 -1
  47. package/dist/constants/legacyBuildPresets.js +33 -49
  48. package/dist/constants/legacyBuildPresets.js.map +1 -1
  49. package/dist/constants/log.js +15 -33
  50. package/dist/constants/log.js.map +1 -1
  51. package/dist/dev.js +45 -91
  52. package/dist/dev.js.map +1 -1
  53. package/dist/error.js +37 -54
  54. package/dist/error.js.map +1 -1
  55. package/dist/hooks/build.js +22 -35
  56. package/dist/hooks/build.js.map +1 -1
  57. package/dist/hooks/dev.js +15 -33
  58. package/dist/hooks/dev.js.map +1 -1
  59. package/dist/hooks/index.js +15 -42
  60. package/dist/hooks/index.js.map +1 -1
  61. package/dist/hooks/misc.js +10 -28
  62. package/dist/hooks/misc.js.map +1 -1
  63. package/dist/index.js +21 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/locale/en.d.ts +7 -2
  66. package/dist/locale/en.js +25 -32
  67. package/dist/locale/en.js.map +1 -1
  68. package/dist/locale/index.d.ts +14 -4
  69. package/dist/locale/index.js +18 -31
  70. package/dist/locale/index.js.map +1 -1
  71. package/dist/locale/zh.d.ts +7 -2
  72. package/dist/locale/zh.js +25 -32
  73. package/dist/locale/zh.js.map +1 -1
  74. package/dist/plugins.js +16 -39
  75. package/dist/plugins.js.map +1 -1
  76. package/dist/types/color.js +4 -15
  77. package/dist/types/color.js.map +1 -1
  78. package/dist/types/command.js +4 -15
  79. package/dist/types/command.js.map +1 -1
  80. package/dist/types/config/index.d.ts +6 -0
  81. package/dist/types/config/index.js +6 -17
  82. package/dist/types/config/index.js.map +1 -1
  83. package/dist/types/config/style.js +4 -15
  84. package/dist/types/config/style.js.map +1 -1
  85. package/dist/types/context.js +4 -15
  86. package/dist/types/context.js.map +1 -1
  87. package/dist/types/copy.js +4 -15
  88. package/dist/types/copy.js.map +1 -1
  89. package/dist/types/dts.js +4 -15
  90. package/dist/types/dts.js.map +1 -1
  91. package/dist/types/hooks.js +4 -15
  92. package/dist/types/hooks.js.map +1 -1
  93. package/dist/types/index.js +11 -22
  94. package/dist/types/index.js.map +1 -1
  95. package/dist/types/legacyConfig/index.js +4 -15
  96. package/dist/types/legacyConfig/index.js.map +1 -1
  97. package/dist/types/legacyConfig/output.js +4 -15
  98. package/dist/types/legacyConfig/output.js.map +1 -1
  99. package/dist/types/legacyConfig/source.js +4 -15
  100. package/dist/types/legacyConfig/source.js.map +1 -1
  101. package/dist/types/legacyConfig/tools.js +4 -15
  102. package/dist/types/legacyConfig/tools.js.map +1 -1
  103. package/dist/types/utils.js +4 -17
  104. package/dist/utils/builder.d.ts +20 -2
  105. package/dist/utils/builder.js +81 -68
  106. package/dist/utils/builder.js.map +1 -1
  107. package/dist/utils/common.js +10 -44
  108. package/dist/utils/common.js.map +1 -1
  109. package/dist/utils/config.js +108 -144
  110. package/dist/utils/config.js.map +1 -1
  111. package/dist/utils/context.js +16 -59
  112. package/dist/utils/context.js.map +1 -1
  113. package/dist/utils/dts.js +69 -146
  114. package/dist/utils/dts.js.map +1 -1
  115. package/dist/utils/input.js +44 -87
  116. package/dist/utils/input.js.map +1 -1
  117. package/dist/utils/language.js +15 -60
  118. package/dist/utils/language.js.map +1 -1
  119. package/dist/utils/libuildPlugins.js +27 -67
  120. package/dist/utils/libuildPlugins.js.map +1 -1
  121. package/dist/utils/log.js +14 -61
  122. package/dist/utils/log.js.map +1 -1
  123. package/dist/utils/onExit.js +14 -61
  124. package/dist/utils/onExit.js.map +1 -1
  125. package/dist/utils/path.js +13 -59
  126. package/dist/utils/path.js.map +1 -1
  127. package/dist/utils/print.js +57 -105
  128. package/dist/utils/print.js.map +1 -1
  129. package/dist/utils/style.js +54 -106
  130. package/dist/utils/style.js.map +1 -1
  131. package/dist/utils/tspathsTransform.js +44 -81
  132. package/dist/utils/tspathsTransform.js.map +1 -1
  133. package/package.json +25 -20
  134. package/scripts/debug-mode.js +23 -21
  135. package/dist/types/utils.js.map +0 -1
@@ -1,24 +1,13 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);
17
- __reExport(types_exports, require("./hooks"), module.exports);
18
- __reExport(types_exports, require("./command"), module.exports);
19
- __reExport(types_exports, require("./config"), module.exports);
20
- __reExport(types_exports, require("./legacyConfig"), module.exports);
21
- __reExport(types_exports, require("./dts"), module.exports);
22
- __reExport(types_exports, require("./context"), module.exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./hooks"), exports);
7
+ _export_star._(require("./command"), exports);
8
+ _export_star._(require("./config"), exports);
9
+ _export_star._(require("./legacyConfig"), exports);
10
+ _export_star._(require("./dts"), exports);
11
+ _export_star._(require("./context"), exports);
23
12
 
24
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAQA,0BAAc,oBARd;AASA,0BAAc,sBATd;AAUA,0BAAc,qBAVd;AAWA,0BAAc,2BAXd;AAYA,0BAAc,kBAZd;AAaA,0BAAc,sBAbd;","names":[],"sources":["../../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"]}
@@ -1,17 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var legacyConfig_exports = {};
15
- module.exports = __toCommonJS(legacyConfig_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
16
5
 
17
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/index.ts"],"sourcesContent":["import type { OutputLegacyUserConfig } from './output';\nimport type { SourceLegacyUserConfig } from './source';\n\nimport type { ToolsLegacyUserConfig } from './tools';\n\nexport type { OutputLegacyUserConfig } from './output';\n\nexport type { SourceLegacyUserConfig } from './source';\nexport type { ToolsLegacyUserConfig } from './tools';\n\nexport interface RuntimeLegacyConfig {\n [name: string]: any;\n}\n\nexport interface RuntimeByEntriesLegacyConfig {\n [name: string]: RuntimeLegacyConfig;\n}\n\nexport type ModuleToolsLegacyUserConfig = {\n source?: SourceLegacyUserConfig;\n output?: OutputLegacyUserConfig;\n tools?: ToolsLegacyUserConfig;\n runtime?: RuntimeLegacyConfig;\n legacy?: boolean;\n};\n\nexport type ModuleToolsLegacyNormalizedConfig =\n Required<ModuleToolsLegacyUserConfig>;\n"]}
1
+ {"version":3,"mappings":";AACA,OAAO,eAAe,SAAS,cAAc;AAAA,EACzC,OAAO;AACX,CAAC;","names":[],"sources":["../../../src/types/legacyConfig/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n"]}
@@ -1,17 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var output_exports = {};
15
- module.exports = __toCommonJS(output_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
16
5
 
17
6
  //# sourceMappingURL=output.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/output.ts"],"sourcesContent":["import type { UserConfig as LibuildUserConfig } from '@modern-js/libuild';\n\nexport type LegacyBuildPreset =\n | 'npm-library'\n | 'npm-library-with-umd'\n | 'npm-component'\n | 'npm-component-with-umd';\n\nexport type LegacyFormat = 'esm' | 'cjs' | 'umd';\nexport type LegacyTarget =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\nexport type LegacyBuildType = 'bundle' | 'bundleless';\nexport type LegacySourceMap = boolean | 'inline' | 'external';\n\nexport type LegacyBundleOptions = {\n entry?: Record<string, string>;\n platform?: LibuildUserConfig['platform'];\n splitting?: boolean;\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n skipDeps?: boolean;\n getModuleId?: (moduleName: string) => string | undefined;\n};\n\nexport type LegacyBundlelessOptions = {\n sourceDir?: string;\n style?: {\n compileMode?:\n | 'all'\n | 'only-compiled-code'\n | /* may be will be deprecated */ 'only-source-code'\n | false;\n path?: string;\n };\n static?: {\n path?: string;\n };\n};\n\nexport type LegacyBaseBuildConfig = {\n format?: LegacyFormat;\n target?: LegacyTarget;\n sourceMap?: LegacySourceMap;\n buildType?: LegacyBuildType;\n bundleOptions?: LegacyBundleOptions;\n bundlelessOptions?: LegacyBundlelessOptions;\n tsconfig?: string;\n enableDts?: boolean;\n dtsOnly?: boolean;\n outputPath?: string;\n};\n\nexport type LegacyBuildConfig = LegacyBaseBuildConfig | LegacyBaseBuildConfig[];\n\nexport type JsSyntaxType = 'CJS+ES6' | 'ESM+ES5' | 'ESM+ES6';\nexport interface PackageFields {\n main?: JsSyntaxType;\n 'jsnext:modern'?: JsSyntaxType;\n module?: JsSyntaxType;\n}\n\nexport type OutputLegacyUserConfig = {\n jsPath?: string;\n path?: string;\n copy?: Array<Record<string, unknown> & { from: string }>;\n disableTsChecker?: boolean;\n /** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */\n assetsPath?: string;\n /** @deprecated Use the `buildConfig.sourceMap` instead */\n disableSourceMap?: boolean;\n buildPreset?: LegacyBuildPreset;\n buildConfig?: LegacyBuildConfig;\n importStyle?: 'source-code' | 'compiled-code';\n packageMode?:\n | 'universal-js'\n | 'universal-js-lite'\n | 'browser-js'\n | 'browser-js-lite'\n | 'node-js';\n packageFields?: PackageFields;\n};\n"]}
1
+ {"version":3,"mappings":";AACA,OAAO,eAAe,SAAS,cAAc;AAAA,EACzC,OAAO;AACX,CAAC;","names":[],"sources":["../../../src/types/legacyConfig/output.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n"]}
@@ -1,17 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var source_exports = {};
15
- module.exports = __toCommonJS(source_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
16
5
 
17
6
  //# sourceMappingURL=source.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/source.ts"],"sourcesContent":["import type { AliasOption } from '../config';\n\nexport type SourceLegacyUserConfig = {\n alias?: AliasOption;\n envVars?: Array<string>;\n globalVars?: Record<string, string>;\n jsxTransformRuntime?: 'automatic' | 'classic';\n /**\n * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n designSystem?: Record<string, any>;\n};\n"]}
1
+ {"version":3,"mappings":";AACA,OAAO,eAAe,SAAS,cAAc;AAAA,EACzC,OAAO;AACX,CAAC;","names":[],"sources":["../../../src/types/legacyConfig/source.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n"]}
@@ -1,17 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var tools_exports = {};
15
- module.exports = __toCommonJS(tools_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
16
5
 
17
6
  //# sourceMappingURL=tools.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/tools.ts"],"sourcesContent":["import type { JestConfig } from '@modern-js/core';\nimport type { AcceptedPlugin as PostCSSPlugin } from 'postcss';\nimport type { LessConfig, SassConfig } from '../config';\n\nexport type PostCSSOptions = {\n to?: string;\n from?: string;\n map?: any;\n syntax?: any;\n parser?: any;\n plugins?: PostCSSPlugin[];\n stringifier?: any;\n};\n\nexport type PostCSSLoaderOptions = {\n /**\n * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.\n */\n execute?: boolean;\n /**\n * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.\n */\n sourceMap?: boolean;\n /**\n * The special implementation option determines which implementation of PostCSS to use.\n */\n implementation?: unknown;\n /**\n * Allows to set PostCSS options and plugins.\n */\n postcssOptions?: PostCSSOptions;\n};\n\nexport type PostCSSConfigUtils = {\n addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;\n};\n\ninterface ToolsConfig {\n speedy?: any | ((config: any) => any);\n}\n\nexport type PostCSSFunction = (\n options: PostCSSLoaderOptions,\n utils: PostCSSConfigUtils,\n) => PostCSSLoaderOptions | void;\n\nexport type ToolsLegacyUserConfig = {\n babel?: any;\n less?: LessConfig;\n lodash?: any;\n postcss?: PostCSSLoaderOptions | PostCSSFunction;\n sass?: SassConfig;\n speedy?: ToolsConfig['speedy'] | Array<NonNullable<ToolsConfig['speedy']>>;\n /**\n * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n tailwindcss?:\n | Record<string, any>\n | ((options: Record<string, any>) => Record<string, any> | void);\n jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);\n};\n"]}
1
+ {"version":3,"mappings":";AACA,OAAO,eAAe,SAAS,cAAc;AAAA,EACzC,OAAO;AACX,CAAC;","names":[],"sources":["../../../src/types/legacyConfig/tools.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n"]}
@@ -1,17 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var utils_exports = {};
15
- module.exports = __toCommonJS(utils_exports);
16
-
17
- //# sourceMappingURL=utils.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1,8 +1,26 @@
1
- import type { BaseBuildConfig } from '../types/config';
1
+ import type { BaseBuildConfig, ExternalHelpers, BuildType, Format, Target } from '../types/config';
2
2
  export declare const getFinalExternals: (config: BaseBuildConfig, options: {
3
3
  appDirectory: string;
4
4
  }) => Promise<(string | RegExp)[]>;
5
5
  export declare const getAllDeps: <T>(appDirectory: string, options?: {
6
6
  dependencies?: boolean;
7
+ devDependencies?: boolean;
7
8
  peerDependencies?: boolean;
8
- }) => Promise<string[]>;
9
+ }) => Promise<string[]>;
10
+ export declare const checkSwcHelpers: (options: {
11
+ appDirectory: string;
12
+ externalHelpers: ExternalHelpers;
13
+ }) => Promise<void>;
14
+ export declare const matchSwcTransformCondition: (condtionOptions: {
15
+ sourceType: 'commonjs' | 'module';
16
+ buildType: BuildType;
17
+ format: Format;
18
+ disableSwcTransform?: boolean;
19
+ }) => boolean;
20
+ export declare const matchEs5PluginCondition: (condtionOptions: {
21
+ sourceType: 'commonjs' | 'module';
22
+ buildType: BuildType;
23
+ format: Format;
24
+ target: Target;
25
+ disableSwcTransform?: boolean;
26
+ }) => boolean;
@@ -1,66 +1,33 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
- var builder_exports = {};
49
- __export(builder_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ getFinalExternals: () => getFinalExternals,
50
14
  getAllDeps: () => getAllDeps,
51
- getFinalExternals: () => getFinalExternals
15
+ checkSwcHelpers: () => checkSwcHelpers,
16
+ matchSwcTransformCondition: () => matchSwcTransformCondition,
17
+ matchEs5PluginCondition: () => matchEs5PluginCondition
52
18
  });
53
- module.exports = __toCommonJS(builder_exports);
54
- var import_path = __toESM(require("path"));
55
- var import_logger = require("@modern-js/utils/logger");
56
- const getFinalExternals = (config, options) => __async(void 0, null, function* () {
19
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
20
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
21
+ const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
+ const _logger = require("@modern-js/utils/logger");
23
+ const getFinalExternals = async (config, options) => {
57
24
  const { autoExternal, externals } = config;
58
25
  const { appDirectory } = options;
59
26
  if (typeof autoExternal === "boolean") {
60
27
  if (!autoExternal) {
61
28
  return externals || [];
62
29
  }
63
- const deps2 = yield getAllDeps(appDirectory, {
30
+ const deps2 = await getAllDeps(appDirectory, {
64
31
  dependencies: true,
65
32
  peerDependencies: true
66
33
  });
@@ -69,18 +36,16 @@ const getFinalExternals = (config, options) => __async(void 0, null, function* (
69
36
  ...externals || []
70
37
  ];
71
38
  }
72
- const deps = yield getAllDeps(appDirectory, autoExternal);
39
+ const deps = await getAllDeps(appDirectory, autoExternal);
73
40
  return [
74
41
  ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
75
42
  ...externals || []
76
43
  ];
77
- });
78
- const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDirectory, options = {}) {
79
- const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
44
+ };
45
+ const getAllDeps = async (appDirectory, options = {}) => {
46
+ const { fs } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
80
47
  try {
81
- const json = JSON.parse(
82
- fs.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8")
83
- );
48
+ const json = JSON.parse(fs.readFileSync(_path.default.resolve(appDirectory, "./package.json"), "utf8"));
84
49
  let deps = [];
85
50
  if (options.dependencies) {
86
51
  deps = [
@@ -88,6 +53,12 @@ const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDir
88
53
  ...Object.keys(json.dependencies || {})
89
54
  ];
90
55
  }
56
+ if (options.devDependencies) {
57
+ deps = [
58
+ ...deps,
59
+ ...Object.keys(json.devDependencies || {})
60
+ ];
61
+ }
91
62
  if (options.peerDependencies) {
92
63
  deps = [
93
64
  ...deps,
@@ -96,14 +67,56 @@ const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDir
96
67
  }
97
68
  return deps;
98
69
  } catch (e) {
99
- import_logger.logger.warn("package.json is broken");
70
+ _logger.logger.warn("package.json is broken");
100
71
  return [];
101
72
  }
102
- });
103
- // Annotate the CommonJS export names for ESM import in node:
104
- 0 && (module.exports = {
105
- getAllDeps,
106
- getFinalExternals
107
- });
73
+ };
74
+ const checkSwcHelpers = async (options) => {
75
+ const { appDirectory, externalHelpers } = options;
76
+ if (externalHelpers === false) {
77
+ return;
78
+ }
79
+ const deps = await getAllDeps(appDirectory, {
80
+ dependencies: true,
81
+ devDependencies: true
82
+ });
83
+ const swcHelpersPkgName = "@swc/helpers";
84
+ if (!deps.includes(swcHelpersPkgName)) {
85
+ const local = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../locale")));
86
+ throw new Error(local.i18n.t(local.localeKeys.errors.externalHelpers));
87
+ }
88
+ };
89
+ const matchSwcTransformCondition = (condtionOptions) => {
90
+ const { sourceType, buildType, format, disableSwcTransform } = condtionOptions;
91
+ if (disableSwcTransform) {
92
+ return false;
93
+ }
94
+ if (sourceType === "commonjs") {
95
+ return false;
96
+ }
97
+ if (buildType === "bundleless") {
98
+ return true;
99
+ }
100
+ if (format === "esm" || format === "iife") {
101
+ return true;
102
+ }
103
+ return false;
104
+ };
105
+ const matchEs5PluginCondition = (condtionOptions) => {
106
+ const { sourceType, buildType, format, target, disableSwcTransform } = condtionOptions;
107
+ if (target !== "es5") {
108
+ return false;
109
+ }
110
+ if (disableSwcTransform) {
111
+ return true;
112
+ }
113
+ if (sourceType === "commonjs") {
114
+ return true;
115
+ }
116
+ if (buildType === "bundle" && format === "cjs") {
117
+ return true;
118
+ }
119
+ return false;
120
+ };
108
121
 
109
122
  //# sourceMappingURL=builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,oBAAuB;AAGhB,MAAM,oBAAoB,CAC/B,QACA,YACG;AACH,QAAM,EAAE,cAAc,UAAU,IAAI;AACpC,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,OAAO,iBAAiB,WAAW;AACrC,QAAI,CAAC,cAAc;AACjB,aAAO,aAAa,CAAC;AAAA,IACvB;AAEA,UAAMA,QAAO,MAAM,WAAW,cAAc;AAAA,MAC1C,cAAc;AAAA,MACd,kBAAkB;AAAA,IACpB,CAAC;AACD,WAAO;AAAA,MACL,GAAGA,MAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,MACpD,GAAI,aAAa,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,WAAW,cAAc,YAAY;AACxD,SAAO;AAAA,IACL,GAAG,KAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,IACpD,GAAI,aAAa,CAAC;AAAA,EACpB;AACF;AAEO,MAAM,aAAa,CACxB,OAKG,wBALH,IAKG,mBALH,cACA,UAGI,CAAC,GACF;AACH,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI;AACF,UAAM,OAAO,KAAK;AAAA,MAChB,GAAG,aAAa,oBAAK,QAAQ,cAAc,gBAAgB,GAAG,MAAM;AAAA,IACtE;AAEA,QAAI,OAAiB,CAAC;AAEtB,QAAI,QAAQ,cAAc;AACxB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,gBAAkC,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AAEA,QAAI,QAAQ,kBAAkB;AAC5B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,oBAAsC,CAAC,CAAC;AAAA,MAC/D;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,GAAP;AACA,yBAAO,KAAK,wBAAwB;AACpC,WAAO,CAAC;AAAA,EACV;AACF;;;;;;","names":["deps"],"sources":["../../src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type { BaseBuildConfig } 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 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.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"]}
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,52 +1,18 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __export = (target, all) => {
23
- for (var name in all)
24
- __defProp(target, name, { get: all[name], enumerable: true });
25
- };
26
- var __copyProps = (to, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from))
29
- if (!__hasOwnProp.call(to, key) && key !== except)
30
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
- }
32
- return to;
33
- };
34
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var common_exports = {};
36
- __export(common_exports, {
37
- transformUndefineObject: () => transformUndefineObject
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "transformUndefineObject", {
6
+ enumerable: true,
7
+ get: () => transformUndefineObject
38
8
  });
39
- module.exports = __toCommonJS(common_exports);
40
9
  const transformUndefineObject = (arr) => {
41
10
  return arr.reduce((o, key) => {
42
- return __spreadProps(__spreadValues({}, o), {
11
+ return {
12
+ ...o,
43
13
  [key]: void 0
44
- });
14
+ };
45
15
  }, {});
46
16
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- transformUndefineObject
50
- });
51
17
 
52
18
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,0BAA0B,CACrC,QAC8B;AAC9B,SAAO,IAAI,OAAO,CAAC,GAAG,QAAQ;AAC5B,WAAO,iCACF,IADE;AAAA,MAEL,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AACP;","names":[],"sources":["../../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"]}