@modern-js/module-tools 2.0.0-beta.7 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - e27bbe4: update libuild version to support svgr in bundleless, and svgr only support default export
8
+ 更新 libuild 版本以支持 svgr 能在 bundleless 下工作,同时 svgr 只支持 default export
9
+ - @modern-js/new-action@2.0.2
10
+ - @modern-js/core@2.0.2
11
+ - @modern-js/utils@2.0.2
12
+ - @modern-js/plugin-changeset@2.0.2
13
+ - @modern-js/plugin-i18n@2.0.2
14
+ - @modern-js/plugin-lint@2.0.2
15
+ - @modern-js/plugin@2.0.2
16
+ - @modern-js/upgrade@2.0.2
17
+
18
+ ## 2.0.1
19
+
20
+ ### Patch Changes
21
+
22
+ - 00a2252: fix: module tools v2.0.0 bad version
23
+
24
+ fix: 修复 module tools v2.0.0 版本问题
25
+
26
+ - @modern-js/core@2.0.1
27
+ - @modern-js/plugin-changeset@2.0.1
28
+ - @modern-js/plugin-i18n@2.0.1
29
+ - @modern-js/plugin-lint@2.0.1
30
+ - @modern-js/new-action@2.0.1
31
+ - @modern-js/plugin@2.0.1
32
+ - @modern-js/upgrade@2.0.1
33
+ - @modern-js/utils@2.0.1
34
+
35
+ ## 2.0.0
36
+
37
+ ### Major Changes
38
+
39
+ - dda38c9c3e: chore: v2
40
+
41
+ ### Patch Changes
42
+
43
+ - d4a456659b: chore: rename plugin-jarvis to plugin-lint
44
+
45
+ chore: 重命名 plugin-jarvis 为 plugin-lint
46
+
47
+ - ffb2ed4: feat:
48
+
49
+ 1. change storybook runtime logic
50
+ 2. export runtime api define from runtime module
51
+ 3. refactor defineConfig in module-tools
52
+
53
+ feat:
54
+
55
+ 1. 更改 Storybook 对于 Runtime API 的处理逻辑
56
+ 2. 从 @modern-js/runtime 导出 Runtime API 的用户配置
57
+ 3. 重构 module-tools 的 defineConfig
58
+
59
+ - 824dc45: 默认关闭 svgr 功能
60
+ close svgr default
61
+ - efb69f9: fix tsconfig extends path calculation errors
62
+ 修复 tsconfig 里 extends 路径计算错误的问题
63
+ - Updated dependencies [c9e800d39a]
64
+ - Updated dependencies [edd1cfb1af]
65
+ - Updated dependencies [d4a456659b]
66
+ - Updated dependencies [f680410886]
67
+ - Updated dependencies [dda38c9c3e]
68
+ - Updated dependencies [8b8e1bb571]
69
+ - Updated dependencies [ffb2ed4]
70
+ - Updated dependencies [bbe4c4ab64]
71
+ - @modern-js/core@2.0.0
72
+ - @modern-js/utils@2.0.0
73
+ - @modern-js/plugin-lint@2.0.0
74
+ - @modern-js/plugin-changeset@2.0.0
75
+ - @modern-js/plugin-i18n@2.0.0
76
+ - @modern-js/new-action@2.0.0
77
+ - @modern-js/plugin@2.0.0
78
+ - @modern-js/upgrade@2.0.0
79
+
3
80
  ## 2.0.0-beta.7
4
81
 
5
82
  ### Major Changes
@@ -1,7 +1,7 @@
1
1
  import type { RollupWatcher } from '../../../compiled/rollup';
2
2
  import type { BaseBuildConfig, Input } from '../../types';
3
3
  export type { RollupWatcher };
