urlToRequire() — vue Function Reference
Architecture documentation for the urlToRequire() function in utils.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 90eed22c_58dc_8abb_a418_7c84bdd13880["urlToRequire()"] 86cee8da_2433_7225_4bc4_522e812617bc["rewrite()"] 86cee8da_2433_7225_4bc4_522e812617bc -->|calls| 90eed22c_58dc_8abb_a418_7c84bdd13880 9806d4c8_1f8b_eef1_02b1_ca958f0b0e01["transform()"] 9806d4c8_1f8b_eef1_02b1_ca958f0b0e01 -->|calls| 90eed22c_58dc_8abb_a418_7c84bdd13880 dbfae07d_383d_6378_1fbb_d8556299500c["isExternalUrl()"] 90eed22c_58dc_8abb_a418_7c84bdd13880 -->|calls| dbfae07d_383d_6378_1fbb_d8556299500c 33610561_437a_0371_2456_d0e9c21eb62b["isDataUrl()"] 90eed22c_58dc_8abb_a418_7c84bdd13880 -->|calls| 33610561_437a_0371_2456_d0e9c21eb62b 31b20170_507e_c5fb_e49a_f50a0fbff272["parseUriParts()"] 90eed22c_58dc_8abb_a418_7c84bdd13880 -->|calls| 31b20170_507e_c5fb_e49a_f50a0fbff272 style 90eed22c_58dc_8abb_a418_7c84bdd13880 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/compiler-sfc/src/templateCompilerModules/utils.ts lines 5–58
export function urlToRequire(
url: string,
transformAssetUrlsOption: TransformAssetUrlsOptions = {}
): string {
const returnValue = `"${url}"`
// same logic as in transform-require.js
const firstChar = url.charAt(0)
if (firstChar === '~') {
const secondChar = url.charAt(1)
url = url.slice(secondChar === '/' ? 2 : 1)
}
if (isExternalUrl(url) || isDataUrl(url) || firstChar === '#') {
return returnValue
}
const uriParts = parseUriParts(url)
if (transformAssetUrlsOption.base) {
// explicit base - directly rewrite the url into absolute url
// does not apply to absolute urls or urls that start with `@`
// since they are aliases
if (firstChar === '.' || firstChar === '~') {
// Allow for full hostnames provided in options.base
const base = parseUriParts(transformAssetUrlsOption.base)
const protocol = base.protocol || ''
const host = base.host ? protocol + '//' + base.host : ''
const basePath = base.path || '/'
// when packaged in the browser, path will be using the posix-
// only version provided by rollup-plugin-node-builtins.
return `"${host}${(path.posix || path).join(
basePath,
uriParts.path + (uriParts.hash || '')
)}"`
}
}
if (
transformAssetUrlsOption.includeAbsolute ||
firstChar === '.' ||
firstChar === '~' ||
firstChar === '@'
) {
if (!uriParts.hash) {
return `require("${url}")`
} else {
// support uri fragment case by excluding it from
// the require and instead appending it as string;
// assuming that the path part is sufficient according to
// the above caseing(t.i. no protocol-auth-host parts expected)
return `require("${uriParts.path}") + "${uriParts.hash}"`
}
}
return returnValue
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does urlToRequire() do?
urlToRequire() is a function in the vue codebase.
What does urlToRequire() call?
urlToRequire() calls 3 function(s): isDataUrl, isExternalUrl, parseUriParts.
What calls urlToRequire()?
urlToRequire() is called by 2 function(s): rewrite, transform.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free