urlToRequire() — vue Function Reference
Architecture documentation for the urlToRequire() function in utils.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 084fbb63_6e20_b1c4_c59e_540beed57a4e["urlToRequire()"] 2347b93b_5b26_2b27_6743_fe5fed353eb5["utils.ts"] 084fbb63_6e20_b1c4_c59e_540beed57a4e -->|defined in| 2347b93b_5b26_2b27_6743_fe5fed353eb5 0ff97342_1187_94f6_a64b_18bb0f56b2df["rewrite()"] 0ff97342_1187_94f6_a64b_18bb0f56b2df -->|calls| 084fbb63_6e20_b1c4_c59e_540beed57a4e 0f70d60f_22b7_52fe_ab25_711c3bc297a9["transform()"] 0f70d60f_22b7_52fe_ab25_711c3bc297a9 -->|calls| 084fbb63_6e20_b1c4_c59e_540beed57a4e 17510187_440b_3fab_53f7_36556a367e46["isExternalUrl()"] 084fbb63_6e20_b1c4_c59e_540beed57a4e -->|calls| 17510187_440b_3fab_53f7_36556a367e46 f1adee7c_8bef_1ecd_92ce_69050ab13ec8["isDataUrl()"] 084fbb63_6e20_b1c4_c59e_540beed57a4e -->|calls| f1adee7c_8bef_1ecd_92ce_69050ab13ec8 9556aec6_39da_eb46_c422_a9b26289b1d6["parseUriParts()"] 084fbb63_6e20_b1c4_c59e_540beed57a4e -->|calls| 9556aec6_39da_eb46_c422_a9b26289b1d6 style 084fbb63_6e20_b1c4_c59e_540beed57a4e 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, defined in packages/compiler-sfc/src/templateCompilerModules/utils.ts.
Where is urlToRequire() defined?
urlToRequire() is defined in packages/compiler-sfc/src/templateCompilerModules/utils.ts at line 5.
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