Skip to content

Commit

Permalink
fix: changed assets not being copied during watch mode
Browse files Browse the repository at this point in the history
Closes #1826
  • Loading branch information
alan-agius4 committed Jan 15, 2021
1 parent f8ca286 commit 8d6664e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/lib/ng-package/entry-point/write-package.transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ export const writePackageTransform: Transform = transformFromPromise(async graph
for (const file of assetFiles) {
const relativePath = path.relative(ngPackage.src, file);
const destination = path.resolve(ngPackage.dest, relativePath);
entryPoint.dependsOn(new Node(fileUrl(ensureUnixPath(relativePath))));
const nodeUri = fileUrl(ensureUnixPath(file));
let node = graph.get(nodeUri);
if (!node) {
node = new Node(nodeUri);
graph.put(node);
}

entryPoint.dependsOn(node);
await fs.copy(file, destination, { overwrite: true, dereference: true });
}
} catch (error) {
Expand Down
13 changes: 7 additions & 6 deletions src/lib/ng-package/package.transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,21 @@ const watchTransformFactory = (
const { filePath, event } = fileChange;
const { sourcesFileCache, ngccProcessingCache } = cache;
const cachedSourceFile = sourcesFileCache.get(filePath);
const { declarationFileName } = cachedSourceFile || {};
const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));
const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));

ngccProcessingCache.clear();

if (!cachedSourceFile) {
if (event === 'unlink' || event === 'add') {
cache.globCache = regenerateGlobCache(sourcesFileCache);
}
return;
}

const { declarationFileName } = cachedSourceFile;

const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));
const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));
if (!nodesToClean) {
return;
}
}

const allUrlsToClean = new Set<string>(
flatten([
Expand Down

0 comments on commit 8d6664e

Please sign in to comment.