licensePlugin() — vite Function Reference
Architecture documentation for the licensePlugin() function in rollupLicensePlugin.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 74b9093c_e915_858a_5cf5_38f75501fe67["licensePlugin()"] 8c8944ff_c444_0ebb_8419_eb691db97f08["rollupLicensePlugin.ts"] 74b9093c_e915_858a_5cf5_38f75501fe67 -->|defined in| 8c8944ff_c444_0ebb_8419_eb691db97f08 66b6f2e4_8712_d179_5d7a_a832e3733280["sortDependencies()"] 74b9093c_e915_858a_5cf5_38f75501fe67 -->|calls| 66b6f2e4_8712_d179_5d7a_a832e3733280 4cea9080_1c4b_baeb_7923_fa9e862e8153["sortLicenses()"] 74b9093c_e915_858a_5cf5_38f75501fe67 -->|calls| 4cea9080_1c4b_baeb_7923_fa9e862e8153 98fcdafd_b9c2_b494_7b17_6cf19b372f35["getDependencyInformation()"] 74b9093c_e915_858a_5cf5_38f75501fe67 -->|calls| 98fcdafd_b9c2_b494_7b17_6cf19b372f35 style 74b9093c_e915_858a_5cf5_38f75501fe67 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/rollupLicensePlugin.ts lines 7–127
export default function licensePlugin(
licenseFilePath: string,
licenseTitle: string,
packageName: string,
additionalSection?: string,
): Plugin {
const originalPlugin = license({
thirdParty(dependencies) {
// https://github.com/rollup/rollup/blob/master/build-plugins/generate-license-file.js
// MIT Licensed https://github.com/rollup/rollup/blob/master/LICENSE-CORE.md
const coreLicense = fs.readFileSync(
new URL('../../LICENSE', import.meta.url),
)
const deps = sortDependencies(dependencies)
const licenses = sortLicenses(
new Set(
dependencies.map((dep) => dep.license).filter(Boolean) as string[],
),
)
let dependencyLicenseTexts = ''
for (let i = 0; i < deps.length; i++) {
// Find dependencies with the same license text so it can be shared
const licenseText = deps[i].licenseText
const sameDeps = [deps[i]]
if (licenseText) {
for (let j = i + 1; j < deps.length; j++) {
if (licenseText === deps[j].licenseText) {
sameDeps.push(...deps.splice(j, 1))
j--
}
}
}
let text = `## ${sameDeps.map((d) => d.name).join(', ')}\n`
const depInfos = sameDeps.map((d) => getDependencyInformation(d))
// If all same dependencies have the same license and contributor names, show them only once
if (
depInfos.length > 1 &&
depInfos.every(
(info) =>
info.license === depInfos[0].license &&
info.names === depInfos[0].names,
)
) {
const { license, names } = depInfos[0]
const repositoryText = depInfos
.map((info) => info.repository)
.filter(Boolean)
.join(', ')
if (license) text += `License: ${license}\n`
if (names) text += `By: ${names}\n`
if (repositoryText) text += `Repositories: ${repositoryText}\n`
}
// Else show each dependency separately
else {
for (let j = 0; j < depInfos.length; j++) {
const { license, names, repository } = depInfos[j]
if (license) text += `License: ${license}\n`
if (names) text += `By: ${names}\n`
if (repository) text += `Repository: ${repository}\n`
if (j !== depInfos.length - 1) text += '\n'
}
}
if (licenseText) {
text +=
'\n' +
licenseText
.trim()
.replace(/\r\n|\r/g, '\n')
.split('\n')
.map((line) => `> ${line}`)
.join('\n') +
'\n'
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does licensePlugin() do?
licensePlugin() is a function in the vite codebase, defined in packages/vite/rollupLicensePlugin.ts.
Where is licensePlugin() defined?
licensePlugin() is defined in packages/vite/rollupLicensePlugin.ts at line 7.
What does licensePlugin() call?
licensePlugin() calls 3 function(s): getDependencyInformation, sortDependencies, sortLicenses.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free