@adamhl8/configs 0.17.1 → 0.17.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.
@@ -8,7 +8,6 @@ import * as hookable0 from "hookable";
8
8
  //#region src/configs/tsdown.d.ts
9
9
  declare const tsdownConfig: MergeConfigFn<{
10
10
  entry?: rolldown0.InputOption;
11
- exports?: boolean | tsdown0.ExportsOptions;
12
11
  external?: rolldown0.ExternalOption;
13
12
  noExternal?: (string | RegExp | (string | RegExp)[]) | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
14
13
  skipNodeModulesBundle?: boolean;
@@ -59,6 +58,7 @@ declare const tsdownConfig: MergeConfigFn<{
59
58
  attw?: boolean | tsdown0.AttwOptions;
60
59
  report?: boolean | tsdown0.ReportOptions;
61
60
  globImport?: boolean;
61
+ exports?: boolean | tsdown0.ExportsOptions;
62
62
  publicDir?: tsdown0.CopyOptions | tsdown0.CopyOptionsFn;
63
63
  copy?: tsdown0.CopyOptions | tsdown0.CopyOptionsFn;
64
64
  hooks?: Partial<tsdown0.TsdownHooks> | ((hooks: hookable0.Hookable<tsdown0.TsdownHooks>) => void | Promise<void>);
@@ -1 +1 @@
1
- {"version":3,"file":"tsdown.d.ts","names":[],"sources":["../../src/configs/tsdown.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAyCa;UAAyF,SAAA,CAAA;;;;;;;EAAzF,MAAA,CAAA,EAAA,MAAyF,GAAA,MAAA,EAAA,GAAA,KAAA;EAAA,GAAA,CAAA,QAAA,CAAA,MAAA,EAAA,GAAA,CAAA;QAAA,CAAA,QAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA7E,SAAA,MAAA,EAAA,KAAA;EACZ,SAAA,QAAA,EAAwF,SAAA;EAAA,SAAA,MAAA,EAAA,UAAA;WAAA,SAAzE,EAAA,IAAA;WAAA,IAAA,EAAA,KAAA;WAAA,GAAA,EAAA;IAAA,SAAA,UAAA,EAAA,IAAA;;;;;;;;;;cAAf,iBAAe,sBAAA,KAAyE,OAAA,CAAzE,OAAA"}
1
+ {"version":3,"file":"tsdown.d.ts","names":[],"sources":["../../src/configs/tsdown.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAyCa;UAAyF,SAAA,CAAA;;;;;;;EAAzF,GAAA,CAAA,QAAA,CAAA,MAAyF,EAAA,GAAA,CAAA;EAAA,MAAA,CAAA,QAAA,CAAA,MAAA,EAAA,MAAA,CAAA;OAAA,CAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA7E,SAAA,MAAA,EAAA,KAAA;EACZ,SAAA,QAAA,EAAwF,SAAA;EAAA,SAAA,MAAA,EAAA,UAAA;WAAA,SAAzE,EAAA,IAAA;WAAA,IAAA,EAAA,KAAA;WAAA,GAAA,EAAA;IAAA,SAAA,UAAA,EAAA,IAAA;;;;;;;;;;cAAf,iBAAe,sBAAA,KAAyE,OAAA,CAAzE,OAAA"}
@@ -61,8 +61,11 @@ function getPathsMap() {
61
61
  }
62
62
  function resolveImportPath(importPath, filePath, pathsMap) {
63
63
  const fileDir = path.dirname(filePath);
64
- for (const [alias, aliasDir] of Object.entries(pathsMap)) {
64
+ const sortedAliases = Object.keys(pathsMap).sort((a, b) => b.length - a.length);
65
+ for (const alias of sortedAliases) {
65
66
  if (!importPath.startsWith(alias)) continue;
67
+ const aliasDir = pathsMap[alias];
68
+ if (!aliasDir) continue;
66
69
  const relativePath = importPath.slice(alias.length + 1);
67
70
  return path.resolve(aliasDir, relativePath);
68
71
  }
@@ -75,6 +78,11 @@ function changeExtension(importParts, newExtension) {
75
78
  base: ""
76
79
  };
77
80
  }
81
+ const ALLOWED_EXTENSIONS = [
82
+ ".ts",
83
+ ".tsx",
84
+ ".d.ts"
85
+ ];
78
86
  function getNewExtensionPathParts(importParts) {
79
87
  const tsExtensionLookups = [
80
88
  "",
@@ -83,16 +91,11 @@ function getNewExtensionPathParts(importParts) {
83
91
  ".ts",
84
92
  ".tsx"
85
93
  ];
86
- const allowedExtensions = [
87
- ".ts",
88
- ".tsx",
89
- ".d.ts"
90
- ];
91
94
  if (!tsExtensionLookups.includes(importParts.ext)) return {
92
95
  ext: importParts.ext,
93
96
  base: importParts.base
94
97
  };
95
- if (tsExtensionLookups.includes(importParts.ext)) for (const allowedExtension of allowedExtensions) {
98
+ if (tsExtensionLookups.includes(importParts.ext)) for (const allowedExtension of ALLOWED_EXTENSIONS) {
96
99
  const targetPathParts = changeExtension(importParts, allowedExtension);
97
100
  const targetPath = path.format(targetPathParts);
98
101
  if (fss.existsSync(targetPath)) return {
@@ -132,7 +135,10 @@ async function fixImports(filePaths, { write, importIgnoreStrings, skipAlias })
132
135
  ...newImportParts,
133
136
  ...transformExtensionResult
134
137
  };
135
- else importErrorsForFile.push(`skipped extension transform of '${importPath}': target file not found`);
138
+ else {
139
+ const targetFilePath = `${path.format(changeExtension(resolvedImportParts, ""))}.{${ALLOWED_EXTENSIONS.map((ext) => ext.replace(".", "")).join()}}`;
140
+ importErrorsForFile.push(`skipped extension transform of '${importPath}': target file not found (looking for '${targetFilePath}')`);
141
+ }
136
142
  if (isRelativeImport && !skipAlias) {
137
143
  const transformToAliasImportResult = getAliasPathParts(resolvedImportParts, pathsMap);
138
144
  if (transformToAliasImportResult) newImportParts = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamhl8/configs",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",