@modern-js/module-tools 2.6.0 → 2.7.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 (50) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/builder/build.js +4 -4
  3. package/dist/builder/build.js.map +1 -1
  4. package/dist/builder/copy.d.ts +6 -1
  5. package/dist/builder/copy.js +51 -2
  6. package/dist/builder/copy.js.map +1 -1
  7. package/dist/config/{legacy-schema.js → legacySchema.js} +4 -4
  8. package/dist/config/legacySchema.js.map +1 -0
  9. package/dist/config/normalize.js +2 -2
  10. package/dist/config/normalize.js.map +1 -1
  11. package/dist/config/schema.d.ts +1 -1
  12. package/dist/config/schema.js +2 -2
  13. package/dist/config/schema.js.map +1 -1
  14. package/dist/config/{transform-legacy-config.js → transformLegacyConfig.js} +6 -6
  15. package/dist/config/transformLegacyConfig.js.map +1 -0
  16. package/dist/constants/{build-presets.js → buildPresets.js} +4 -4
  17. package/dist/constants/buildPresets.js.map +1 -0
  18. package/dist/constants/{legacy-build-presets.js → legacyBuildPresets.js} +4 -4
  19. package/dist/constants/legacyBuildPresets.js.map +1 -0
  20. package/dist/constants/log.d.ts +1 -0
  21. package/dist/constants/log.js +3 -0
  22. package/dist/constants/log.js.map +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/config/index.d.ts +1 -1
  27. package/dist/types/config/index.js.map +1 -1
  28. package/dist/utils/dts.js +1 -1
  29. package/dist/utils/dts.js.map +1 -1
  30. package/dist/utils/{libuild-plugins.js → libuildPlugins.js} +4 -4
  31. package/dist/utils/libuildPlugins.js.map +1 -0
  32. package/dist/utils/log.d.ts +1 -1
  33. package/dist/utils/log.js +2 -2
  34. package/dist/utils/log.js.map +1 -1
  35. package/dist/utils/{tspaths-transform.js → tspathsTransform.js} +4 -4
  36. package/dist/utils/tspathsTransform.js.map +1 -0
  37. package/package.json +16 -14
  38. package/scripts/debug-mode.js +49 -0
  39. package/dist/config/legacy-schema.js.map +0 -1
  40. package/dist/config/transform-legacy-config.js.map +0 -1
  41. package/dist/constants/build-presets.js.map +0 -1
  42. package/dist/constants/legacy-build-presets.js.map +0 -1
  43. package/dist/utils/libuild-plugins.js.map +0 -1
  44. package/dist/utils/tspaths-transform.js.map +0 -1
  45. /package/dist/config/{legacy-schema.d.ts → legacySchema.d.ts} +0 -0
  46. /package/dist/config/{transform-legacy-config.d.ts → transformLegacyConfig.d.ts} +0 -0
  47. /package/dist/constants/{build-presets.d.ts → buildPresets.d.ts} +0 -0
  48. /package/dist/constants/{legacy-build-presets.d.ts → legacyBuildPresets.d.ts} +0 -0
  49. /package/dist/utils/{libuild-plugins.d.ts → libuildPlugins.d.ts} +0 -0
  50. /package/dist/utils/{tspaths-transform.d.ts → tspathsTransform.d.ts} +0 -0
