@modern-js/module-tools 2.43.0 → 2.45.0-beta.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 (32) hide show
  1. package/compiled/@svgr/core/dist/index.d.ts +78 -0
  2. package/compiled/@svgr/core/index.js +1 -0
  3. package/compiled/@svgr/core/license +7 -0
  4. package/compiled/@svgr/core/package.json +1 -0
  5. package/compiled/@svgr/core/prettier/index.d.ts +920 -0
  6. package/compiled/@svgr/core/svgo/lib/svgo.d.ts +66 -0
  7. package/compiled/@svgr/plugin-jsx/@svgr/core/dist/index.d.ts +78 -0
  8. package/compiled/@svgr/plugin-jsx/dist/index.d.ts +5 -0
  9. package/compiled/@svgr/plugin-jsx/index.js +11 -0
  10. package/compiled/@svgr/plugin-jsx/license +7 -0
  11. package/compiled/@svgr/plugin-jsx/package.json +1 -0
  12. package/compiled/@svgr/plugin-jsx/prettier/index.d.ts +920 -0
  13. package/compiled/@svgr/plugin-jsx/svgo/lib/svgo.d.ts +66 -0
  14. package/compiled/@svgr/plugin-svgo/@svgr/core/dist/index.d.ts +78 -0
  15. package/compiled/@svgr/plugin-svgo/dist/index.d.ts +5 -0
  16. package/compiled/@svgr/plugin-svgo/index.js +1 -0
  17. package/compiled/@svgr/plugin-svgo/license +7 -0
  18. package/compiled/@svgr/plugin-svgo/package.json +1 -0
  19. package/compiled/@svgr/plugin-svgo/prettier/index.d.ts +920 -0
  20. package/compiled/@svgr/plugin-svgo/svgo/lib/svgo.d.ts +66 -0
  21. package/dist/builder/build.js +3 -2
  22. package/dist/builder/clear.js +11 -9
  23. package/dist/builder/dts/tsc.js +8 -7
  24. package/dist/builder/feature/asset.d.ts +2 -3
  25. package/dist/builder/feature/asset.js +25 -40
  26. package/dist/builder/feature/redirect.js +6 -7
  27. package/dist/constants/build.js +2 -1
  28. package/dist/constants/preset.d.ts +4 -4
  29. package/dist/types/config/index.d.ts +7 -1
  30. package/dist/types/dts.d.ts +1 -0
  31. package/dist/utils/dts.js +6 -1
  32. package/package.json +17 -18
