diff --git a/build/WebpackSPDXPlugin.js b/build/WebpackSPDXPlugin.js index eeb338c032c..73c2be2a896 100644 --- a/build/WebpackSPDXPlugin.js +++ b/build/WebpackSPDXPlugin.js @@ -137,13 +137,8 @@ class WebpackSPDXPlugin { .filter((s) => !!s) .map((s) => s.split('?', 2)[0]) - // Skip assets without modules, these are emitted by webpack plugins - if (sources.length === 0) { - logger.warn(`Skipping ${asset} because it does not contain any source information`) - continue - } - - /** packages used by the current asset + /** + * packages used by the current asset * @type {Set} */ const packages = new Set() @@ -198,6 +193,29 @@ class WebpackSPDXPlugin { output += `- ${pkg.name}\n\t- version: ${pkg.version}\n\t- license: ${license}\n` } output = `\n\n${output}` + + if (sources.length === 0) { + logger.info(`Checking content of asset ${asset}`) + const sources = [...modules].map((module) => module.identifier()) + for (const source of sources) { + const match = source.match(/asset\/inline\|data:image\/svg\+xml,(.+)/) + if (match) { + const content = decodeURI(match[1]) + const [, license] = content.match(/SPDX-License-Identifier:\s*([^\s]+)/) ?? [] + const [, author] = content.match(/SPDX-FileCopyrightText:\s*([^-]+)/) ?? [] + if (author && license) { + authors.add(author) + licenses.add(license) + } + } + } + if (authors.size === 0) { + logger.warn(`Asset ${asset} does not contain any source information`) + continue + } + output = '' + } + for (const author of [...authors].sort()) { output = `SPDX-FileCopyrightText: ${author}\n${output}` } diff --git a/dist/7471-7471.js.license b/dist/7471-7471.js.license new file mode 100644 index 00000000000..eef54959ecb --- /dev/null +++ b/dist/7471-7471.js.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: 2020 Google Inc.