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

Support publishing to registry with an importmap #3

Closed
dsherret opened this issue Sep 24, 2021 · 6 comments
Closed

Support publishing to registry with an importmap #3

dsherret opened this issue Sep 24, 2021 · 6 comments

Comments

@dsherret
Copy link
Member

dsherret commented Sep 24, 2021

It might be useful for people to publish to the registry with the import map unfurled.

For example, say the module has an import map like so:

{
   "imports": {
      "fmt/": "https://deno.land/std@0.108.0/fmt/"
   }
}

And a TypeScript file like so:

import { red } from "fmt/colors.ts";

console.log(red("hello world"));

The user would be able to somehow specify "here's the import map to use for my module" to the registry (edit: nowadays, probably automatically resolved from deno.json/jsonc or perhaps this could be a GH action build step) and it would be published to the registry as:

import { red } from "https://deno.land/std@0.108.0/fmt/colors.ts";

console.log(red("hello world"));
@crowlKats crowlKats changed the title Ability to specify import map for a module support resolving imports in module with importmap Jan 8, 2023
@crowlKats crowlKats transferred this issue from denoland/deno_registry2 Jan 8, 2023
@dsherret dsherret changed the title support resolving imports in module with importmap Support resolving imports in module with importmap Jan 22, 2023
@dsherret dsherret changed the title Support resolving imports in module with importmap Support publishing to registry with an importmap Jan 22, 2023
@albnnc
Copy link

albnnc commented Jan 22, 2023

Does this mean that every **/*.{ts,tsx,js,tsx} file located in repo is going to be transformed?

Corner case

Suppose me creating something like framework that is going to have a project init script. This script is going to copy some *.ts files which actually use entries from import map, that is also going to be copied during user project creation.

This means that in that particular case only a subset of **/*.{ts,tsx,js,jsx} files should be transformed. How is this going to be handled?

@aapoalas
Copy link

Would it rather make sense to provide an unfurling script?

@dsherret
Copy link
Member Author

Would it rather make sense to provide an unfurling script?

@aapoalas Yes, I think ideally it would be a separate script that runs as part of a GitHub action step. This allows people to give the registry the exact code they want it to serve.

Suppose me creating something like framework that is going to have a project init script. This script is going to copy some *.ts files which actually use entries from import map, that is also going to be copied during user project creation.

This means that in that particular case only a subset of **/*.{ts,tsx,js,jsx} files should be transformed. How is this going to be handled?

@albnnc normally for project init scripts people don't copy over straight files, but instead things are generated because there will be some conditionals. So generally, people would do a straight copy of a file to another file. That said, there would be ways around this such as using the github action with this setting turned off, saving the template file with another extension, or using different import map entries in the module compared to the user's import map.

@harrysolovay
Copy link

I'm wondering if the solution here may also apply to the following:

Let's say that a given lib contains an example/a.ts.

It would be nice for potential users to be able to interact with this example without needing to clone the project. Aka.

deno run -A https://deno.land/x/<the-project>/examples/a.ts

If, however, examples/a.ts uses an import-mapped specifier, then the potential user must also specify the import map.

deno run -A https://deno.land/x/<the-project>/examples/a.ts \
  --import-map=https://deno.land/x/<the-project>/import_map.json

This is unfortunate. Any ideas on how to enable the first, simpler example run command?

@idranme
Copy link

idranme commented Jun 17, 2023

Good idea.

@dsherret
Copy link
Member Author

dsherret commented Mar 2, 2024

No longer relevant with the release of https://jsr.io

This now happens automatically on deno publish

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants