Skip to content
Snippets Groups Projects
Commit 8340e97c authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

getPackagePath: handle node packages not containing any source

as is the case with font packages
parent 96e3a94e
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,15 @@ export function getBuildInfo(build) { ...@@ -21,8 +21,15 @@ export function getBuildInfo(build) {
export async function getPackagePath(packageName, assetPath) { export async function getPackagePath(packageName, assetPath) {
const r = resolve(); const r = resolve();
const id = (await r.resolveId(packageName)).id; const resolved = await r.resolveId(packageName);
const packageInfo = r.getPackageInfoForId(id); let packageRoot;
const fullAssetPath = path.join(packageInfo.root, assetPath); if (resolved !== null) {
return path.relative(process.cwd(), fullAssetPath); 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment