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

?url and ?raw suffix support #21

Merged
merged 11 commits into from
Aug 20, 2021
Merged

?url and ?raw suffix support #21

merged 11 commits into from
Aug 20, 2021

Conversation

Thy3634
Copy link
Contributor

@Thy3634 Thy3634 commented Jul 21, 2021

Using ?url suffix to explicit URL Imports,
as well as ?raw suffix to import .svg file as string.
#20 by gawlk

Using `?url` suffix  to explicit URL Imports, or `?raw` sudffix to import .svg as string.
@jpkleemans
Copy link
Owner

Thanks @Thy3634
I'll look into it next week

@jpkleemans
Copy link
Owner

@Thy3634 Could you run the linter over your code? npm run lint

@jpkleemans jpkleemans marked this pull request as draft July 29, 2021 09:45
@jpkleemans jpkleemans linked an issue Jul 29, 2021 that may be closed by this pull request
Thy3634 and others added 2 commits July 31, 2021 14:50
@Thy3634
Copy link
Contributor Author

Thy3634 commented Jul 31, 2021

Failed. So I add a submit, and the code could be linted over now.

@jpkleemans
Copy link
Owner

Failed. So I add a submit, and the code could be linted over now.

There are still some lint errors:

index.js:5:36: Missing space before function parentheses.
index.js:12:14: Missing space before function parentheses.
index.js:15:15: Missing space before function parentheses.
index.js:19:38: Strings must use singlequote.
index.js:20:21: Strings must use singlequote.
index.js:22:28: Strings must use singlequote.
index.js:26:20: Missing space before function parentheses.
index.js:30:38: Strings must use singlequote.
index.js:31:21: Strings must use singlequote.
index.js:39:36: Unexpected trailing comma.
index.js:40:11: Extra semicolon.
index.js:41:73: Extra semicolon.

lint again. It should work this time.
@Thy3634
Copy link
Contributor Author

Thy3634 commented Aug 2, 2021

Maybe git ignored something.
I add a commit via github directly. It should work.

Copy link
Owner

@jpkleemans jpkleemans left a comment

Choose a reason for hiding this comment

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

I've placed some comments. Could you review them?

index.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@jpkleemans
Copy link
Owner

Thanks for your changes! I've added 1 comment.

@jpkleemans jpkleemans marked this pull request as ready for review August 20, 2021 08:16
@jpkleemans jpkleemans merged commit a624945 into jpkleemans:main Aug 20, 2021
@jpkleemans
Copy link
Owner

Thanks for your work 👍

@CzBiX
Copy link

CzBiX commented Oct 12, 2021

This PR breaks ?url feature.

@jpkleemans
Copy link
Owner

@CzBiX Could you explain what exactly breaks?

@CzBiX
Copy link

CzBiX commented Oct 12, 2021

@jpkleemans, When I write code like this:

import SvgIcon from 'foobar/demo.svg?url'

console.log(SvgIcon)

It will output the local path of file, like /home/demo/src/demo.svg, which failed to load in browser.

I hacked the code to return void in load and transform if query === 'url', then it works as my expect.

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.

Support ?raw parameter to get the string instead of a component
3 participants