4
- declare type Config = {
4
+ type Config = {
5
5
  distDir: string;
6
6
  tsconfigPath: string;
7
7
  externals: BaseBuildConfig['externals'];
@@ -55,7 +55,7 @@ const defaultBuildConfig = Object.freeze({
55
55
  path: "assets",
56
56
  limit: 14336,
57
57
  publicPath: "",
58
- svgr: true
58
+ svgr: false
59
59
  },
60
60
  style: {
61
61
  less: {},
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAGf,MAAM,eAAe,mBAAM,KAAK,aAAa;AAC7C,MAAM,mBAAmB,mBAAM,MAAM,eAAe;AACpD,MAAM,gBAAgB,mBAAM,IAAI,eAAe;AAE/C,MAAM,qBAAqB,OAAO,OAAwB;AAAA,EAC/D,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,EACR,KAAK,OAAO,OAAO;AAAA,IACjB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAAA,EACD,KAAK;AAAA,EACL,OAAO,CAAC,cAAc;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW,CAAC;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,YAAY,CAAC;AAAA,EACb,WAAW;AAAA,EACX,OAAO,CAAC;AAAA,EACR,eAAe,UAAQ;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA,IACP,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,EACZ;AACF,CAAC;;;;;;;;","names":[],"sources":["../../src/constants/build.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\nimport type { BaseBuildConfig } from '../types';\n\nexport const buildingText = chalk.blue('Building...');\nexport const buildSuccessText = chalk.green('Build succeed');\nexport const buildFailText = chalk.red('Build Failed:');\n\nexport const defaultBuildConfig = Object.freeze<BaseBuildConfig>({\n buildType: 'bundle',\n format: 'cjs',\n target: 'esnext',\n sourceMap: false,\n copy: {},\n outDir: './dist',\n dts: Object.freeze({\n only: false,\n distPath: './',\n tsconfigPath: './tsconfig.json',\n }),\n jsx: 'automatic',\n input: ['src/index.ts'],\n platform: 'node',\n splitting: false,\n externals: [],\n minify: false,\n autoExternal: true,\n umdGlobals: {},\n sourceDir: './src',\n alias: {},\n umdModuleName: name => name,\n define: {},\n asset: {\n path: 'assets',\n limit: 14336,\n publicPath: '',\n svgr: true,\n },\n style: {\n less: {},\n sass: {},\n postcss: {},\n tailwindCss: {},\n inject: false,\n autoModules: true,\n modules: {},\n },\n});\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAGf,MAAM,eAAe,mBAAM,KAAK,aAAa;AAC7C,MAAM,mBAAmB,mBAAM,MAAM,eAAe;AACpD,MAAM,gBAAgB,mBAAM,IAAI,eAAe;AAE/C,MAAM,qBAAqB,OAAO,OAAwB;AAAA,EAC/D,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,EACR,KAAK,OAAO,OAAO;AAAA,IACjB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAAA,EACD,KAAK;AAAA,EACL,OAAO,CAAC,cAAc;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW,CAAC;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,YAAY,CAAC;AAAA,EACb,WAAW;AAAA,EACX,OAAO,CAAC;AAAA,EACR,eAAe,UAAQ;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA,IACP,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,EACZ;AACF,CAAC;;;;;;;;","names":[],"sources":["../../src/constants/build.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\nimport type { BaseBuildConfig } from '../types';\n\nexport const buildingText = chalk.blue('Building...');\nexport const buildSuccessText = chalk.green('Build succeed');\nexport const buildFailText = chalk.red('Build Failed:');\n\nexport const defaultBuildConfig = Object.freeze<BaseBuildConfig>({\n buildType: 'bundle',\n format: 'cjs',\n target: 'esnext',\n sourceMap: false,\n copy: {},\n outDir: './dist',\n dts: Object.freeze({\n only: false,\n distPath: './',\n tsconfigPath: './tsconfig.json',\n }),\n jsx: 'automatic',\n input: ['src/index.ts'],\n platform: 'node',\n splitting: false,\n externals: [],\n minify: false,\n autoExternal: true,\n umdGlobals: {},\n sourceDir: './src',\n alias: {},\n umdModuleName: name => name,\n define: {},\n asset: {\n path: 'assets',\n limit: 14336,\n publicPath: '',\n svgr: false,\n },\n style: {\n less: {},\n sass: {},\n postcss: {},\n tailwindCss: {},\n inject: false,\n autoModules: true,\n modules: {},\n },\n});\n"]}
@@ -1 +1 @@
1
- export declare type RGB = [number, number, number];
1
+ export type RGB = [number, number, number];
@@ -1,41 +1,41 @@
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
- import type { DeepPartial } from '../utils';
3
+ import type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';
4
4
  import { BuildInPreset, presetList } from '../../constants/build-presets';
5
5
  import type { CopyConfig } from '../copy';
6
6
  import type { LessConfig, SassConfig, PostCSSConfig, TailwindCSSConfig } from './style';
7
7
  export * from './style';
8
- export declare type BuildType = 'bundleless' | 'bundle';
9
- export declare type Format = 'esm' | 'cjs' | 'umd' | 'iife';
10
- export declare type Target = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
11
- export declare type Input = Required<LibuildUserConfig>['input'];
12
- export declare type DTSOptions = {
8
+ export type BuildType = 'bundleless' | 'bundle';
9
+ export type Format = 'esm' | 'cjs' | 'umd' | 'iife';
10
+ export type Target = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
11
+ export type Input = Required<LibuildUserConfig>['input'];
12
+ export type DTSOptions = {
13
13
  distPath: string;
14
14
  tsconfigPath: string;
15
15
  only: boolean;
16
16
  };
17
- export declare type DTS = false | Partial<DTSOptions>;
17
+ export type DTS = false | Partial<DTSOptions>;
18
18
  export interface Asset {
19
19
  path?: LibuildAsset['outdir'];
20
20
  limit?: LibuildAsset['limit'];
21
21
  publicPath?: LibuildAsset['publicPath'];
22
22
  svgr?: boolean | Options;
23
23
  }
24
- export declare type SourceMap = Required<LibuildUserConfig>['sourceMap'];
25
- export declare type AutoExternal = boolean | {
24
+ export type SourceMap = Required<LibuildUserConfig>['sourceMap'];
25
+ export type AutoExternal = boolean | {
26
26
  dependencies?: boolean;
27
27
  peerDependencies?: boolean;
28
28
  };
29
- export declare type JSX = 'automatic' | 'transform';
30
- export declare type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, string> | void);
31
- export declare type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias'> & {
29
+ export type JSX = 'automatic' | 'transform';
30
+ export type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, string> | void);
31
+ export type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias'> & {
32
32
  dts: false | DTSOptions;
33
33
  style: Omit<Required<LibuildStyle>, 'cleanCss'> & {
34
34
  tailwindCss: TailwindCSSConfig;
35
35
  };
36
36
  alias: Record<string, string>;
37
37
  };
38
- export declare type PartialBaseBuildConfig = {
38
+ export type PartialBaseBuildConfig = {
39
39
  buildType?: 'bundleless' | 'bundle';
40
40
  format?: Format;
41
41
  target?: Target;
@@ -58,9 +58,9 @@ export declare type PartialBaseBuildConfig = {
58
58
  define?: LibuildUserConfig['define'];
59
59
  style?: StyleConfig;
60
60
  };
61
- export declare type BuildConfig = BaseBuildConfig | BaseBuildConfig[];
62
- export declare type PartialBuildConfig = PartialBaseBuildConfig | PartialBaseBuildConfig[];
63
- export declare type BuildPreset = keyof typeof presetList | ((options: {
61
+ export type BuildConfig = BaseBuildConfig | BaseBuildConfig[];
62
+ export type PartialBuildConfig = PartialBaseBuildConfig | PartialBaseBuildConfig[];
63
+ export type BuildPreset = keyof typeof presetList | ((options: {
64
64
  preset: typeof BuildInPreset;
65
65
  }) => PartialBuildConfig | Promise<PartialBuildConfig>);
66
66
  export interface StyleConfig {
@@ -78,15 +78,20 @@ export interface StyleConfig {
78
78
 
79
79
  tailwindcss?: TailwindCSSConfig;
80
80
  }
81
- export interface StorybookDevConfig {
82
- name?: string;
81
+ export interface StorybookBuildConfig {
82
+ webpack?: WebpackBuilderToolsConfig['webpack'];
83
+ webpackChain?: WebpackBuilderToolsConfig['webpackChain'];
83
84
  }
84
85
  export interface Dev {
85
- storybook: StorybookDevConfig;
86
+ storybook?: StorybookBuildConfig;
87
+ }
88
+ export interface RuntimeUserConfig {
89
+ [name: string]: any;
86
90
  }
87
91
  export interface ModuleExtraConfig {
88
92
  designSystem?: Record<string, any>;
89
93
  buildConfig?: PartialBuildConfig;
90
94
  buildPreset?: BuildPreset;
91
- dev?: DeepPartial<Dev>;
95
+ dev?: Dev;
96
+ runtime?: RuntimeUserConfig;
92
97
  }
@@ -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 { DeepPartial } from '../utils';\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'\n> & {\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 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};\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 }) => 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 StorybookDevConfig {\n name?: string;\n}\nexport interface Dev {\n storybook: StorybookDevConfig;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: DeepPartial<Dev>;\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/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'\n> & {\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 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};\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 }) => 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,12 +1,12 @@
1
1
  import type { Style } from '@modern-js/libuild';
2
2
  import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
3
- export declare type LessOptions = Required<Style>['less'];
4
- export declare type SassOptions = Required<Style>['sass'];
5
- export declare type PostcssOptions = Required<Style>['postcss'];
6
- export declare type LessConfig = LessOptions | ((options: LessOptions) => LessOptions | void);
7
- export declare type SassConfig = SassOptions | ((options: SassOptions) => SassOptions | void);
8
- export declare type PostCSSConfigUtils = {
3
+ export type LessOptions = Required<Style>['less'];
4
+ export type SassOptions = Required<Style>['sass'];
5
+ export type PostcssOptions = Required<Style>['postcss'];
6
+ export type LessConfig = LessOptions | ((options: LessOptions) => LessOptions | void);
7
+ export type SassConfig = SassOptions | ((options: SassOptions) => SassOptions | void);
8
+ export type PostCSSConfigUtils = {
9
9
  addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
10
10
  };
11
- export declare type PostCSSConfig = PostcssOptions | ((options: PostcssOptions, utils: PostCSSConfigUtils) => PostcssOptions | void);
12
- export declare type TailwindCSSConfig = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
11
+ export type PostCSSConfig = PostcssOptions | ((options: PostcssOptions, utils: PostCSSConfigUtils) => PostcssOptions | void);
12
+ export type TailwindCSSConfig = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
@@ -12,4 +12,4 @@ export interface CopyOptions {
12
12
  enableCopySync?: boolean;
13
13
  };
14
14
  }
15
- export declare type CopyConfig = CopyOptions;
15
+ export type CopyConfig = CopyOptions;
@@ -18,8 +18,8 @@ export interface BuildPlatformResult {
18
18
  status: 'success' | 'fail';
19
19
  message: string | Error | null;
20
20
  }
21
- export declare type DevToolData = BaseDevToolData<DevCommandOptions>;
22
- export declare type PromptResult = {
21
+ export type DevToolData = BaseDevToolData<DevCommandOptions>;
22
+ export type PromptResult = {
23
23
  choiceDevTool: string;
24
24
  } & Record<string, any>;
25
- export declare type ModuleToolsHooks = typeof registerHook;
25
+ export type ModuleToolsHooks = typeof registerHook;
@@ -7,11 +7,11 @@ export * from './config';
7
7
  export * from './dts';
8
8
  export * from './context';
9
9
  export type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';
10
- export declare type ModuleTools = {
10
+ export type ModuleTools = {
11
11
  hooks: ModuleToolsHooks;
12
12
  userConfig: ModuleExtraConfig;
13
13
  normalizedConfig: Required<ModuleExtraConfig>;
14
14
  };
15
- export declare type ModuleUserConfig = UserConfig<ModuleTools>;
16
- export declare type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;
17
- export declare type ModuleConfigParams = ModuleUserConfig | Promise<ModuleUserConfig> | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);
15
+ export type ModuleUserConfig = UserConfig<ModuleTools>;
16
+ export type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;
17
+ export type ModuleConfigParams = ModuleUserConfig | Promise<ModuleUserConfig> | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);
@@ -1,7 +1,7 @@
1
- export declare type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? DeepPartialArray<U> : T extends object ? DeepPartialObject<T> : T | undefined;
1
+ export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? DeepPartialArray<U> : T extends object ? DeepPartialObject<T> : T | undefined;
2
2
  /** @private */
3
3
 
4
- export declare type DeepPartialArray<T> = Array<DeepPartial<T>>;
4
+ export type DeepPartialArray<T> = Array<DeepPartial<T>>;
5
5
  /** @private */
6
6
 
7
- export declare type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
7
+ export type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
package/dist/utils/dts.js CHANGED
@@ -71,12 +71,7 @@ const generatorTsConfig = (projectTsconfig, config) => __async(void 0, null, fun
71
71
  var _a, _b, _c;
72
72
  const { fs, lodash, nanoid } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
73
73
  const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
74
- const {
75
- appDirectory,
76
- sourceDir: absSourceDir,
77
- distAbsPath,
78
- tsconfigPath
79
- } = config;
74
+ const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;
80
75
  const tempDistAbsRootPath = import_path.default.join(
81
76
  appDirectory,
82
77
  `${dtsTempDirectory}/${nanoid()}`
@@ -101,7 +96,7 @@ const generatorTsConfig = (projectTsconfig, config) => __async(void 0, null, fun
101
96
  };
102
97
  if (projectTsconfig.extends) {
103
98
  resetConfig.extends = projectTsconfig.extends.startsWith(".") ? import_path.default.join(
104
- import_path.default.relative(`${distAbsPath}/tsconfig.json`, tsconfigPath),
99
+ import_path.default.relative(`${tempDistAbsRootPath}`, import_path.default.dirname(tsconfigPath)),
105
100
  projectTsconfig.extends
106
101
  ) : projectTsconfig.extends;
107
102
  }
@@ -1 +1 @@
1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,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;AAnML;AAoME,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAG7C,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 projectTsconfig: ITsconfig,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, lodash, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const {\n appDirectory,\n sourceDir: absSourceDir,\n distAbsPath,\n tsconfigPath,\n } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsSrcPath = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const rootDir = path.relative(tempDistAbsRootPath, appDirectory);\n const baseUrl = projectTsconfig.compilerOptions?.baseUrl\n ? path.join(appDirectory, projectTsconfig.compilerOptions?.baseUrl)\n : appDirectory;\n // if include = ['src'], final include should be ['../src']\n const include = [path.relative(tempDistAbsRootPath, absSourceDir)];\n\n const resetConfig: ITsconfig = {\n compilerOptions: {\n ...projectTsconfig?.compilerOptions,\n rootDir,\n baseUrl,\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsRootPath,\n },\n include,\n exclude: projectTsconfig.exclude ?? [],\n };\n\n // extends: '../tsconfig.json'\n if (projectTsconfig.extends) {\n resetConfig.extends = projectTsconfig.extends.startsWith('.')\n ? path.join(\n path.relative(`${distAbsPath}/tsconfig.json`, tsconfigPath),\n projectTsconfig.extends,\n )\n : projectTsconfig.extends;\n }\n\n const recommendOption = {\n // Ensure that Babel can safely transpile files in the TypeScript project\n compilerOptions: {\n isolatedModules: true,\n },\n };\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const deepMerge = lodash.merge;\n fs.writeJSONSync(\n tempTsconfigPath,\n deepMerge(\n recommendOption,\n projectTsconfig,\n // 此处是必须要覆盖用户默认配置\n resetConfig,\n ),\n );\n\n return { tempTsconfigPath, tempDistAbsRootPath, tempDistAbsSrcPath };\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,oBAAoB,CAC/B,iBACA,WACG;AAfL;AAgBE,QAAM,EAAE,IAAI,QAAQ,OAAO,IAAI,MAAM,6CAAO;AAC5C,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO;AAE1C,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAAA,EAChC;AACA,QAAM,qBAAqB,oBAAK;AAAA,IAC9B;AAAA,IACA,oBAAK,SAAS,cAAc,YAAY;AAAA,EAC1C;AAEA,QAAM,UAAU,oBAAK,SAAS,qBAAqB,YAAY;AAC/D,QAAM,YAAU,qBAAgB,oBAAhB,mBAAiC,WAC7C,oBAAK,KAAK,eAAc,qBAAgB,oBAAhB,mBAAiC,OAAO,IAChE;AAEJ,QAAM,UAAU,CAAC,oBAAK,SAAS,qBAAqB,YAAY,CAAC;AAEjE,QAAM,cAAyB;AAAA,IAC7B,iBAAiB,iCACZ,mDAAiB,kBADL;AAAA,MAEf;AAAA,MACA;AAAA,MAEA,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAS,qBAAgB,YAAhB,YAA2B,CAAC;AAAA,EACvC;AAGA,MAAI,gBAAgB,SAAS;AAC3B,gBAAY,UAAU,gBAAgB,QAAQ,WAAW,GAAG,IACx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I;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;AA9LL;AA+LE,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO;AAG7C,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 projectTsconfig: ITsconfig,\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, lodash, 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 tempDistAbsSrcPath = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const rootDir = path.relative(tempDistAbsRootPath, appDirectory);\n const baseUrl = projectTsconfig.compilerOptions?.baseUrl\n ? path.join(appDirectory, projectTsconfig.compilerOptions?.baseUrl)\n : appDirectory;\n // if include = ['src'], final include should be ['../src']\n const include = [path.relative(tempDistAbsRootPath, absSourceDir)];\n\n const resetConfig: ITsconfig = {\n compilerOptions: {\n ...projectTsconfig?.compilerOptions,\n rootDir,\n baseUrl,\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsRootPath,\n },\n include,\n exclude: projectTsconfig.exclude ?? [],\n };\n\n // extends: '../tsconfig.json'\n if (projectTsconfig.extends) {\n resetConfig.extends = projectTsconfig.extends.startsWith('.')\n ? path.join(\n path.relative(`${tempDistAbsRootPath}`, path.dirname(tsconfigPath)),\n projectTsconfig.extends,\n )\n : projectTsconfig.extends;\n }\n\n const recommendOption = {\n // Ensure that Babel can safely transpile files in the TypeScript project\n compilerOptions: {\n isolatedModules: true,\n },\n };\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const deepMerge = lodash.merge;\n fs.writeJSONSync(\n tempTsconfigPath,\n deepMerge(\n recommendOption,\n projectTsconfig,\n // 此处是必须要覆盖用户默认配置\n resetConfig,\n ),\n );\n\n return { tempTsconfigPath, tempDistAbsRootPath, tempDistAbsSrcPath };\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"]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "module-tools",
12
12
  "lib-tools"
13
13
  ],
14
- "version": "2.0.0-beta.7",
14
+ "version": "2.0.2",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js",
17
17
  "modern-module": "./bin/modern.js"
@@ -36,17 +36,17 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@modern-js/libuild": "~0.7.3",
40
- "@modern-js/libuild-plugin-svgr": "0.6.0",
41
- "@modern-js/libuild-plugin-swc": "0.6.0",
42
- "@modern-js/core": "2.0.0-beta.7",
43
- "@modern-js/new-action": "2.0.0-beta.7",
44
- "@modern-js/plugin": "2.0.0-beta.7",
45
- "@modern-js/plugin-i18n": "2.0.0-beta.7",
46
- "@modern-js/upgrade": "2.0.0-beta.7",
47
- "@modern-js/utils": "2.0.0-beta.7",
48
- "@modern-js/plugin-changeset": "2.0.0-beta.7",
49
- "@modern-js/plugin-lint": "2.0.0-beta.7"
39
+ "@modern-js/libuild": "~0.8.0",
40
+ "@modern-js/libuild-plugin-svgr": "~0.8.0",
41
+ "@modern-js/libuild-plugin-swc": "~0.8.0",
42
+ "@modern-js/core": "2.0.2",
43
+ "@modern-js/new-action": "2.0.2",
44
+ "@modern-js/plugin": "2.0.2",
45
+ "@modern-js/plugin-i18n": "2.0.2",
46
+ "@modern-js/upgrade": "2.0.2",
47
+ "@modern-js/utils": "2.0.2",
48
+ "@modern-js/plugin-changeset": "2.0.2",
49
+ "@modern-js/plugin-lint": "2.0.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@modern-js/self": "npm:@modern-js/module-tools@*",
@@ -60,8 +60,9 @@
60
60
  "postcss-alias": "2.0.0",
61
61
  "react": "17",
62
62
  "typescript": "^4",
63
- "@scripts/build": "2.0.0-beta.7",
64
- "@scripts/jest-config": "2.0.0-beta.7"
63
+ "@modern-js/builder-webpack-provider": "2.0.2",
64
+ "@scripts/jest-config": "2.0.2",
65
+ "@scripts/build": "2.0.2"
65
66
  },
66
67
  "publishConfig": {
67
68
  "registry": "https://registry.npmjs.org/",