@mintlify/previewing 4.0.814 → 4.0.816

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.
@@ -1,4 +1,4 @@
1
- import { findAndRemoveImports, stringifyTree, topologicalSort, hasImports, optionallyAddLeadingSlash, optionallyRemoveLeadingSlash, } from '@mintlify/common';
1
+ import { findAndRemoveImports, stringifyTree, topologicalSort, hasImports, optionallyAddLeadingSlash, optionallyRemoveLeadingSlash, resolveSnippetImportPath, } from '@mintlify/common';
2
2
  import { outputFile } from 'fs-extra';
3
3
  import { join } from 'path';
4
4
  import { NEXT_PUBLIC_PATH } from '../../constants.js';
@@ -19,7 +19,11 @@ const findAllDependents = async (initialFileWithSlash, allSnippets, processedDat
19
19
  processedData = await findAndRemoveImports(clonedTree);
20
20
  processedDataCache.set(potentialDependentFile, processedData);
21
21
  }
22
- if (processedData.importMap[currentSourceFile]) {
22
+ const importsCurrentFile = Object.keys(processedData.importMap).some((importPath) => {
23
+ const resolvedPath = resolveSnippetImportPath(importPath, potentialDependentFile);
24
+ return resolvedPath === currentSourceFile;
25
+ });
26
+ if (importsCurrentFile) {
23
27
  if (!affected.has(potentialDependentFile)) {
24
28
  affected.add(potentialDependentFile);
25
29
  queue.push(potentialDependentFile);
@@ -61,7 +65,9 @@ export const generateDependentSnippets = async (changedFilename, newImportData)
61
65
  }
62
66
  const graph = {};
63
67
  snippets.forEach((item) => {
64
- graph[item.filename] = Object.keys(item.importMap).map((dep) => optionallyAddLeadingSlash(dep));
68
+ graph[item.filename] = Object.keys(item.importMap)
69
+ .map((dep) => resolveSnippetImportPath(dep, item.filename))
70
+ .filter((resolvedDep) => resolvedDep != null);
65
71
  });
66
72
  const sortedSnippets = topologicalSort(graph).reverse();
67
73
  const snippetsMap = new Map(snippets.map((item) => [item.filename, item]));
@@ -1,4 +1,4 @@
1
- import { findAndRemoveImports, optionallyRemoveLeadingSlash, resolveAllImports, stringifyTree, SNIPPET_EXTENSIONS, } from '@mintlify/common';
1
+ import { findAndRemoveImports, optionallyRemoveLeadingSlash, resolveAllImports, resolveSnippetImportPath, stringifyTree, SNIPPET_EXTENSIONS, } from '@mintlify/common';
2
2
  import { preparseMdxTree, getFileListSync } from '@mintlify/prebuild';
3
3
  import { promises as _promises } from 'fs';
4
4
  import { outputFile } from 'fs-extra';
@@ -17,7 +17,11 @@ export const generatePagesWithImports = async (updatedSnippets) => {
17
17
  try {
18
18
  const tree = await preparseMdxTree(contentStr, CMD_EXEC_PATH, sourcePath);
19
19
  const importsResponse = await findAndRemoveImports(tree);
20
- if (Object.keys(importsResponse.importMap).some((importPath) => updatedSnippets.has(optionallyRemoveLeadingSlash(importPath)))) {
20
+ if (Object.keys(importsResponse.importMap).some((importPath) => {
21
+ const resolvedPath = resolveSnippetImportPath(importPath, pageFilename);
22
+ return (resolvedPath != null &&
23
+ updatedSnippets.has(optionallyRemoveLeadingSlash(resolvedPath)));
24
+ })) {
21
25
  const content = await resolveAllImports({
22
26
  snippets,
23
27
  fileWithImports: { ...importsResponse, filename: pageFilename },