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

feat(cli): allow import maps from url #5849

Closed
wants to merge 2 commits into from

Conversation

futurist
Copy link

@futurist futurist commented May 25, 2020

This PR should resolved #5522 .

One thing related to the cache, the import map file has the same behavior with module files.

@CLAassistant
Copy link

CLAassistant commented May 25, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@futurist
Copy link
Author

futurist commented May 26, 2020

The tests of last commit shows a pending problem:

how to calculate the base_url of "scopes" in importmap?

The ignored test _033_import_map_http_local_entry will fail, let's see why:

Currently the base_url is from importmap arg,

See:

The URL of the import map is the base URL for its values.

ImportMap::from_json(&file_url, &json_string).map_err(ErrBox::from)

So the below command:

$ deno run --quiet --reload --allow-net \
     --importmap=http://127.0.0.1:4545/cli/tests/importmaps/import_map.json \
     --unstable importmaps/test.ts

The content of test.ts:

......
import "./scope/scoped.ts";

produces the scope url of ./scope/scoped.ts from importmap view:

http://127.0.0.1:4545/cli/tests/importmaps/scope/scoped.ts

but in the test.ts file's view, the url of scope/scoped.ts has file:// schema, just like a local file, which doesn't match the scope of importmap above, thus the "scopes" rule in import_map.json omitted.

I think this should be think carefully and decide the right algorithm.

Or, the test ignored should be really ignored and keep the current algorithm?

@bartlomieju bartlomieju added cli related to cli/ dir feat new feature (which has been agreed to/accepted) labels May 26, 2020
@bartlomieju
Copy link
Member

Thanks for opening the PR @futurist.

The tests of last commit shows a pending problem:

how to calculate the base_url of "scopes" in importmap?

This indeed sounds like a bug, we should fix it by following spec proposal. I've written import map support last year and since it hasn't received much attention. Can you take a stab at fixing this problem?

Please merge with latest master

@ry
Copy link
Member

ry commented Aug 18, 2020

@futurist Thanks for this patch - sorry it never got merged. I'm closing this because it's stale.

In general we are not convinced that import maps really solve any problems and we're considering removing them entirely. This explains why this well-implemented patch was not reviewed - we're hesitating on any features related to import maps. I apologize for not communicating that.

In any case, the feature seems reasonable. I am open to adding this feature if you really want it. Just with the understanding that import-maps remains unstable and it could very likely get cut. Hit me up on discord if you want to talk about it.

@ry ry closed this Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow import maps from url
4 participants