@nhtio/vite-plugins 0.1.0-master-c9c6a989 → 0.1.0-master-58153a44

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/README.md CHANGED
@@ -23,7 +23,12 @@ Internal declaration references (including aliases, directory indexes, ambient
23
23
  files and bundled dependencies) then use paths such as `#types/private/mixin` or
24
24
  `#types/utils/index`, without extensions. External and published package-name
25
25
  self-references remain unchanged. The build fails if any relative import/export
26
- or import-type specifier remains in an emitted declaration.
26
+ or import-type specifier remains in an emitted declaration, or a subpath specifier
27
+ resolves to its own declaration file.
28
+
29
+ A bundled dependency whose types API Extractor cannot inline keeps a bare import
30
+ or re-export of that package. As in relative mode, consumers must have its types
31
+ available (for example, by installing the corresponding `@types` package).
27
32
 
28
33
  Subpath mode also emits `dts-imports.json` at the output root:
29
34
 
package/dts_complex.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { d } from "./index-Crhrknhq.mjs";
1
+ import { d } from "./index-D70JB0pM.mjs";
2
2
  export {
3
3
  d as dtsComplex
4
4
  };
@@ -336074,6 +336074,7 @@ const unpluginFactory = (options2) => {
336074
336074
  const tmpDirTypeChecker = tmpDirProgram.getTypeChecker();
336075
336075
  const tmpDirTransformer = (context) => (sourceFile) => {
336076
336076
  const computeRelativePath = (targetPath) => {
336077
+ if (resolve(targetPath) === resolve(sourceFile.fileName)) return void 0;
336077
336078
  const withoutExtension = targetPath.replace(/\\/g, "/").replace(/\.(d\.ts|ts|tsx|cts|mts|js|jsx|cjs|mjs)$/, "");
336078
336079
  if (mergedOptions.internalImports === "subpath") {
336079
336080
  return `${mergedOptions.subpathPrefix}/${relative(
@@ -336255,6 +336256,7 @@ const unpluginFactory = (options2) => {
336255
336256
  logger.succeed(`Fixed import and export references in generated declaration files`);
336256
336257
  if (mergedOptions.internalImports === "subpath") {
336257
336258
  const relativeSpecifiers = [];
336259
+ const selfSpecifiers = [];
336258
336260
  for (const absolutePath of tmpDirRootNames) {
336259
336261
  const source = ts.createSourceFile(
336260
336262
  absolutePath,
@@ -336268,10 +336270,25 @@ const unpluginFactory = (options2) => {
336268
336270
  `${relative(runtimeConfiguration.tempDirPath, absolutePath)}: ${specifier.text}`
336269
336271
  );
336270
336272
  }
336273
+ if (specifier && ts.isStringLiteral(specifier) && specifier.text.startsWith(`${mergedOptions.subpathPrefix}/`) && resolve(
336274
+ runtimeConfiguration.tempDirPath,
336275
+ `${specifier.text.slice(mergedOptions.subpathPrefix.length + 1)}.d.ts`
336276
+ ) === resolve(absolutePath)) {
336277
+ selfSpecifiers.push(
336278
+ `${relative(runtimeConfiguration.tempDirPath, absolutePath)}: ${specifier.text}`
336279
+ );
336280
+ }
336271
336281
  ts.forEachChild(node, visit);
336272
336282
  };
336273
336283
  visit(source);
336274
336284
  }
336285
+ if (selfSpecifiers.length) {
336286
+ await cleanup();
336287
+ return this.error(
336288
+ `subpath imports contain self-referencing declaration specifiers:
336289
+ ${selfSpecifiers.join("\n")}`
336290
+ );
336291
+ }
336275
336292
  if (relativeSpecifiers.length) {
336276
336293
  await cleanup();
336277
336294
  return this.error(
@@ -336340,4 +336357,4 @@ const dtsComplex = /* @__PURE__ */ createVitePlugin(unpluginFactory);
336340
336357
  export {
336341
336358
  dtsComplex as d
336342
336359
  };
336343
- //# sourceMappingURL=index-Crhrknhq.mjs.map
336360
+ //# sourceMappingURL=index-D70JB0pM.mjs.map