Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Exploration of JSR type aquisition #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
`,
Comment on lines +165 to +169
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With fresh eyes I see the very obvious flaw here: The imported code has relative imports that won't exist in the context of this module. So anything defined and available in the actual code itself will appear fine, but anything imported from another file will fallback to being any.

So it does need to be a re-export of some sort but so far I've been unable to get that to work in most contexts.

);
}

Expand Down