-
Notifications
You must be signed in to change notification settings - Fork 76
feat: Support uri fragment in transformed require #22
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
Conversation
Just for the records: originally requested on ktsn/vue-template-loader#49 |
lib/templateCompilerModules/utils.ts
Outdated
if(urlString){ | ||
// A TypeError is thrown if urlString is not a string | ||
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost | ||
if('string' === typeof urlString){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urlString
is of type string
. Is this really required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was assuming pure JS library user, so no tsc validation. Defensive.
If not really required, should there be a catch block? Or what's the expected upper error handling concept? Anyone upper expected to log that error?
lib/templateCompilerModules/utils.ts
Outdated
export function urlToRequire (url: string): string { | ||
let returnValue = `"${url}"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer const
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
lib/templateCompilerModules/utils.ts
Outdated
|
||
const uriParts = parseUriParts(url) | ||
|
||
!uriParts.hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use if
block and return
early. Avoid using mutable variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok on if instead of ternary and return early;
not totally sure what is meant with mutable variables; pls comment on next commit
lib/templateCompilerModules/utils.ts
Outdated
function parseUriParts(urlString: string): UrlWithStringQuery{ | ||
// initialize return value | ||
const returnValue : UrlWithStringQuery = uriParse(""); | ||
if(urlString){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the code style is not consistent with the existing code. It seems that we should add a linting tool here. @znck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced double quotes with single quotes, if that is all you have meant
Please make sure to follow existing code style:
|
plus minor spelling correction
plus minor spelling correction
plus minor spelling correction
plus minor spelling correction
Sorry for the merge foxtrot - please squash. |
My case for this PR is a svg within a html based vue component, where i deployed
vue-template-loader
for this usage. In this html i put a svg element as inRoot cause is that the whole href is generated by
component-compiler-utils
and as-is is required by webpack; this must fail because the whole href - including the uri fragment#menu
- is not part of any mapped physical file location of such an svg.