Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,17 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
watch: buildOptions.watch,
watchOptions: {
poll,
// The below is needed as when preserveSymlinks is enabled we disable `resolve.symlinks`.
followSymlinks: buildOptions.preserveSymlinks,
Comment thread
alan-agius4 marked this conversation as resolved.
ignored: poll === undefined ? undefined : '**/node_modules/**',
},
snapshot: {
module: {
// Use hash of content instead of timestamp because the timestamp of the symlink will be used
// instead of the referenced files which causes changes in symlinks not to be picked up.
hash: buildOptions.preserveSymlinks,
},
},
performance: {
hints: false,
},
Expand Down
31 changes: 31 additions & 0 deletions tests/legacy-cli/e2e/tests/build/rebuild-symlink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { symlink } from 'fs/promises';
import { resolve } from 'path';
import { appendToFile, expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
import { execAndWaitForOutputToMatch, waitForAnyProcessOutputToMatch } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

const buildReadyRegEx = /Build at: /;

export default async function () {
await updateJsonFile('angular.json', (configJson) => {
configJson.projects['test-project'].architect.build.options.preserveSymlinks = true;
});

await writeMultipleFiles({
'src/link-source.ts': '// empty file',
'src/main.ts': `import './link-dest';`,
});

await symlink(resolve('src/link-source.ts'), resolve('src/link-dest.ts'));

await execAndWaitForOutputToMatch(
'ng',
['build', '--watch', '--configuration=development'],
buildReadyRegEx,
);

// Trigger a rebuild
await appendToFile('src/link-source.ts', `console.log('foo-bar');`);
await waitForAnyProcessOutputToMatch(buildReadyRegEx);
await expectFileToMatch('dist/test-project/main.js', `console.log('foo-bar')`);
}