Skip to content

Commit

Permalink
fix: infinite loop error replace_type_placeholder (#223)
Browse files Browse the repository at this point in the history
* Add global flag

* Add changeset
  • Loading branch information
PuruVJ committed Sep 13, 2023
1 parent 2952ea3 commit a1f2c5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-cars-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/site-kit': patch
---

fix: infinite loop error replace_type_placeholder
3 changes: 1 addition & 2 deletions packages/site-kit/src/lib/markdown/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export async function replace_export_type_placeholders(content, modules) {
EXPANDED_TYPES: /> EXPANDED_TYPES: (.+?)#(.+)$/gm,
TYPES: /> TYPES: (.+?)(?:#(.+))?$/gm,
EXPORT_SNIPPET: /> EXPORT_SNIPPET: (.+?)#(.+)?$/gm,
MODULES: /> MODULES/,
MODULES: /> MODULES/g, //! /g is VERY IMPORTANT, OR WILL CAUSE INFINITE LOOP
EXPORTS: /> EXPORTS: (.+)/
};

Expand All @@ -531,7 +531,6 @@ export async function replace_export_type_placeholders(content, modules) {
.replace(REGEXES.MODULES, '')
.replace(REGEXES.EXPORTS, '');
}

content = await async_replace(content, REGEXES.EXPANDED_TYPES, async ([_, name, id]) => {
const module = modules.find((module) => module.name === name);
if (!module) throw new Error(`Could not find module ${name}`);
Expand Down

0 comments on commit a1f2c5b

Please sign in to comment.