@modern-js/module-tools 2.60.6 → 2.62.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.
@@ -254,7 +254,7 @@ class EsbuildCompiler {
254
254
  root,
255
255
  platform: config.platform,
256
256
  alias: config.alias,
257
- tsconfig: config.tsconfig,
257
+ tsConfig: config.resolve.tsConfig,
258
258
  mainFields: config.resolve.mainFields
259
259
  };
260
260
  this.css_resolve = (0, import_resolve.createCssResolver)({
@@ -5,14 +5,16 @@ import type { ImportKind, Platform } from 'esbuild';
5
5
  export declare const cssExtensions: string[];
6
6
  export declare const createJsResolver: (options: ResolverOptions) => (id: string, dir: string, kind?: ImportKind) => string | false;
7
7
  export declare const createCssResolver: (options: ResolverOptions) => (id: string, dir: string, kind?: ImportKind) => string;
8
- interface ResolverOptions {
8
+ export interface ResolverOptions {
9
9
  platform: Platform;
10
10
  resolveType: 'js' | 'css';
11
11
  extensions: string[];
12
12
  root: string;
13
13
  alias: Record<string, string>;
14
- tsconfig: string;
14
+ tsConfig: {
15
+ configFile: string;
16
+ references?: string[] | undefined;
17
+ };
15
18
  mainFields: string[];
16
19
  preferRelative?: boolean;
17
20
  }
18
- export {};
@@ -45,10 +45,13 @@ const cssExtensions = [
45
45
  ];
46
46
  function createEnhancedResolve(options) {
47
47
  const plugins = [];
48
- const { tsconfig } = options;
49
- if (import_fs.default.existsSync(tsconfig)) {
48
+ const { tsConfig } = options;
49
+ const tsConfigFilePath = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.configFile;
50
+ const references = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.references;
51
+ if (import_fs.default.existsSync(tsConfigFilePath)) {
50
52
  plugins.push(new import_tsconfig_paths_webpack_plugin.default({
51
- configFile: tsconfig
53
+ configFile: tsConfigFilePath,
54
+ references
52
55
  }));
53
56
  }
54
57
  const resolveOptions = {
@@ -36,7 +36,7 @@ var import_utils = require("@modern-js/utils");
36
36
  var import_build = require("../constants/build");
37
37
  var import_utils2 = require("../utils");
38
38
  const mergeDefaultBaseConfig = async (pConfig, options) => {
39
- var _pConfig_resolve, _pConfig_resolve1, _pConfig_resolve2, _pConfig_style, _pConfig_style1, _pConfig_style2, _pConfig_style3;
39
+ var _pConfig_resolve, _pConfig_resolve1, _pConfig_resolve2, _pConfig_resolve3, _pConfig_style, _pConfig_style1, _pConfig_style2, _pConfig_style3;
40
40
  const defaultConfig = (0, import_build.getDefaultBuildConfig)();
41
41
  const { context, buildCmdOptions } = options;
42
42
  const { applyOptionsChain, ensureAbsolutePath, slash } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
@@ -114,11 +114,14 @@ const mergeDefaultBaseConfig = async (pConfig, options) => {
114
114
  "browser",
115
115
  "main"
116
116
  ];
117
- var _pConfig_resolve_mainFields, _pConfig_resolve_jsExtensions;
117
+ var _pConfig_resolve_mainFields, _pConfig_resolve_jsExtensions, _pConfig_resolve_tsConfig;
118
118
  const resolve = {
119
119
  mainFields: (_pConfig_resolve_mainFields = (_pConfig_resolve1 = pConfig.resolve) === null || _pConfig_resolve1 === void 0 ? void 0 : _pConfig_resolve1.mainFields) !== null && _pConfig_resolve_mainFields !== void 0 ? _pConfig_resolve_mainFields : defaultMainFields,
120
120
  jsExtensions: (_pConfig_resolve_jsExtensions = (_pConfig_resolve2 = pConfig.resolve) === null || _pConfig_resolve2 === void 0 ? void 0 : _pConfig_resolve2.jsExtensions) !== null && _pConfig_resolve_jsExtensions !== void 0 ? _pConfig_resolve_jsExtensions : defaultConfig.resolve.jsExtensions,
121
- alias: mergedResolveAlias
121
+ alias: mergedResolveAlias,
122
+ tsConfig: (_pConfig_resolve_tsConfig = (_pConfig_resolve3 = pConfig.resolve) === null || _pConfig_resolve3 === void 0 ? void 0 : _pConfig_resolve3.tsConfig) !== null && _pConfig_resolve_tsConfig !== void 0 ? _pConfig_resolve_tsConfig : tsconfig ? {
123
+ configFile: tsconfig
124
+ } : defaultConfig.resolve.tsConfig
122
125
  };
123
126
  var _pConfig_esbuildOptions;
124
127
  const esbuildOptions = (_pConfig_esbuildOptions = pConfig.esbuildOptions) !== null && _pConfig_esbuildOptions !== void 0 ? _pConfig_esbuildOptions : defaultConfig.esbuildOptions;
@@ -103,6 +103,9 @@ const transformToAbsPath = async (baseConfig, options) => {
103
103
  newConfig.outDir = import_path.default.resolve(context.appDirectory, newConfig.outDir);
104
104
  newConfig.sourceDir = import_path.default.resolve(context.appDirectory, baseConfig.sourceDir);
105
105
  newConfig.tsconfig = import_path.default.resolve(context.appDirectory, newConfig.tsconfig);
106
+ if (newConfig.resolve.tsConfig) {
107
+ newConfig.resolve.tsConfig.configFile = import_path.default.resolve(context.appDirectory, newConfig.resolve.tsConfig.configFile);
108
+ }
106
109
  if (newConfig.dts) {
107
110
  newConfig.dts.distPath = import_path.default.resolve(newConfig.outDir, newConfig.dts.distPath);
108
111
  if (newConfig.dts.tsconfigPath) {
@@ -80,7 +80,11 @@ const getDefaultBuildConfig = () => {
80
80
  ".ts",
81
81
  ".json"
82
82
  ],
83
- alias: {}
83
+ alias: {},
84
+ tsConfig: {
85
+ configFile: "tsconfig.json",
86
+ references: void 0
87
+ }
84
88
  },
85
89
  shims: false,
86
90
  sideEffects: void 0,
@@ -95,11 +95,17 @@ export type Resolve = {
95
95
  mainFields?: string[];
96
96
  jsExtensions?: string[];
97
97
  alias?: AliasOption;
98
+ tsConfig?: Tsconfig;
99
+ };
100
+ type Tsconfig = {
101
+ configFile: string;
102
+ references?: string[] | undefined;
98
103
  };
99
104
  export type ResolveOptions = {
100
105
  mainFields: string[];
101
106
  jsExtensions: string[];
102
107
  alias: Record<string, string>;
108
+ tsConfig: Tsconfig;
103
109
  };
104
110
  export type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias' | 'sideEffects' | 'asset' | 'resolve'> & {
105
111
  sideEffects?: SideEffects;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/module-tools",
3
- "version": "2.60.6",
3
+ "version": "2.62.0",
4
4
  "description": "Simple, powerful, high-performance modern npm package development solution.",
5
5
  "keywords": [
6
6
  "modern",
@@ -70,21 +70,21 @@
70
70
  "tapable": "2.2.1",
71
71
  "terser": "^5.31.1",
72
72
  "tsconfig-paths-webpack-plugin": "4.1.0",
73
- "@modern-js/core": "2.60.6",
74
- "@modern-js/plugin-changeset": "2.60.6",
75
- "@modern-js/plugin": "2.60.6",
76
- "@modern-js/types": "2.60.6",
77
- "@modern-js/plugin-i18n": "2.60.6",
78
- "@modern-js/utils": "2.60.6"
73
+ "@modern-js/core": "2.62.0",
74
+ "@modern-js/plugin": "2.62.0",
75
+ "@modern-js/plugin-changeset": "2.62.0",
76
+ "@modern-js/plugin-i18n": "2.62.0",
77
+ "@modern-js/types": "2.62.0",
78
+ "@modern-js/utils": "2.62.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@rsbuild/core": "~1.0.11",
81
+ "@rsbuild/core": "~1.1.0",
82
82
  "@types/convert-source-map": "1.5.2",
83
83
  "@types/node": "^14",
84
84
  "typescript": "^5",
85
- "@modern-js/self": "npm:@modern-js/module-tools@2.60.6",
86
- "@scripts/build": "2.60.6",
87
- "@scripts/vitest-config": "2.60.6"
85
+ "@modern-js/self": "npm:@modern-js/module-tools@2.62.0",
86
+ "@scripts/build": "2.62.0",
87
+ "@scripts/vitest-config": "2.62.0"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "typescript": "^4 || ^5"