Skip to content

Commit 5593637

Browse files
committed
Fix references adjustment & no-export decorator
1 parent 97c6735 commit 5593637

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/build-entries-and-types/build-types-pure.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function processLines(lines) {
4141
}
4242
if (noExport) return [];
4343
if (options.noExport) {
44-
if (/^[^{]*$/.test(line) || /\{[^}]?\}/.test(line)) return [];
44+
if (/^[^{]*$/.test(line) || /\{[^{}]*\}/.test(line)) return [];
4545
noExport = true;
4646
return [];
4747
}
@@ -164,7 +164,14 @@ export async function preparePureTypes(typesPath, initialPath) {
164164

165165
const content = await readFile(typePath, 'utf8');
166166

167-
const result = content.includes('declare namespace') ? content : wrapInNamespace(content);
167+
const adjustedContent = content.replace(
168+
/(?<open>\/\/\/\s*<reference\s+types=")(?<path>[^"]+)(?<close>"\s*\/>)/g,
169+
(...args) => {
170+
const { open, path, close } = args.at(-1);
171+
return `${ open }../${ path }${ close }`;
172+
},
173+
);
174+
const result = content.includes('declare namespace') ? adjustedContent : wrapInNamespace(content);
168175

169176
await outputFile(resultFilePath, result);
170177
}

0 commit comments

Comments
 (0)