From 8340e97c45a1a1a1606307a641f3ba0104c5a8cc Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 17 Nov 2020 15:06:09 +0100 Subject: [PATCH] getPackagePath: handle node packages not containing any source as is the case with font packages --- rollup.utils.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rollup.utils.js b/rollup.utils.js index 634b82d1..b3b2aa19 100644 --- a/rollup.utils.js +++ b/rollup.utils.js @@ -21,8 +21,15 @@ export function getBuildInfo(build) { export async function getPackagePath(packageName, assetPath) { const r = resolve(); - const id = (await r.resolveId(packageName)).id; - const packageInfo = r.getPackageInfoForId(id); - const fullAssetPath = path.join(packageInfo.root, assetPath); - return path.relative(process.cwd(), fullAssetPath); + const resolved = await r.resolveId(packageName); + let packageRoot; + if (resolved !== null) { + const id = (await r.resolveId(packageName)).id; + const packageInfo = r.getPackageInfoForId(id); + packageRoot = packageInfo.root; + } else { + // Non JS packages + packageRoot = path.dirname(require.resolve(packageName + '/package.json')); + } + return path.relative(process.cwd(), path.join(packageRoot, assetPath)); } \ No newline at end of file -- GitLab