@@ -0,0 +1,66 @@
1
+ import type { StringifyOptions, DataUri, Plugin as PluginFn } from './types';
2
+ import type {
3
+ BuiltinsWithOptionalParams,
4
+ BuiltinsWithRequiredParams,
5
+ } from '../plugins/plugins-types';
6
+
7
+ type CustomPlugin = {
8
+ name: string;
9
+ fn: PluginFn<void>;
10
+ };
11
+
12
+ type PluginConfig =
13
+ | keyof BuiltinsWithOptionalParams
14
+ | {
15
+ [Name in keyof BuiltinsWithOptionalParams]: {
16
+ name: Name;
17
+ params?: BuiltinsWithOptionalParams[Name];
18
+ };
19
+ }[keyof BuiltinsWithOptionalParams]
20
+ | {
21
+ [Name in keyof BuiltinsWithRequiredParams]: {
22
+ name: Name;
23
+ params: BuiltinsWithRequiredParams[Name];
24
+ };
25
+ }[keyof BuiltinsWithRequiredParams]
26
+ | CustomPlugin;
27
+
28
+ export type Config = {
29
+ /** Can be used by plugins, for example prefixids */
30
+ path?: string;
31
+ /** Pass over SVGs multiple times to ensure all optimizations are applied. */
32
+ multipass?: boolean;
33
+ /** Precision of floating point numbers. Will be passed to each plugin that suppors this param. */
34
+ floatPrecision?: number;
35
+ /**
36
+ * Plugins configuration
37
+ * ['preset-default'] is default
38
+ * Can also specify any builtin plugin
39
+ * ['sortAttrs', { name: 'prefixIds', params: { prefix: 'my-prefix' } }]
40
+ * Or custom
41
+ * [{ name: 'myPlugin', fn: () => ({}) }]
42
+ */
43
+ plugins?: PluginConfig[];
44
+ /** Options for rendering optimized SVG from AST. */
45
+ js2svg?: StringifyOptions;
46
+ /** Output as Data URI string. */
47
+ datauri?: DataUri;
48
+ };
49
+
50
+ type Output = {
51
+ data: string;
52
+ };
53
+
54
+ /** The core of SVGO */
55
+ export declare function optimize(input: string, config?: Config): Output;
56
+
57
+ /**
58
+ * If you write a tool on top of svgo you might need a way to load svgo config.
59
+ *
60
+ * You can also specify relative or absolute path and customize current working directory.
61
+ */
62
+ export declare function loadConfig(
63
+ configFile: string,
64
+ cwd?: string
65
+ ): Promise<Config>;
66
+ export declare function loadConfig(): Promise<Config | null>;
@@ -76,7 +76,7 @@ const generatorDts = async (config, api, options) => {
76
76
  const { watch, dts } = options;
77
77
  const { buildType, input, sourceDir, alias, externals, tsconfig, footer: { dts: footer }, banner: { dts: banner }, format, autoExtension } = config;
78
78
  const { appDirectory } = api.useAppContext();
79
- const { distPath, abortOnError, respectExternal } = dts;
79
+ const { distPath, abortOnError, respectExternal, enableTscBuild } = dts;
80
80
  var _dts_tsconfigPath;
81
81
  const tsconfigPath = (_dts_tsconfigPath = dts.tsconfigPath) !== null && _dts_tsconfigPath !== void 0 ? _dts_tsconfigPath : tsconfig;
82
82
  const { dtsExtension } = (0, import_utils2.getDefaultOutExtension)({
@@ -99,7 +99,8 @@ const generatorDts = async (config, api, options) => {
99
99
  alias,
100
100
  sourceDir,
101
101
  dtsExtension,
102
- userTsconfig
102
+ userTsconfig,
103
+ enableTscBuild
103
104
  };
104
105
  const prevTime = Date.now();
105
106
  (0, import_debug.debug)(`${(0, import_debug.label)("dts")} Build Start`);
@@ -35,23 +35,25 @@ const clearBuildConfigPaths = async (configs, projectAbsRootPath) => {
35
35
  }
36
36
  if (config.buildType === "bundleless" && config.dts) {
37
37
  const { compilerOptions } = await (0, import_utils2.getProjectTsconfig)(config.tsconfig);
38
- const { composite, incremental, rootDir, tsBuildInfoFile = ".tsbuildinfo" } = compilerOptions || {};
38
+ const { composite, incremental, rootDir, outDir, tsBuildInfoFile = ".tsbuildinfo" } = compilerOptions || {};
39
39
  if (!composite && !incremental) {
40
40
  return;
41
41
  }
42
- const outDir = config.dts.distPath;
43
42
  const tsconfigDir = (0, import_path.dirname)(config.tsconfig);
44
43
  let tsbuildInfoFilePath = `${(0, import_path.basename)(config.tsconfig, ".json")}${tsBuildInfoFile}`;
45
- if (rootDir) {
46
- tsbuildInfoFilePath = (0, import_path.resolve)(outDir, (0, import_path.relative)((0, import_path.resolve)(tsconfigDir, rootDir), tsconfigDir), tsbuildInfoFilePath);
47
- } else {
48
- tsbuildInfoFilePath = (0, import_path.resolve)(outDir, tsbuildInfoFilePath);
44
+ if (outDir) {
45
+ if (rootDir) {
46
+ tsbuildInfoFilePath = (0, import_path.join)(outDir, (0, import_path.relative)((0, import_path.resolve)(tsconfigDir, rootDir), tsconfigDir), tsbuildInfoFilePath);
47
+ } else {
48
+ tsbuildInfoFilePath = (0, import_path.join)(outDir, tsbuildInfoFilePath);
49
+ }
49
50
  }
51
+ const tsbuildInfoFileAbsPath = (0, import_path.resolve)(tsconfigDir, tsbuildInfoFilePath);
50
52
  (0, import_debug.debug)("clear tsbuildinfo");
51
- if (await import_utils.fs.pathExists(tsbuildInfoFilePath)) {
52
- await import_utils.fs.remove(tsbuildInfoFilePath);
53
+ if (await import_utils.fs.pathExists(tsbuildInfoFileAbsPath)) {
54
+ await import_utils.fs.remove(tsbuildInfoFileAbsPath);
53
55
  } else {
54
- (0, import_debug.debug)(`${tsbuildInfoFilePath} doesn't exist`);
56
+ (0, import_debug.debug)(`${tsbuildInfoFileAbsPath} doesn't exist`);
55
57
  }
56
58
  }
57
59
  }
@@ -57,22 +57,23 @@ const resolveLog = async (childProgress, options) => {
57
57
  });
58
58
  };
59
59
  const runTscBin = async (api, config) => {
60
- const { appDirectory, watch = false, abortOnError = true, tsconfigPath, userTsconfig, distPath } = config;
60
+ const { appDirectory, watch = false, abortOnError = true, tsconfigPath, userTsconfig, distPath, enableTscBuild } = config;
61
61
  const tscBinFile = await (0, import_utils2.getTscBinPath)(appDirectory);
62
62
  const params = [];
63
- if (userTsconfig.references) {
63
+ if (enableTscBuild) {
64
64
  params.push("-b", tsconfigPath);
65
65
  var _userTsconfig_compilerOptions;
66
- const { baseUrl = ".", outDir, emitDeclarationOnly, declaration } = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) !== null && _userTsconfig_compilerOptions !== void 0 ? _userTsconfig_compilerOptions : {};
66
+ const { baseUrl = ".", outDir, emitDeclarationOnly, declaration, declarationDir } = (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) !== null && _userTsconfig_compilerOptions !== void 0 ? _userTsconfig_compilerOptions : {};
67
67
  const abosultBaseUrl = import_path.default.isAbsolute(baseUrl) ? baseUrl : import_path.default.join(import_path.default.dirname(tsconfigPath), baseUrl);
68
- if (!outDir || import_path.default.resolve(abosultBaseUrl, outDir) !== distPath) {
68
+ if ((!outDir || import_path.default.resolve(abosultBaseUrl, outDir) !== distPath) && (!declarationDir || import_path.default.resolve(abosultBaseUrl, declarationDir) !== distPath)) {
69
69
  const correctOutDir = import_path.default.relative(abosultBaseUrl, distPath);
70
- throw new Error(`Please set outDir: "${correctOutDir}" in ${import_utils.chalk.underline(tsconfigPath)} to keep it same as buildConfig.`);
70
+ const info = outDir && !declarationDir ? "outDir" : "declarationDir";
71
+ import_utils.logger.error(`Please set ${info}: "${correctOutDir}" in ${import_utils.chalk.underline(tsconfigPath)} to keep it same as buildConfig.`);
71
72
  }
72
73
  const tsVersion = await (0, import_utils2.detectTSVersion)(appDirectory);
73
74
  if (tsVersion !== 5) {
74
75
  if (!declaration || !emitDeclarationOnly) {
75
- throw new Error(`Please set declaration: true and emitDeclaration: true in ${import_utils.chalk.underline(tsconfigPath)}`);
76
+ import_utils.logger.error(`Please set declaration: true and emitDeclarationOnly: true in ${import_utils.chalk.underline(tsconfigPath)}`);
76
77
  }
77
78
  } else {
78
79
  params.push("--declaration", "--emitDeclarationOnly");
@@ -82,7 +83,7 @@ const runTscBin = async (api, config) => {
82
83
  "-p",
83
84
  tsconfigPath,
84
85
  // Same as dts.distPath
85
- "--outDir",
86
+ "--declarationDir",
86
87
  distPath,
87
88
  // Only emit d.ts files
88
89
  "--declaration",
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ICompiler, LoadResult, SvgrOptions } from '../../types';
2
+ import { ICompiler } from '../../types';
3
3
  export declare const asset: {
4
4
  name: string;
5
5
  apply(compiler: ICompiler): void;
@@ -14,6 +14,5 @@ export declare const asset: {
14
14
  */
15
15
  export declare function getAssetContents(this: ICompiler, assetPath: string, rebaseFrom: string, calledOnLoad?: boolean): Promise<{
16
16
  contents: string | Buffer;
17
- loader: "copy" | "text";
17
+ loader: "copy" | "text" | "jsx";
18
18
  }>;
19
- export declare function loadSvgr(path: string, options: boolean | SvgrOptions): Promise<LoadResult | undefined>;
@@ -29,16 +29,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var asset_exports = {};
30
30
  __export(asset_exports, {
31
31
  asset: () => asset,
32
- getAssetContents: () => getAssetContents,
33
- loadSvgr: () => loadSvgr
32
+ getAssetContents: () => getAssetContents
34
33
  });
35
34
  module.exports = __toCommonJS(asset_exports);
36
35
  var import_path = require("path");
37
36
  var import_fs = __toESM(require("fs"));
38
37
  var import_pluginutils = require("@rollup/pluginutils");
39
- var import_core = require("@svgr/core");
40
- var import_plugin_svgo = __toESM(require("@svgr/plugin-svgo"));
41
- var import_plugin_jsx = __toESM(require("@svgr/plugin-jsx"));
38
+ var import_core = require("../../../compiled/@svgr/core");
39
+ var import_plugin_svgo = __toESM(require("../../../compiled/@svgr/plugin-svgo"));
40
+ var import_plugin_jsx = __toESM(require("../../../compiled/@svgr/plugin-jsx"));
42
41
  var import_file = require("../../constants/file");
43
42
  var import_utils = require("../../utils");
44
43
  const name = "asset";
@@ -50,11 +49,7 @@ const asset = {
50
49
  name
51
50
  }, async (args) => {
52
51
  if (import_file.assetExt.find((ext) => ext === (0, import_path.extname)(args.path))) {
53
- const { buildType, outDir, sourceDir, asset: asset2 } = compiler.config;
54
- const svgrResult = await loadSvgr(args.path, asset2.svgr);
55
- if (svgrResult) {
56
- return svgrResult;
57
- }
52
+ const { buildType, outDir, sourceDir } = compiler.config;
58
53
  const rebaseFrom = buildType === "bundle" ? outDir : (0, import_path.join)(outDir, (0, import_path.relative)(sourceDir, (0, import_path.dirname)(args.path)));
59
54
  const { contents, loader } = await getAssetContents.apply(compiler, [
60
55
  args.path,
@@ -75,7 +70,7 @@ function encodeSVG(buffer) {
75
70
  async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
76
71
  const fileContent = await import_fs.default.promises.readFile(assetPath);
77
72
  const { buildType, format, outDir } = this.config;
78
- const { limit, path, publicPath } = this.config.asset;
73
+ const { limit, path, publicPath, svgr } = this.config.asset;
79
74
  const hash = (0, import_utils.getHash)(fileContent, null).slice(0, 8);
80
75
  const outputFileName = (0, import_path.basename)(assetPath).split(".").join(`.${hash}.`);
81
76
  const outputFilePath = (0, import_path.resolve)(outDir, path, outputFileName);
@@ -85,7 +80,24 @@ async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
85
80
  let emitAsset = true;
86
81
  let contents = normalizedPublicPath;
87
82
  let loader = "text";
88
- if (buildType === "bundle") {
83
+ const config = typeof svgr === "boolean" ? {} : svgr;
84
+ const filter = (0, import_pluginutils.createFilter)(config.include || SVG_REGEXP, config.exclude);
85
+ if (svgr && filter(assetPath)) {
86
+ const previousExport = config.exportType === "named" ? `export default "${normalizedPublicPath}"` : null;
87
+ contents = await (0, import_core.transform)(fileContent.toString(), config, {
88
+ filePath: assetPath,
89
+ caller: {
90
+ name: "svgr",
91
+ defaultPlugins: [
92
+ import_plugin_svgo.default,
93
+ import_plugin_jsx.default
94
+ ],
95
+ previousExport
96
+ }
97
+ });
98
+ loader = "jsx";
99
+ emitAsset = false;
100
+ } else if (buildType === "bundle") {
89
101
  if (fileContent.length <= limit) {
90
102
  const mimetype = (await Promise.resolve().then(() => __toESM(require("@modern-js/utils/mime-types")))).default.lookup(assetPath);
91
103
  const isSVG = mimetype === "image/svg+xml";
@@ -115,35 +127,8 @@ async function getAssetContents(assetPath, rebaseFrom, calledOnLoad) {
115
127
  loader
116
128
  };
117
129
  }
118
- async function loadSvgr(path, options) {
119
- if (!options) {
120
- return;
121
- }
122
- const config = typeof options === "boolean" ? {} : options;
123
- const filter = (0, import_pluginutils.createFilter)(config.include || SVG_REGEXP, config.exclude);
124
- if (!filter(path)) {
125
- return;
126
- }
127
- const loader = "jsx";
128
- const text = import_fs.default.readFileSync(path, "utf8");
129
- const jsCode = await (0, import_core.transform)(text, config, {
130
- filePath: path,
131
- caller: {
132
- name: "svgr",
133
- defaultPlugins: [
134
- import_plugin_svgo.default,
135
- import_plugin_jsx.default
136
- ]
137
- }
138
- });
139
- return {
140
- contents: jsCode,
141
- loader
142
- };
143
- }
144
130
  // Annotate the CommonJS export names for ESM import in node:
145
131
  0 && (module.exports = {
146
132
  asset,
147
- getAssetContents,
148
- loadSvgr
133
+ getAssetContents
149
134
  });
@@ -55,7 +55,7 @@ async function redirectImport(compiler, code, modules, aliasRecord, filePath, ou
55
55
  const { start, end } = module2;
56
56
  let { name: name2 } = module2;
57
57
  const ext = (0, import_path.extname)(name2);
58
- const { redirect: redirect2, asset } = compiler.config;
58
+ const { redirect: redirect2 } = compiler.config;
59
59
  const { alias, style } = redirect2;
60
60
  if (alias) {
61
61
  let absoluteImportPath = matchPath ? matchPath(name2, void 0, void 0, extensions) : void 0;
@@ -119,16 +119,15 @@ async function redirectImport(compiler, code, modules, aliasRecord, filePath, ou
119
119
  if (redirect2.asset) {
120
120
  if (import_file.assetExt.filter((ext2) => name2.endsWith(ext2)).length) {
121
121
  const absPath = (0, import_path.resolve)((0, import_path.dirname)(filePath), name2);
122
- const svgrResult = await (0, import_asset.loadSvgr)(absPath, asset.svgr);
123
- if (svgrResult) {
122
+ const { contents: relativeImportPath, loader } = await import_asset.getAssetContents.apply(compiler, [
123
+ absPath,
124
+ outputDir
125
+ ]);
126
+ if (loader === "jsx") {
124
127
  const ext2 = (0, import_path.extname)(name2);
125
128
  const outputName = `${name2.slice(0, -ext2.length)}.js`;
126
129
  str.overwrite(start, end, outputName);
127
130
  } else {
128
- const { contents: relativeImportPath } = await import_asset.getAssetContents.apply(compiler, [
129
- absPath,
130
- outputDir
131
- ]);
132
131
  str.overwrite(start, end, `${relativeImportPath}`);
133
132
  }
134
133
  }
@@ -42,7 +42,8 @@ const getDefaultBuildConfig = () => {
42
42
  distPath: "./",
43
43
  tsconfigPath: void 0,
44
44
  abortOnError: true,
45
- respectExternal: true
45
+ respectExternal: true,
46
+ enableTscBuild: false
46
47
  }),
47
48
  autoExtension: false,
48
49
  esbuildOptions: (c) => c,
@@ -7,19 +7,19 @@ export declare const npmComponentWithUmdPresetConfig: PartialBaseBuildConfig[];
7
7
  export declare const libraryPreset: {
8
8
  'npm-library': PartialBaseBuildConfig[];
9
9
  };
10
- export declare const libraryPresetWithTarget: Record<"npm-library-es6" | "npm-library-esnext" | "npm-library-es5" | "npm-library-es2015" | "npm-library-es2016" | "npm-library-es2017" | "npm-library-es2018" | "npm-library-es2019" | "npm-library-es2020" | "npm-library-es2021" | "npm-library-es2022", PartialBaseBuildConfig[]>;
10
+ export declare const libraryPresetWithTarget: Record<"npm-library-esnext" | "npm-library-es5" | "npm-library-es6" | "npm-library-es2015" | "npm-library-es2016" | "npm-library-es2017" | "npm-library-es2018" | "npm-library-es2019" | "npm-library-es2020" | "npm-library-es2021" | "npm-library-es2022", PartialBaseBuildConfig[]>;
11
11
  export declare const libraryUmdPreset: {
12
12
  'npm-library-with-umd': PartialBaseBuildConfig[];
13
13
  };
14
- export declare const libraryUmdPresetWithTarget: Record<"npm-library-with-umd-es6" | "npm-library-with-umd-esnext" | "npm-library-with-umd-es5" | "npm-library-with-umd-es2015" | "npm-library-with-umd-es2016" | "npm-library-with-umd-es2017" | "npm-library-with-umd-es2018" | "npm-library-with-umd-es2019" | "npm-library-with-umd-es2020" | "npm-library-with-umd-es2021" | "npm-library-with-umd-es2022", PartialBaseBuildConfig[]>;
14
+ export declare const libraryUmdPresetWithTarget: Record<"npm-library-with-umd-esnext" | "npm-library-with-umd-es5" | "npm-library-with-umd-es6" | "npm-library-with-umd-es2015" | "npm-library-with-umd-es2016" | "npm-library-with-umd-es2017" | "npm-library-with-umd-es2018" | "npm-library-with-umd-es2019" | "npm-library-with-umd-es2020" | "npm-library-with-umd-es2021" | "npm-library-with-umd-es2022", PartialBaseBuildConfig[]>;
15
15
  export declare const componentPreset: {
16
16
  'npm-component': PartialBaseBuildConfig[];
17
17
  };
18
- export declare const componentPresetWithTarget: Record<"npm-component-es6" | "npm-component-esnext" | "npm-component-es5" | "npm-component-es2015" | "npm-component-es2016" | "npm-component-es2017" | "npm-component-es2018" | "npm-component-es2019" | "npm-component-es2020" | "npm-component-es2021" | "npm-component-es2022", PartialBaseBuildConfig[]>;
18
+ export declare const componentPresetWithTarget: Record<"npm-component-esnext" | "npm-component-es5" | "npm-component-es6" | "npm-component-es2015" | "npm-component-es2016" | "npm-component-es2017" | "npm-component-es2018" | "npm-component-es2019" | "npm-component-es2020" | "npm-component-es2021" | "npm-component-es2022", PartialBaseBuildConfig[]>;
19
19
  export declare const componentUmdPreset: {
20
20
  'npm-component-with-umd': PartialBaseBuildConfig[];
21
21
  };
22
- export declare const componentUmdPresetWithTarget: Record<"npm-component-with-umd-es6" | "npm-component-with-umd-esnext" | "npm-component-with-umd-es5" | "npm-component-with-umd-es2015" | "npm-component-with-umd-es2016" | "npm-component-with-umd-es2017" | "npm-component-with-umd-es2018" | "npm-component-with-umd-es2019" | "npm-component-with-umd-es2020" | "npm-component-with-umd-es2021" | "npm-component-with-umd-es2022", PartialBaseBuildConfig[]>;
22
+ export declare const componentUmdPresetWithTarget: Record<"npm-component-with-umd-esnext" | "npm-component-with-umd-es5" | "npm-component-with-umd-es6" | "npm-component-with-umd-es2015" | "npm-component-with-umd-es2016" | "npm-component-with-umd-es2017" | "npm-component-with-umd-es2018" | "npm-component-with-umd-es2019" | "npm-component-with-umd-es2020" | "npm-component-with-umd-es2021" | "npm-component-with-umd-es2022", PartialBaseBuildConfig[]>;
23
23
  export declare const nodeBuildConfig: PartialBaseBuildConfig[];
24
24
  export declare const universalBuildConfig: PartialBaseBuildConfig[];
25
25
  export declare const presetList: Record<string, PartialBaseBuildConfig[]>;
@@ -1,9 +1,9 @@
1
1
  import type { BuildOptions } from 'esbuild';
2
2
  import type { ImportItem } from '@modern-js/swc-plugins';
3
- import type { Config } from '@svgr/core';
4
3
  import type { CreateFilter } from '@rollup/pluginutils';
5
4
  import type { MinifyOptions as TerserMinifyOptions } from 'terser';
6
5
  import type { TestConfig } from '@modern-js/types';
6
+ import type { Config } from '../../../compiled/@svgr/core';
7
7
  import { internalPreset, presetList } from '../../constants/preset';
8
8
  import { ICompiler } from '../esbuild';
9
9
  import type { CopyConfig } from './copy';
@@ -41,6 +41,12 @@ export type Redirect = {
41
41
  export type DTSOptions = {
42
42
  abortOnError: boolean;
43
43
  distPath: string;
44
+ /**
45
+ * Build one or more projects and their dependencies, if out of date
46
+ * The same as 'tsc --build'
47
+ * @default false
48
+ */
49
+ enableTscBuild: boolean;
44
50
  only: boolean;
45
51
  /**
46
52
  * @deprecated
@@ -14,6 +14,7 @@ export interface GeneratorDtsConfig {
14
14
  respectExternal: boolean;
15
15
  dtsExtension: string;
16
16
  userTsconfig: ITsconfig;
17
+ enableTscBuild: boolean;
17
18
  }
18
19
  export interface GeneratedDtsInfo {
19
20
  userTsconfig: ITsconfig;
package/dist/utils/dts.js CHANGED
@@ -123,7 +123,12 @@ const processDtsFilesAfterTsc = async (config) => {
123
123
  return;
124
124
  }
125
125
  const { start, end, name } = module2;
126
- const absoluteImportPath = matchPath(name);
126
+ const absoluteImportPath = matchPath(name, void 0, void 0, [
127
+ ".jsx",
128
+ ".tsx",
129
+ ".js",
130
+ ".ts"
131
+ ]);
127
132
  if (absoluteImportPath) {
128
133
  const relativePath = (0, import_path.relative)((0, import_path.dirname)(originalFilePath), absoluteImportPath);
129
134
  const relativeImportPath = (0, import_builder.normalizeSlashes)(relativePath.startsWith("..") ? relativePath : `./${relativePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/module-tools",
3
- "version": "2.43.0",
3
+ "version": "2.45.0-beta.0",
4
4
  "description": "Simple, powerful, high-performance modern npm package development solution.",
5
5
  "keywords": [
6
6
  "modern",
@@ -47,12 +47,11 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ampproject/remapping": "^2.2.1",
50
- "@ast-grep/napi": "0.12.0",
50
+ "@ast-grep/napi": "0.16.0",
51
+ "@babel/core": "^7.23.2",
52
+ "@babel/types": "^7.23.2",
51
53
  "@modern-js/swc-plugins": "0.6.6",
52
54
  "@rollup/pluginutils": "4.1.1",
53
- "@svgr/core": "8.0.0",
54
- "@svgr/plugin-jsx": "8.0.1",
55
- "@svgr/plugin-svgo": "8.0.1",
56
55
  "@swc/helpers": "0.5.3",
57
56
  "convert-source-map": "1.8.0",
58
57
  "enhanced-resolve": "5.12.0",
@@ -67,24 +66,24 @@
67
66
  "tapable": "2.2.1",
68
67
  "terser": "5.19.2",
69
68
  "tsconfig-paths-webpack-plugin": "4.1.0",
70
- "@modern-js/core": "2.43.0",
71
- "@modern-js/new-action": "2.43.0",
72
- "@modern-js/plugin": "2.43.0",
73
- "@modern-js/plugin-i18n": "2.43.0",
74
- "@modern-js/plugin-lint": "2.43.0",
75
- "@modern-js/plugin-changeset": "2.43.0",
76
- "@modern-js/types": "2.43.0",
77
- "@modern-js/upgrade": "2.43.0",
78
- "@modern-js/utils": "2.43.0"
69
+ "@modern-js/core": "2.45.0",
70
+ "@modern-js/new-action": "2.45.0",
71
+ "@modern-js/plugin": "2.45.0",
72
+ "@modern-js/plugin-changeset": "2.45.0",
73
+ "@modern-js/plugin-i18n": "2.45.0",
74
+ "@modern-js/plugin-lint": "2.45.0",
75
+ "@modern-js/types": "2.45.0",
76
+ "@modern-js/upgrade": "2.45.0",
77
+ "@modern-js/utils": "2.45.0"
79
78
  },
80
79
  "devDependencies": {
81
80
  "@types/convert-source-map": "1.5.2",
82
81
  "@types/node": "^14",
83
82
  "typescript": "^5",
84
- "@modern-js/builder-webpack-provider": "2.43.0",
85
- "@modern-js/self": "npm:@modern-js/module-tools@2.43.0",
86
- "@scripts/build": "2.43.0",
87
- "@scripts/vitest-config": "2.43.0"
83
+ "@modern-js/builder-webpack-provider": "2.45.0",
84
+ "@modern-js/self": "npm:@modern-js/module-tools@2.45.0-beta.0",
85
+ "@scripts/build": "2.45.0",
86
+ "@scripts/vitest-config": "2.45.0"
88
87
  },
89
88
  "peerDependencies": {
90
89
  "typescript": "^4 || ^5"