MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / rewriteSpecifiers

Function rewriteSpecifiers

packages/core/scripts/rewrite-esm-extensions.ts:45–59  ·  view source on GitHub ↗
(filePath: string, source: string)

Source from the content-addressed store, hash-verified

43}
44
45function rewriteSpecifiers(filePath: string, source: string): string {
46 const patterns = [
47 /(from\s+["'])(\.\.?\/[^"']+)(["'])/g,
48 /(import\s+["'])(\.\.?\/[^"']+)(["'])/g,
49 /(import\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g,
50 ];
51
52 return patterns.reduce(
53 (nextSource, pattern) =>
54 nextSource.replace(pattern, (_match, prefix: string, specifier: string, suffix: string) => {
55 return `${prefix}${resolveRuntimeSpecifier(filePath, specifier)}${suffix}`;
56 }),
57 source,
58 );
59}
60
61let changed = 0;
62for (const filePath of listJavaScriptFiles(distDir)) {

Callers 1

Calls 1

resolveRuntimeSpecifierFunction · 0.85

Tested by

no test coverage detected