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

fix: import maps does not work on local files #159

Merged
merged 2 commits into from
Jan 9, 2022

Conversation

aiotter
Copy link
Contributor

@aiotter aiotter commented Jan 7, 2022

When you specify a local file as an import map, Lume raises an error even when the specified file is a valid import map.

$ lume --serve -- --import-map=./import_map.json
Error: Unable to load the import map file
- mapFile: ./import_map.json
    at getImportMap (https://deno.land/x/lume@v1.4.1/ci.ts:53:13)
    at async getArgs (https://deno.land/x/lume@v1.4.1/ci.ts:95:33)
    at async main (https://deno.land/x/lume@v1.4.1/ci.ts:103:32)
    at async (https://deno.land/x/lume@v1.4.1/cli.ts:150:5)

Caused by TypeError: Invalid URL
    at Object.opSync (deno:core/01_core.js:149:12)
    at opUrlParse (deno:ext/url/00_url.js:47:27)
    at new URL (deno:ext/url/00_url.js:320:20)
    at new Request (deno:ext/fetch/23_request.js:241:27)
    at (deno:ext/fetch/26_fetch.js:396:29)
    at fetch (deno:ext/fetch/26_fetch.js:392:12)
    at getImportMap (https://deno.land/x/lume@v1.4.1/ci.ts:48:33)
    at getArgs (https://deno.land/x/lume@v1.4.1/ci.ts:95:39)
    at main (https://deno.land/x/lume@v1.4.1/ci.ts:103:38)

This PR resolves this.

@oscarotero
Copy link
Member

Nice!
Just one comment: maybe it's better to use toFileUrl function of the std library: https://deno.land/std@0.120.0/path#tofileurl. It looks more stronger and it can handle paths on Windows environment.

@aiotter
Copy link
Contributor Author

aiotter commented Jan 7, 2022

Wow, that's handy. I'll update the code tomorrow.

@aiotter
Copy link
Contributor Author

aiotter commented Jan 9, 2022

Updated!
I have no windows environment so I couldn't test it on windows. On macOS it works properly.

@oscarotero oscarotero merged commit 5f0d950 into lumeland:master Jan 9, 2022
@oscarotero
Copy link
Member

Perfect. Thank you!

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

Successfully merging this pull request may close these issues.

2 participants