From a553308ba5e05df312f9a29fa3ff474e9161acdd Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Sun, 13 Oct 2024 23:13:38 -0400 Subject: [PATCH] Try declaring module w/ imported code --- src/index.ts | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/index.ts b/src/index.ts index f055149..0b9bb88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -162,28 +162,11 @@ ${debugLinks debugLinks.push([resolvedUrl.url, redirectedUrl]); typescriptEnvironment.createFile( urlToFilepath(resolvedUrl.url), - - // export * from … doesn't re-export default exports. But we - // want to re-export default exports. So we have turned - // allowSyntheticDefaultImports on, which makes the next - // line of code work, but on the other hand, doesn't _actually_ - // work in Deno because they don't support the option because - // Node.js doesn't support the option in their native ESM - // loading strategy. - // - // So, if we can find a way to essentially "link" or "redirect" - // typescript modules other than this one, let's switch, - // but for now this lets us do a sort of 'transparent' redirect - // from one val to another. - // - // The purpose of this whole redirecting dance is because of relative - // paths: when you import from a url that is a redirect, and the - // code that's at that path uses relative paths, we need to resolve - // those relative paths relative to the final resolved url, not the - // initial one. - // - // https://github.com/denoland/deno/issues/17058 - `export * from '${redirectedUrl}'; import e from '${redirectedUrl}'; export default e;`, + ` + declare module '${importSpecifier}' { + ${importedCode} + } + `, ); }