@@ -25,8 +25,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var legacy_build_presets_exports = {};
29
- __export(legacy_build_presets_exports, {
28
+ var legacyBuildPresets_exports = {};
29
+ __export(legacyBuildPresets_exports, {
30
30
  browserJsLitePreset: () => browserJsLitePreset,
31
31
  browserJsPreset: () => browserJsPreset,
32
32
  legacyPresets: () => legacyPresets,
@@ -34,7 +34,7 @@ __export(legacy_build_presets_exports, {
34
34
  universalJsLitePreset: () => universalJsLitePreset,
35
35
  universalJsPreset: () => universalJsPreset
36
36
  });
37
- module.exports = __toCommonJS(legacy_build_presets_exports);
37
+ module.exports = __toCommonJS(legacyBuildPresets_exports);
38
38
  var import_path = __toESM(require("path"));
39
39
  const legacyWithSourceCodeToCopyConfig = {
40
40
  patterns: [
@@ -204,4 +204,4 @@ const legacyPresets = {
204
204
  universalJsPreset
205
205
  });
206
206
 
207
- //# sourceMappingURL=legacy-build-presets.js.map
207
+ //# sourceM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KAAK,EAAE,MAAM,KAAK;AAAA,IAClB,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,gBAAgB;AAAA,EAC3B,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,SAAS;AACX;;;;;;;;;;","names":[],"sources":["../../src/constants/legacyBuildPresets.ts"],"sourcesContent":["import path from 'path';\nimport type { PartialBuildConfig } from '../types';\n\nconst legacyWithSourceCodeToCopyConfig = {\n patterns: [\n {\n from: path.join('src', '**/*.{less,sass,scss}'),\n context: 'src',\n },\n ],\n};\n\nexport const universalJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const universalJsLitePreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\nexport const browserJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const browserJsLitePreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n dts: false,\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const nodeJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n dts: false,\n outDir: './dist/js/node',\n copy: legacyWithSourceCodeToCopyConfig,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n dts: false,\n outDir: './dist/js/modern',\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const legacyPresets = {\n 'universal-js': universalJsPreset,\n UNIVERSAL_JS: universalJsPreset,\n 'universal-js-lite': universalJsLitePreset,\n UNIVERSAL_JS_LITE: universalJsLitePreset,\n 'browser-js': browserJsPreset,\n BROWSER_JS: browserJsPreset,\n 'browser-js-lite': browserJsLitePreset,\n BROWSER_JS_LITE: browserJsLitePreset,\n 'node-js': nodeJsPreset,\n NODE_JS: nodeJsPreset,\n};\n"]}
@@ -5,6 +5,7 @@ export declare enum SectionTitleStatus {
5
5
  }
6
6
  export declare const BundleDtsLogPrefix = "[Bundle:DTS]";
7
7
  export declare const BundlelessDtsLogPrefix = "[Bundleless:DTS]";
8
+ export declare const CopyLogPrefix = "[Copy]";
8
9
  export declare const buildSuccessText = "Build succeed";
9
10
  export declare const reportFile1LineText = "Bundle Files";
10
11
  export declare const reportFile2LineText = "Size";
@@ -19,6 +19,7 @@ var log_exports = {};
19
19
  __export(log_exports, {
20
20
  BundleDtsLogPrefix: () => BundleDtsLogPrefix,
21
21
  BundlelessDtsLogPrefix: () => BundlelessDtsLogPrefix,
22
+ CopyLogPrefix: () => CopyLogPrefix,
22
23
  SectionTitleStatus: () => SectionTitleStatus,
23
24
  buildSuccessText: () => buildSuccessText,
24
25
  reportFile1LineText: () => reportFile1LineText,
@@ -33,6 +34,7 @@ var SectionTitleStatus = /* @__PURE__ */ ((SectionTitleStatus2) => {
33
34
  })(SectionTitleStatus || {});
34
35
  const BundleDtsLogPrefix = "[Bundle:DTS]";
35
36
  const BundlelessDtsLogPrefix = "[Bundleless:DTS]";
37
+ const CopyLogPrefix = "[Copy]";
36
38
  const buildSuccessText = "Build succeed";
37
39
  const reportFile1LineText = "Bundle Files";
38
40
  const reportFile2LineText = "Size";
@@ -40,6 +42,7 @@ const reportFile2LineText = "Size";
40
42
  0 && (module.exports = {
41
43
  BundleDtsLogPrefix,
42
44
  BundlelessDtsLogPrefix,
45
+ CopyLogPrefix,
43
46
  SectionTitleStatus,
44
47
  buildSuccessText,
45
48
  reportFile1LineText,
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,qBAAL,kBAAKA,wBAAL;AACL;AACA;AACA;AAHU;AAAA;AAML,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AAEzB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;","names":["SectionTitleStatus"],"sources":["../../src/constants/log.ts"],"sourcesContent":["export enum SectionTitleStatus {\n Success,\n Fail,\n Log,\n}\n\nexport const BundleDtsLogPrefix = '[Bundle:DTS]';\nexport const BundlelessDtsLogPrefix = '[Bundleless:DTS]';\nexport const buildSuccessText = 'Build succeed';\n\nexport const reportFile1LineText = 'Bundle Files';\nexport const reportFile2LineText = 'Size';\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,qBAAL,kBAAKA,wBAAL;AACL;AACA;AACA;AAHU;AAAA;AAML,MAAM,qBAAqB;AAC3B,MAAM,yBAAyB;AAC/B,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AAEzB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;","names":["SectionTitleStatus"],"sources":["../../src/constants/log.ts"],"sourcesContent":["export enum SectionTitleStatus {\n Success,\n Fail,\n Log,\n}\n\nexport const BundleDtsLogPrefix = '[Bundle:DTS]';\nexport const BundlelessDtsLogPrefix = '[Bundleless:DTS]';\nexport const CopyLogPrefix = '[Copy]';\nexport const buildSuccessText = 'Build succeed';\n\nexport const reportFile1LineText = 'Bundle Files';\nexport const reportFile2LineText = 'Size';\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cli } from './cli';
2
2
  export { defineConfig, defineLegacyConfig } from './config/defineConfig';
3
- export { legacyPresets } from './constants/legacy-build-presets';
3
+ export { legacyPresets } from './constants/legacyBuildPresets';
4
4
  export * from './types';
5
5
  export default cli;
package/dist/index.js CHANGED
@@ -21,12 +21,12 @@ __export(src_exports, {
21
21
  default: () => src_default,
22
22
  defineConfig: () => import_defineConfig.defineConfig,
23
23
  defineLegacyConfig: () => import_defineConfig.defineLegacyConfig,
24
- legacyPresets: () => import_legacy_build_presets.legacyPresets
24
+ legacyPresets: () => import_legacyBuildPresets.legacyPresets
25
25
  });
26
26
  module.exports = __toCommonJS(src_exports);
27
27
  var import_cli = require("./cli");
28
28
  var import_defineConfig = require("./config/defineConfig");
29
- var import_legacy_build_presets = require("./constants/legacy-build-presets");
29
+ var import_legacyBuildPresets = require("./constants/legacyBuildPresets");
30
30
  __reExport(src_exports, require("./types"), module.exports);
31
31
  var src_default = import_cli.cli;
32
32
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AAEpB,0BAAiD;AACjD,kCAA8B;AAC9B,wBAAc,oBAJd;AAKA,IAAO,cAAQ;;;;;;;","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { cli } from './cli';\n\nexport { defineConfig, defineLegacyConfig } from './config/defineConfig';\nexport { legacyPresets } from './constants/legacy-build-presets';\nexport * from './types';\nexport default cli;\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AAEpB,0BAAiD;AACjD,gCAA8B;AAC9B,wBAAc,oBAJd;AAKA,IAAO,cAAQ;;;;;;;","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { cli } from './cli';\n\nexport { defineConfig, defineLegacyConfig } from './config/defineConfig';\nexport { legacyPresets } from './constants/legacyBuildPresets';\nexport * from './types';\nexport default cli;\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { UserConfig as LibuildUserConfig, Asset as LibuildAsset, Style as LibuildStyle } from '@modern-js/libuild';
2
2
  import type { Options } from '@modern-js/libuild-plugin-svgr';
3
3
  import type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';
4
- import { BuildInPreset, presetList } from '../../constants/build-presets';
4
+ import { BuildInPreset, presetList } from '../../constants/buildPresets';
5
5
  import type { CopyConfig } from '../copy';
6
6
  import type { LessConfig, SassConfig, PostCSSConfig, TailwindCSSConfig } from './style';
7
7
  export * from './style';
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';\nimport { BuildInPreset, presetList } from '../../constants/build-presets';\nimport type { CopyConfig } from '../copy';\nimport type {\n LessConfig,\n SassConfig,\n PostCSSConfig,\n TailwindCSSConfig,\n} from './style';\n\nexport * from './style';\n\nexport type BuildType = 'bundleless' | 'bundle';\n\nexport type Format = 'esm' | 'cjs' | 'umd' | 'iife';\n\nexport type Target =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n | 'es2021'\n | 'es2022'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\n\nexport type Input = Required<LibuildUserConfig>['input'];\n\nexport type DTSOptions = {\n distPath: string;\n tsconfigPath: string;\n only: boolean;\n};\nexport type DTS = false | Partial<DTSOptions>;\n\nexport interface Asset {\n path?: LibuildAsset['outdir'];\n limit?: LibuildAsset['limit'];\n publicPath?: LibuildAsset['publicPath'];\n svgr?: boolean | Options;\n}\nexport type SourceMap = Required<LibuildUserConfig>['sourceMap'];\nexport type AutoExternal =\n | boolean\n | {\n dependencies?: boolean;\n peerDependencies?: boolean;\n };\nexport type JSX = 'automatic' | 'transform';\n\nexport type AliasOption =\n | Record<string, string>\n | ((aliases: Record<string, string>) => Record<string, string> | void);\n\nexport type BaseBuildConfig = Omit<\n Required<PartialBaseBuildConfig>,\n 'dts' | 'style' | 'alias' | 'sideEffects'\n> & {\n sideEffects: LibuildUserConfig['sideEffects'];\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n metafile?: boolean;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n sideEffects?: LibuildUserConfig['sideEffects'];\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n extendPreset: (\n extendPresetName: keyof typeof BuildInPreset,\n extendBuildConfig: PartialBaseBuildConfig,\n ) => PartialBuildConfig;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\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?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';\nimport { BuildInPreset, presetList } from '../../constants/buildPresets';\nimport type { CopyConfig } from '../copy';\nimport type {\n LessConfig,\n SassConfig,\n PostCSSConfig,\n TailwindCSSConfig,\n} from './style';\n\nexport * from './style';\n\nexport type BuildType = 'bundleless' | 'bundle';\n\nexport type Format = 'esm' | 'cjs' | 'umd' | 'iife';\n\nexport type Target =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n | 'es2021'\n | 'es2022'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\n\nexport type Input = Required<LibuildUserConfig>['input'];\n\nexport type DTSOptions = {\n distPath: string;\n tsconfigPath: string;\n only: boolean;\n};\nexport type DTS = false | Partial<DTSOptions>;\n\nexport interface Asset {\n path?: LibuildAsset['outdir'];\n limit?: LibuildAsset['limit'];\n publicPath?: LibuildAsset['publicPath'];\n svgr?: boolean | Options;\n}\nexport type SourceMap = Required<LibuildUserConfig>['sourceMap'];\nexport type AutoExternal =\n | boolean\n | {\n dependencies?: boolean;\n peerDependencies?: boolean;\n };\nexport type JSX = 'automatic' | 'transform';\n\nexport type AliasOption =\n | Record<string, string>\n | ((aliases: Record<string, string>) => Record<string, string> | void);\n\nexport type BaseBuildConfig = Omit<\n Required<PartialBaseBuildConfig>,\n 'dts' | 'style' | 'alias' | 'sideEffects'\n> & {\n sideEffects: LibuildUserConfig['sideEffects'];\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n metafile?: boolean;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n sideEffects?: LibuildUserConfig['sideEffects'];\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n extendPreset: (\n extendPresetName: keyof typeof BuildInPreset,\n extendBuildConfig: PartialBaseBuildConfig,\n ) => PartialBuildConfig;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\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?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
package/dist/utils/dts.js CHANGED
@@ -130,7 +130,7 @@ const resolveAlias = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], functio
130
130
  var _a, _b;
131
131
  const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;
132
132
  const { globby, fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
133
- const { transformDtsAlias } = yield Promise.resolve().then(() => __toESM(require("./tspaths-transform")));
133
+ const { transformDtsAlias } = yield Promise.resolve().then(() => __toESM(require("./tspathsTransform")));
134
134
  const { distAbsPath } = config;
135
135
  const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;
136
136
  const dtsFilenames = watchFilenames.length > 0 ? watchFilenames : globby.sync(dtsDistPath, { absolute: true });
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,oBAAoB,CAC/B,WACG;AACH,QAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAE5D,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAAA,EAChC;AACA,QAAM,oBAAoB,oBAAK;AAAA,IAC7B;AAAA,IACA,oBAAK,SA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QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,qBAAqB;AAChE,QAAM,EAAE,YAAY,IAAI;AACxB,QAAM,cAAc,GAAG;AACvB,QAAM,eACJ,eAAe,SAAS,IACpB,iBACA,OAAO,KAAK,aAAa,EAAE,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,kBAAkB;AAAA,IAC/B,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAO,wBAAa,oBAAb,mBAA8B,UAA9B,YAAuC,CAAC;AAAA,EACjD,CAAC;AACD,aAAW,KAAK,QAAQ;AACtB,OAAG,cAAc,EAAE,MAAM,EAAE,OAAO;AAAA,EACpC;AAEA,QAAM,GAAG,KAAK,oBAAoB,WAAW;AAC/C;AAgDO,MAAM,qBAAqB,CAChC,QACA,YACG;AAjKL;AAkKE,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO,kBAAkB;AAG/D,MACE,OAAO,QAAQ,aAAa,YAC5B,QAAQ,aAAa,qBACrB;AACA,WAAO,MAAM;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,QACN,YAAO,QAAP,YAAc,CAAC,IAHR;AAAA,MAIX,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // 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(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspaths-transform');\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 ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ts.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 // 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(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
@@ -45,12 +45,12 @@ var __async = (__this, __arguments, generator) => {
45
45
  step((generator = generator.apply(__this, __arguments)).next());
46
46
  });
47
47
  };
48
- var libuild_plugins_exports = {};
49
- __export(libuild_plugins_exports, {
48
+ var libuildPlugins_exports = {};
49
+ __export(libuildPlugins_exports, {
50
50
  externalPlugin: () => externalPlugin,
51
51
  watchPlugin: () => watchPlugin
52
52
  });
53
- module.exports = __toCommonJS(libuild_plugins_exports);
53
+ module.exports = __toCommonJS(libuildPlugins_exports);
54
54
  const watchPlugin = (api, config) => {
55
55
  return {
56
56
  name: "watch-plugin",
@@ -86,4 +86,4 @@ const externalPlugin = (config, options) => {
86
86
  watchPlugin
87
87
  });
88
88
 
89
- //# sourceMappingURL=libuild-plugins.js.map
89
+ //# sourceMappingURL=libuildPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
@@ -1,2 +1,2 @@
1
1
  import { SectionTitleStatus } from '../constants/log';
2
- export declare const watchSectionTitle: (str: string, status: SectionTitleStatus) => Promise<string>;
2
+ export declare const watchSectionTitle: (str: string, status: SectionTitleStatus, detailLog?: string) => Promise<string>;
package/dist/utils/log.js CHANGED
@@ -51,7 +51,7 @@ __export(log_exports, {
51
51
  });
52
52
  module.exports = __toCommonJS(log_exports);
53
53
  var import_log = require("../constants/log");
54
- const watchSectionTitle = (str, status) => __async(void 0, null, function* () {
54
+ const watchSectionTitle = (str, status, detailLog) => __async(void 0, null, function* () {
55
55
  const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
56
56
  if (status === import_log.SectionTitleStatus.Success) {
57
57
  return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(
@@ -62,7 +62,7 @@ const watchSectionTitle = (str, status) => __async(void 0, null, function* () {
62
62
  "Build Failed"
63
63
  )}`;
64
64
  }
65
- return `${chalk.bgWhite.gray.underline(str)} ${chalk.blue.underline("Log")}`;
65
+ return `${chalk.bgWhite.gray.underline(str)} ${detailLog ? detailLog : chalk.blue.underline("Log")}`;
66
66
  });
67
67
  // Annotate the CommonJS export names for ESM import in node:
68
68
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,WACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,KAAK,UAAU,KAAK;AAC3E;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.blue.underline('Log')}`;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KACxC,YAAY,YAAY,MAAM,KAAK,UAAU,KAAK;AAEtD;;;;;","names":[],"sources":["../../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.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${\n detailLog ? detailLog : chalk.blue.underline('Log')\n }`;\n};\n"]}
@@ -25,11 +25,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var tspaths_transform_exports = {};
29
- __export(tspaths_transform_exports, {
28
+ var tspathsTransform_exports = {};
29
+ __export(tspathsTransform_exports, {
30
30
  transformDtsAlias: () => transformDtsAlias
31
31
  });
32
- module.exports = __toCommonJS(tspaths_transform_exports);
32
+ module.exports = __toCommonJS(tspathsTransform_exports);
33
33
  var path = __toESM(require("path"));
34
34
  var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
35
35
  var import_utils = require("@modern-js/utils");
@@ -123,4 +123,4 @@ const transformDtsAlias = (option) => {
123
123
  transformDtsAlias
124
124
  });
125
125
 
126
- //# sourceMappingURL=tspaths-transform.js.map
126
+ //# sourceMappingURL=tspathsTransform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,4BAAgC;AAChC,mBAAmB;AACnB,aAAwB;AACxB,uBAAsB;AACtB,QAAmB;AACnB,sBAAmC;AACnC,kBAA6B;AAU7B,SAAS,cACP,UACA,EAAE,UAAU,SAAS,MAAM,GAC3B;AACA,MAAI,CAAC,EAAE,gBAAgB,QAAQ,GAAG;AAChC;AAAA,EACF;AAEA,QAAM,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,IACD,mBAAmB,gBAAgB;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACD,aAAO,0BAAU,GAAG,EAAE;AACxB;AAOO,MAAM,oBAAoB,CAAC,WAAoC;AACpE,QAAM,EAAE,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI;AAC3C,QAAM,kBAAuD,CAAC;AAC9D,aAAW,YAAY,WAAW;AAChC,oBAAgB,KAAK;AAAA,MACnB,MAAM;AAAA,MACN,SAAS,yBAAyB,EAAE,UAAU,SAAS,MAAM,CAAC;AAAA,IAChE,CAAC;AAAA,EACH;AACA,SAAO;AACT;;;;;","names":[],"sources":["../../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"]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "module-tools",
12
12
  "lib-tools"
13
13
  ],
14
- "version": "2.6.0",
14
+ "version": "2.7.0",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js",
17
17
  "modern-module": "./bin/modern.js"
@@ -39,19 +39,20 @@
39
39
  "@modern-js/libuild": "~0.11.0",
40
40
  "@modern-js/libuild-plugin-svgr": "~0.11.0",
41
41
  "@modern-js/libuild-plugin-swc": "~0.11.0",
42
- "@modern-js/core": "2.6.0",
43
- "@modern-js/new-action": "2.6.0",
44
- "@modern-js/plugin": "2.6.0",
45
- "@modern-js/plugin-changeset": "2.6.0",
46
- "@modern-js/plugin-i18n": "2.6.0",
47
- "@modern-js/plugin-lint": "2.6.0",
48
- "@modern-js/upgrade": "2.6.0",
49
- "@modern-js/utils": "2.6.0"
42
+ "@modern-js/core": "2.7.0",
43
+ "@modern-js/new-action": "2.7.0",
44
+ "@modern-js/plugin": "2.7.0",
45
+ "@modern-js/plugin-changeset": "2.7.0",
46
+ "@modern-js/plugin-i18n": "2.7.0",
47
+ "@modern-js/plugin-lint": "2.7.0",
48
+ "@modern-js/upgrade": "2.7.0",
49
+ "@modern-js/utils": "2.7.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/fs-extra": "9.0.13",
53
53
  "@types/jest": "^27",
54
54
  "@types/node": "^14",
55
+ "detect-indent": "6.1.0",
55
56
  "fs-extra": "10.1.0",
56
57
  "jest": "^27",
57
58
  "path-browserify": "1.0.1",
@@ -59,10 +60,10 @@
59
60
  "postcss-alias": "2.0.0",
60
61
  "react": "17",
61
62
  "typescript": "^4",
62
- "@modern-js/builder-webpack-provider": "2.6.0",
63
- "@modern-js/self": "npm:@modern-js/module-tools@2.6.0",
64
- "@scripts/build": "2.6.0",
65
- "@scripts/jest-config": "2.6.0"
63
+ "@modern-js/builder-webpack-provider": "2.7.0",
64
+ "@modern-js/self": "npm:@modern-js/module-tools@2.7.0",
65
+ "@scripts/jest-config": "2.7.0",
66
+ "@scripts/build": "2.7.0"
66
67
  },
67
68
  "publishConfig": {
68
69
  "registry": "https://registry.npmjs.org/",
@@ -81,6 +82,7 @@
81
82
  "dev": "modern-lib build --watch",
82
83
  "test": "jest",
83
84
  "test:update": "jest --updateSnapshot",
84
- "new": "modern-lib new"
85
+ "new": "modern-lib new",
86
+ "debug-mode": "node ./scripts/debug-mode.js"
85
87
  }
86
88
  }
@@ -0,0 +1,49 @@
1
+ /* eslint-disable no-console */
2
+ /**
3
+ * 修改 exports.* 配置
4
+ * 将 export.'.': './src/index.ts' 转换为 export.'.': './dist/index.js'
5
+ * 当作为 demo 项目调试的时候使用: pnpm debug-mode
6
+ * 关闭调试模式:pnpm debug-mode off
7
+ */
8
+ const path = require('path');
9
+ const { fs } = require('@modern-js/utils');
10
+ const detectIndent = require('detect-indent');
11
+
12
+ const ON = 'on';
13
+ const OFF = 'off';
14
+ const operation = process.argv[2] === OFF ? OFF : ON;
15
+
16
+ const appDir = path.join(__dirname, '..');
17
+ const pkgPath = path.join(appDir, './package.json');
18
+ const tempPkgPath = path.join(appDir, 'temp-package.json');
19
+
20
+ if (operation === ON) {
21
+ if (!fs.pathExistsSync(tempPkgPath)) {
22
+ fs.copyFileSync(pkgPath, tempPkgPath);
23
+ }
24
+ } else {
25
+ fs.copyFileSync(tempPkgPath, pkgPath);
26
+ fs.removeSync(tempPkgPath);
27
+ }
28
+
29
+ const pkgJson = require(pkgPath);
30
+ const originalExports = {
31
+ '.': './src/index.ts',
32
+ './defineConfig': './src/config/defineConfig.ts',
33
+ };
34
+ const debugExports = {
35
+ '.': './dist/index.js',
36
+ './defineConfig': './dist/config/defineConfig.js',
37
+ };
38
+
39
+ console.debug('operation is', operation);
40
+ if (operation === ON) {
41
+ pkgJson.exports = debugExports;
42
+ } else {
43
+ pkgJson.exports = originalExports;
44
+ }
45
+
46
+ const output = fs.readFileSync(pkgPath, 'utf-8');
47
+ const indent = detectIndent(output);
48
+ fs.writeJSONSync(pkgPath, pkgJson, { spaces: indent.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AM,eAAe;AAAA;AAAA,EAE1B;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ,EAAE,MAAM,kBAAkB;AAAA,EACpC;AAAA;AAAA,EAEA;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ,EAAE,QAAQ,SAAS;AAAA,EAC7B;AAAA;AAAA,EAEA;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ,EAAE,QAAQ,UAAU;AAAA,EAC9B;AAAA;AAAA,EAEA;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,MAAM,CAAC,iBAAiB,aAAa;AAAA,IACvC;AAAA,EACF;AAAA;AAAA,EAEA;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,GAAG;AACL;AAEO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ;AAAA;AAAA,MAEN,MAAM,CAAC,WAAW,WAAW;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,MAAM,cAAc;AAAA,EACzB;AAAA,IACE,QAAQ;AAAA,IACR,QAAQ;AAAA,MACN,QAAQ,CAAC,UAAU,UAAU;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAAC,GAAG,cAAc,GAAG,cAAc,GAAG,WAAW;","names":[],"sources":["../../src/config/legacy-schema.ts"],"sourcesContent":["export const targets = [\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',\n];\n\nexport const presets = [\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ...[\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ].reduce<string[]>((ret, crt) => {\n return [...ret, ...targets.map(t => `${crt}-${t}`)];\n }, []),\n];\n\nconst properties = {\n target: {\n enum: targets,\n },\n format: {\n enum: ['cjs', 'esm', 'umd'],\n },\n sourceMap: {\n enum: [true, false, 'inline', 'external'],\n },\n buildType: {\n enum: ['bundle', 'bundleless'],\n },\n bundleOptions: {\n type: 'object',\n properties: {\n getModuleId: {\n instanceof: 'Function',\n },\n entry: {\n type: 'object',\n },\n splitting: {\n type: 'boolean',\n },\n externals: {\n type: 'array',\n items: {\n anyOf: [\n {\n instanceof: 'RegExp',\n },\n {\n typeof: 'string',\n },\n ],\n },\n },\n platform: {\n enum: ['node', 'browser'],\n },\n minify: {\n enum: ['esbuild', 'terser', false],\n },\n skipDeps: {\n type: 'boolean',\n },\n },\n },\n bundlelessOptions: {\n type: 'object',\n properties: {\n sourceDir: {\n type: 'string',\n },\n style: {\n type: 'object',\n properties: {\n compileMode: {\n enum: ['all', 'only-compiled-code', 'only-source-code', false],\n },\n path: { type: 'string' },\n },\n },\n static: {\n type: 'object',\n properties: {\n path: { type: 'string' },\n },\n },\n },\n },\n\n tsconfig: {\n type: 'string',\n },\n enableDts: {\n type: 'boolean',\n },\n dtsOnly: {\n type: 'boolean',\n },\n\n outputPath: { type: 'string' },\n};\n\nexport const buildSchema = [\n {\n target: 'output.buildConfig',\n schema: {\n if: {\n type: 'array',\n },\n then: {\n items: [{ type: 'object', properties, additionalProperties: false }],\n },\n else: { type: 'object', properties, additionalProperties: false },\n },\n },\n {\n target: 'output.buildPreset',\n schema: {\n enum: presets,\n },\n },\n];\n\nconst PACKAGE_MODE_LIST = [\n 'universal-js',\n 'universal-js-lite',\n 'browser-js',\n 'browser-js-lite',\n 'node-js',\n];\n\nexport const outputSchema = [\n /** packageMode will deprecated */\n {\n target: 'output.packageMode',\n schema: { enum: PACKAGE_MODE_LIST },\n },\n /** packageFields will deprecated */\n {\n target: 'output.packageFields',\n schema: { typeof: 'object' },\n },\n /** enableSourceMap will deprecated */\n {\n target: 'output.enableSourceMap',\n schema: { typeof: 'boolean' },\n },\n /** importStyle will deprecated */\n {\n target: 'output.importStyle',\n schema: {\n enum: ['compiled-code', 'source-code'],\n },\n },\n /** assetsPath will deprecated */\n {\n target: 'output.assetsPath',\n schema: {\n typeof: 'string',\n default: 'styles',\n },\n },\n ...buildSchema,\n];\n\nexport const sourceSchema = [\n {\n target: 'source.jsxTransformRuntime',\n schema: {\n // https://babeljs.io/docs/en/babel-preset-react#runtime\n enum: ['classic', 'automatic'],\n },\n },\n];\n\nexport const toolsSchema = [\n {\n target: 'tools.speedy',\n schema: {\n typeof: ['object', 'function'],\n },\n },\n];\n\nexport const legacySchema = [...sourceSchema, ...outputSchema, ...toolsSchema];\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AAkBV,MAAM,8BAA8B,CACzC,aACA,qBACG;AAtBL;AAuBE,MAAI,CAAC,iBAAiB,OAAO;AAC3B;AAAA,EACF;AACA,QAAM,cAAc,iBAAiB;AACrC,cAAY,QAAQ,kCACd,iBAAY,UAAZ,YAAqB,CAAC,IADR;AAAA,IAElB,OAAM,iBAAY,SAAZ,YAAoB,CAAC;AAAA,IAC3B,OAAM,iBAAY,SAAZ,YAAoB,CAAC;AAAA,IAC3B,cAAa,iBAAY,gBAAZ,YAA2B,CAAC;AAAA,EAC3C;AAEA,MAAI,YAAY,SAAS;AACvB,gBAAY,MAAM,UAChB,OAAO,YAAY,YAAY,aAC3B,CAAC,MAAM,UAAU;AArC3B;AAsCY,YAAM,aAAmC;AAAA,QACvC,gBAAgB;AAAA,UACd,SAAS,KAAK;AAAA,QAChB;AAAA,MACF;AACA,MAAC,YAAY,QAA4B,YAAY,KAAK;AAC1D,WAAK,WAAUA,iBAAW,mBAAX,oBAA2B;AAC1C,WAAK,iBAAiB,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],"sourcesContent":["/* eslint-disable max-lines */\nimport path from 'path';\nimport type {\n ModuleUserConfig,\n ModuleToolsLegacyUserConfig,\n PartialBaseBuildConfig,\n} from '../types';\nimport type { LegacyBaseBuildConfig } from '../types/legacyConfig/output';\nimport {\n PostCSSFunction,\n PostCSSLoaderOptions,\n} from '../types/legacyConfig/tools';\n\n/**\n * transform `tools` to buildConfig\n * include tools.less/sass/postcss/tailwindcss\n * @param buildConfig PartialBaseBuildConfig\n * @param legacyUserConfig Readonly<ModuleToolsLegacyUserConfig>\n */\nexport const transformToolsToBuildConfig = (\n buildConfig: PartialBaseBuildConfig,\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n) => {\n if (!legacyUserConfig.tools) {\n return;\n }\n const legacyTools = legacyUserConfig.tools;\n buildConfig.style = {\n ...(buildConfig.style ?? {}),\n less: legacyTools.less ?? {},\n sass: legacyTools.sass ?? {},\n tailwindcss: legacyTools.tailwindcss ?? {},\n };\n\n if (legacyTools.postcss) {\n buildConfig.style.postcss =\n typeof legacyTools.postcss === 'function'\n ? (opts, utils) => {\n const legacyOpts: PostCSSLoaderOptions = {\n postcssOptions: {\n plugins: opts.plugins,\n },\n };\n (legacyTools.postcss as PostCSSFunction)(legacyOpts, utils);\n opts.plugins = legacyOpts.postcssOptions?.plugins;\n opts.processOptions = legacyOpts.postcssOptions;\n }\n : {\n plugins: legacyTools.postcss.postcssOptions?.plugins,\n processOptions: legacyTools.postcss.postcssOptions,\n };\n }\n};\n\n/**\n * transform `source` to buildConfig\n *\n * @param buildConfig PartialBaseBuildConfig\n * @param legacyUserConfig Readonly<ModuleToolsLegacyUserConfig>\n *\n * NB: ignore source.designSystem in this function\n */\nexport const transformSourceToBuildConfig = (\n buildConfig: PartialBaseBuildConfig,\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n) => {\n if (!legacyUserConfig.source) {\n return;\n }\n const legacySource = legacyUserConfig.source;\n\n buildConfig.alias = legacySource.alias ?? {};\n\n buildConfig.define = {};\n legacySource.envVars?.forEach(envVar => {\n buildConfig.define![`process.env.${envVar}`] = process.env[\n envVar\n ] as string;\n });\n buildConfig.define = {\n ...buildConfig.define,\n ...legacySource.globalVars,\n };\n\n buildConfig.jsx =\n legacySource.jsxTransformRuntime === 'classic' ? 'transform' : 'automatic';\n};\n\nexport const transformOutputToBuildConfig = (\n buildConfig: PartialBaseBuildConfig,\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n) => {\n if (legacyUserConfig.output?.disableTsChecker) {\n buildConfig.dts = false;\n }\n\n if (legacyUserConfig.output?.disableSourceMap) {\n buildConfig.sourceMap = false;\n }\n};\n\nexport const commonTransformAndLog = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n) => {\n const { logger } = await import('@modern-js/utils');\n const finalConfig: ModuleUserConfig = {};\n // source.designSystem\n finalConfig.designSystem = legacyUserConfig.source?.designSystem;\n\n if (legacyUserConfig.tools) {\n const legacyTools = legacyUserConfig.tools;\n if (legacyTools.babel) {\n logger.warn(\n '`tools.babel` is not support in legacy mode. Please check migrate documentation.',\n );\n }\n\n if (legacyTools.lodash) {\n logger.warn(\n '`tools.lodash` is not support in legacy mode. Please check migrate documentation.',\n );\n }\n\n if (legacyTools.jest) {\n finalConfig.testing = {\n jest: legacyTools.jest,\n };\n }\n }\n\n if (legacyUserConfig.output?.importStyle) {\n logger.warn(\n '`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled',\n );\n }\n\n if (legacyUserConfig.output?.jsPath) {\n logger.warn('`output.jsPath` is not support in legacy mode.');\n }\n\n return finalConfig;\n};\n\nexport const createConfigByBuildConfig = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const { logger } = await import('@modern-js/utils');\n const legacyBuildConfig = legacyUserConfig.output!.buildConfig!;\n\n const createBuildConfig = (config: LegacyBaseBuildConfig) => {\n const newConfig: PartialBaseBuildConfig = {};\n\n transformSourceToBuildConfig(newConfig, legacyUserConfig);\n\n // [legacy config: output] start\n const legacyPath = legacyUserConfig.output?.path ?? 'dist';\n newConfig.outDir = path.join(legacyPath, config.outputPath ?? './');\n\n // `bundlelessOptions.static.path` is a higher priority than `output?.assetsPath`\n newConfig.asset = {\n path: legacyUserConfig.output?.assetsPath,\n };\n\n // `buildConfig.sourceMap` is a higher priority than `output?.disableSourceMap`\n newConfig.sourceMap = !legacyUserConfig.output?.disableSourceMap;\n newConfig.sourceMap = config.sourceMap ?? config.buildType === 'bundle';\n\n newConfig.buildType = config.buildType ?? 'bundleless';\n newConfig.format = config.format ?? 'cjs';\n newConfig.target = config.target ?? 'esnext';\n\n newConfig.dts = legacyUserConfig.output?.disableTsChecker ? false : {};\n if (config.dtsOnly) {\n newConfig.dts = {\n ...(typeof newConfig.dts === 'object' ? newConfig.dts : {}),\n only: true,\n };\n }\n if (config.tsconfig) {\n newConfig.dts = {\n ...(typeof newConfig.dts === 'object' ? newConfig.dts : {}),\n tsconfigPath: config.tsconfig,\n };\n }\n // check enableDts must be last\n if (!config.enableDts) {\n newConfig.dts = false;\n }\n\n if (config.bundleOptions) {\n const { bundleOptions } = config;\n if (bundleOptions.entry) {\n newConfig.input = config.bundleOptions.entry;\n }\n\n newConfig.splitting = bundleOptions.splitting ?? false;\n newConfig.platform = bundleOptions.platform ?? 'node';\n newConfig.minify = bundleOptions.minify ?? false;\n newConfig.externals = bundleOptions.externals ?? [];\n newConfig.autoExternal = bundleOptions.skipDeps ?? true;\n }\n\n if (config.bundlelessOptions) {\n const { bundlelessOptions } = config;\n newConfig.sourceDir = bundlelessOptions.sourceDir ?? './src';\n\n if (bundlelessOptions.style) {\n logger.warn(\n 'bundlelessOptions.style is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled.',\n );\n }\n\n // look the notes about `output?.assetsPath` above\n if (bundlelessOptions.static?.path) {\n newConfig.asset = {\n path: bundlelessOptions.static?.path,\n };\n }\n }\n\n if (legacyUserConfig.output?.importStyle) {\n logger.warn(\n '`output.importStyle` is not support in legacy mode. Please check migrate documentation. By default, the style will be compiled',\n );\n }\n\n if (legacyUserConfig.output?.jsPath) {\n logger.warn('`output.jsPath` is not support in legacy mode.');\n }\n // [legacy config: output] end\n\n if (legacyUserConfig.tools) {\n transformToolsToBuildConfig(newConfig, legacyUserConfig);\n }\n\n return newConfig;\n };\n\n const finalConfig: ModuleUserConfig = {};\n if (Array.isArray(legacyBuildConfig)) {\n finalConfig.buildConfig = legacyBuildConfig.map(config =>\n createBuildConfig(config),\n );\n } else {\n finalConfig.buildConfig = [createBuildConfig(legacyBuildConfig)];\n }\n\n // source.designSystem\n finalConfig.designSystem = legacyUserConfig.source?.designSystem;\n\n // output.copy\n if (legacyUserConfig.output?.copy) {\n finalConfig.buildConfig.push({\n copy: {\n patterns: legacyUserConfig.output.copy,\n },\n });\n }\n\n if (legacyUserConfig.tools) {\n const legacyTools = legacyUserConfig.tools;\n if (legacyTools.babel) {\n logger.warn(\n '`tools.babel` is not support in legacy mode. Please check migrate documentation.',\n );\n }\n\n if (legacyTools.lodash) {\n logger.warn(\n '`tools.lodash` is not support in legacy mode. Please check migrate documentation.',\n );\n }\n\n if (legacyTools.jest) {\n finalConfig.testing = {\n jest: legacyTools.jest,\n };\n }\n }\n\n return finalConfig;\n};\n\nexport const createConfigByBuildPreset = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const legacyBuildPreset = legacyUserConfig.output?.buildPreset;\n const finalConfig = await commonTransformAndLog(legacyUserConfig);\n\n return {\n ...finalConfig,\n buildPreset({ preset }) {\n const buildConfigs = preset[legacyBuildPreset ?? 'npm-library'];\n buildConfigs.forEach(buildConfig => {\n transformSourceToBuildConfig(buildConfig, legacyUserConfig);\n transformToolsToBuildConfig(buildConfig, legacyUserConfig);\n transformOutputToBuildConfig(buildConfig, legacyUserConfig);\n });\n // output.copy\n if (legacyUserConfig.output?.copy) {\n buildConfigs.push({\n copy: {\n patterns: legacyUserConfig.output.copy,\n },\n });\n }\n return buildConfigs;\n },\n };\n};\n\nexport const createConfigByPackageFields = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const finalConfig = await commonTransformAndLog(legacyUserConfig);\n\n const output = legacyUserConfig.output!;\n const packageFields = output.packageFields!;\n const buildConfigs: PartialBaseBuildConfig[] = [];\n\n const packageFieldsKeys = Object.keys(packageFields) as (\n | 'main'\n | 'jsnext:modern'\n | 'module'\n )[];\n\n for (const packageField of packageFieldsKeys) {\n const packageFieldValue = packageFields[packageField];\n let buildConfig: PartialBaseBuildConfig = {};\n let outDir;\n if (packageField === 'main') {\n outDir = `./${output.path ?? 'dist'}/js/node`;\n } else if (packageField === 'module') {\n outDir = `./${output.path ?? 'dist'}/js/treeshaking`;\n } else {\n outDir = `./${output.path ?? 'dist'}/js/modern`;\n }\n\n if (packageFieldValue === 'CJS+ES6') {\n buildConfig = {\n format: 'cjs',\n target: 'es6',\n outDir,\n };\n } else if (packageFieldValue === 'ESM+ES5') {\n buildConfig = {\n format: 'esm',\n target: 'es5',\n outDir,\n };\n } else if (packageFieldValue === 'ESM+ES6') {\n buildConfig = {\n format: 'esm',\n target: 'es6',\n outDir,\n };\n }\n\n transformSourceToBuildConfig(buildConfig, legacyUserConfig);\n transformToolsToBuildConfig(buildConfig, legacyUserConfig);\n transformOutputToBuildConfig(buildConfig, legacyUserConfig);\n\n buildConfigs.push(buildConfig);\n }\n\n buildConfigs.push({\n buildType: 'bundleless',\n outDir: './dist/types',\n dts: {\n only: true,\n },\n });\n\n // output.copy\n if (legacyUserConfig.output?.copy) {\n buildConfigs.push({\n copy: {\n patterns: legacyUserConfig.output.copy,\n },\n });\n }\n\n return {\n ...finalConfig,\n buildConfig: buildConfigs,\n };\n};\n\nexport const createConfigByPackageMode = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const finalConfig = await commonTransformAndLog(legacyUserConfig);\n\n const { legacyPresets } = await import('../constants/legacy-build-presets');\n const packageMode = legacyUserConfig.output!.packageMode!;\n const buildConfigs = legacyPresets[packageMode];\n\n for (const buildConfig of buildConfigs) {\n transformSourceToBuildConfig(buildConfig, legacyUserConfig);\n transformToolsToBuildConfig(buildConfig, legacyUserConfig);\n transformOutputToBuildConfig(buildConfig, legacyUserConfig);\n // NB: not process output.path\n }\n\n // output.copy\n if (legacyUserConfig.output?.copy) {\n buildConfigs.push({\n copy: {\n patterns: legacyUserConfig.output.copy,\n },\n });\n }\n return {\n ...finalConfig,\n buildConfig: buildConfigs,\n };\n};\n\nexport const createConfigByDefault = async (\n legacyUserConfig: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const finalConfig = await commonTransformAndLog(legacyUserConfig);\n\n const { legacyPresets } = await import('../constants/legacy-build-presets');\n const buildConfigs = legacyPresets['universal-js'];\n\n for (const buildConfig of buildConfigs) {\n transformSourceToBuildConfig(buildConfig, legacyUserConfig);\n transformToolsToBuildConfig(buildConfig, legacyUserConfig);\n transformOutputToBuildConfig(buildConfig, legacyUserConfig);\n // NB: not process output.path\n }\n\n // output.copy\n if (legacyUserConfig.output?.copy) {\n buildConfigs.push({\n copy: {\n patterns: legacyUserConfig.output.copy,\n },\n });\n }\n return {\n ...finalConfig,\n buildConfig: buildConfigs,\n };\n};\n\nexport const createUserConfigFromLegacy = async (\n config: Readonly<ModuleToolsLegacyUserConfig>,\n): Promise<ModuleUserConfig> => {\n const { buildConfig, buildPreset, packageFields, packageMode } =\n config.output ?? {};\n\n if (buildConfig) {\n return createConfigByBuildConfig(config);\n }\n\n if (buildPreset) {\n return createConfigByBuildPreset(config);\n }\n\n if (packageFields) {\n return createConfigByPackageFields(config);\n }\n\n if (packageMode) {\n return createConfigByPackageFields(config);\n }\n\n return createConfigByDefault(config);\n};\n\n/* eslint-enable max-lines */\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"mappings":";;;;;;;;;;;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,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,KAAK;AAAA,MACH,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,aAAa,0IACrB,gBACA,0BACA,mBACA,6BACA,kBACA,4BACA,qBACA,+BARqB;AAAA,EASxB,kBAAkB;AAAA,EAClB,uBAAuB;AACzB;AAEO,MAAM,gBAAgB;AAAA,EAC3B,aAAa;AAAA,EACb,eAAe;AAAA,EACf,aAAa;AAAA,EACb,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,kBAAkB;AAAA,EAClB,uBAAuB;AACzB;","names":[],"sources":["../../src/constants/build-presets.ts"],"sourcesContent":["import type {\n PartialBuildConfig,\n PartialBaseBuildConfig,\n Target,\n} from '../types';\n\nexport const targets: Target[] = [\n 'es5',\n 'es6',\n 'es2015',\n 'es2016',\n 'es2017',\n 'es2018',\n 'es2019',\n 'es2020',\n 'es2021',\n 'es2022',\n 'esnext',\n];\n\nexport const basePresetConfig: PartialBuildConfig = {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist',\n dts: { distPath: './types' },\n};\n\nexport const npmLibraryPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/es',\n dts: false,\n },\n {\n buildType: 'bundle',\n dts: { only: true, distPath: './types' },\n },\n];\nexport const npmLibraryWithUmdPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/es',\n dts: false,\n },\n {\n format: 'umd',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/umd',\n dts: false,\n },\n {\n buildType: 'bundle',\n dts: { only: true, distPath: './types' },\n },\n];\nexport const npmComponentPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/es',\n dts: false,\n },\n {\n buildType: 'bundleless',\n outDir: './dist/types',\n dts: { only: true },\n },\n];\nexport const npmComponentWithUmdPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/es',\n dts: false,\n },\n {\n format: 'umd',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/umd',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true, distPath: './types' },\n },\n];\n\nexport const libraryPreset = { 'npm-library': npmLibraryPresetConfig };\n\nexport const libraryPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-library-${target}`] = libraryPreset['npm-library'].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-library-${Target}`, PartialBuildConfig>);\n\nexport const libraryUmdPreset = {\n 'npm-library-with-umd': npmLibraryWithUmdPresetConfig,\n};\nexport const libraryUmdPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-library-with-umd-${target}`] = libraryUmdPreset[\n 'npm-library-with-umd'\n ].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-library-with-umd-${Target}`, PartialBuildConfig>);\n\nexport const componentPreset = {\n 'npm-component': npmComponentPresetConfig,\n};\nexport const componentPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-component-${target}`] = componentPreset['npm-component'].map(\n config => {\n return { ...config, target };\n },\n );\n return ret;\n}, {} as Record<`npm-component-${Target}`, PartialBuildConfig>);\n\nexport const componentUmdPreset = {\n 'npm-component-with-umd': npmComponentWithUmdPresetConfig,\n};\nexport const componentUmdPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-component-with-umd-${target}`] = componentUmdPreset[\n 'npm-component-with-umd'\n ].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-component-with-umd-${Target}`, PartialBuildConfig>);\n\nexport const nodeBuildConfig: PartialBaseBuildConfig[] = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es2019',\n dts: false,\n outDir: './dist/cjs',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es2019',\n dts: false,\n outDir: './dist/esm',\n },\n {\n buildType: 'bundleless',\n dts: {\n only: true,\n },\n outDir: './dist/types',\n },\n];\n\nexport const universalBuildConfig: PartialBaseBuildConfig[] = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es2019',\n dts: false,\n outDir: './dist/cjs',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n dts: false,\n outDir: './dist/esm',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es2019',\n dts: false,\n outDir: './dist/esm-node',\n },\n {\n buildType: 'bundleless',\n dts: {\n only: true,\n },\n outDir: './dist/types',\n },\n];\n\nexport const presetList = {\n ...libraryPreset,\n ...libraryPresetWithTarget,\n ...libraryUmdPreset,\n ...libraryUmdPresetWithTarget,\n ...componentPreset,\n ...componentPresetWithTarget,\n ...componentUmdPreset,\n ...componentUmdPresetWithTarget,\n 'modern-js-node': nodeBuildConfig,\n 'modern-js-universal': universalBuildConfig,\n};\n\nexport const BuildInPreset = {\n BASE_CONFIG: basePresetConfig,\n 'base-config': basePresetConfig,\n NPM_LIBRARY: npmLibraryPresetConfig,\n 'npm-library': npmLibraryPresetConfig,\n NPM_LIBRARY_WITH_UMD: npmLibraryWithUmdPresetConfig,\n 'npm-library-with-umd': npmLibraryWithUmdPresetConfig,\n NPM_COMPONENT: npmComponentPresetConfig,\n 'npm-component': npmComponentPresetConfig,\n NPM_COMPONENT_WITH_UMD: npmComponentWithUmdPresetConfig,\n 'npm-component-with-umd': npmComponentWithUmdPresetConfig,\n 'modern-js-node': nodeBuildConfig,\n 'modern-js-universal': universalBuildConfig,\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,MAAM,mCAAmC;AAAA,EACvC,UAAU;AAAA,IACR;AAAA,MACE,MAAM,oBAAK,KAAK,OAAO,uBAAuB;AAAA,MAC9C,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,MAAM,oBAAwC;AAAA,EACnD;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,KAAK,EAAE,MAAM,KAAK;AAAA,IAClB,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,wBAA4C;AAAA,EACvD;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,WAAW;AA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ACR,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,KAAK,EAAE,MAAM,KAAK;AAAA,IAClB,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,gBAAgB;AAAA,EAC3B,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,SAAS;AACX;;;;;;;;;;","names":[],"sources":["../../src/constants/legacy-build-presets.ts"],"sourcesContent":["import path from 'path';\nimport type { PartialBuildConfig } from '../types';\n\nconst legacyWithSourceCodeToCopyConfig = {\n patterns: [\n {\n from: path.join('src', '**/*.{less,sass,scss}'),\n context: 'src',\n },\n ],\n};\n\nexport const universalJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const universalJsLitePreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\nexport const browserJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const browserJsLitePreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n dts: false,\n outDir: './dist/js/treeshaking',\n copy: legacyWithSourceCodeToCopyConfig,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/node',\n dts: false,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n outDir: './dist/js/modern',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const nodeJsPreset: PartialBuildConfig = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es6',\n dts: false,\n outDir: './dist/js/node',\n copy: legacyWithSourceCodeToCopyConfig,\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es6',\n dts: false,\n outDir: './dist/js/modern',\n },\n {\n buildType: 'bundleless',\n dts: { only: true },\n outDir: './dist/types',\n },\n];\n\nexport const legacyPresets = {\n 'universal-js': universalJsPreset,\n UNIVERSAL_JS: universalJsPreset,\n 'universal-js-lite': universalJsLitePreset,\n UNIVERSAL_JS_LITE: universalJsLitePreset,\n 'browser-js': browserJsPreset,\n BROWSER_JS: browserJsPreset,\n 'browser-js-lite': browserJsLitePreset,\n BROWSER_JS_LITE: browserJsLitePreset,\n 'node-js': nodeJsPreset,\n NODE_JS: nodeJsPreset,\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuild-plugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,4BAAgC;AAChC,mBAAmB;AACnB,aAAwB;AACxB,uBAAsB;AACtB,QAAmB;AACnB,sBAAmC;AACnC,kBAA6B;AAU7B,SAAS,cACP,UACA,EAAE,UAAU,SAAS,MAAM,GAC3B;AACA,MAAI,CAAC,EAAE,gBAAgB,QAAQ,GAAG;AAChC;AAAA,EACF;AAEA,QAAM,aAAa,SAAS,KAAK;AACjC,QAAM,cAAc;AACpB,QAAM,gBAAY;AAAA,IAChB;AAAA,IACA;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AACA,QAAM,SAAS;AAAA,IACb;AAAA,IACA,qBAAmB;AACjB,UAAI,CAAC,gBAAG,WAAW,eAAe,GAAG;AACnC,eAAO;AAAA,MACT;AACA,aAAO,gBAAG,aAAa,eAAe;AAAA,IACxC;AAAA,IACA,cAAY,gBAAG,WAAW,QAAQ;AAAA,IAClC;AAAA,EACF;AACA,MAAI,QAAQ;AACV,UAAM,eAAe,KAAK;AAAA,MACxB,KAAK,QAAQ,WAAW;AAAA,MACxB,KAAK,QAAQ,MAAM;AAAA,IACrB;AAC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"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"]}