Skip to content

[patch] ci: fix dedupe-duplicate-modules flakes #18007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
Merged
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
42 changes: 24 additions & 18 deletions tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

export default async function () {
// Force duplicate modules
await updateJsonFile('package.json', json => {
json.dependencies = {
...json.dependencies,
'tslib': '2.0.0',
'tslib-1': 'npm:[email protected]',
'tslib-1-copy': 'npm:[email protected]',
};
});
// Force duplicate modules
await updateJsonFile('package.json', json => {
json.dependencies = {
...json.dependencies,
'tslib': '2.0.0',
'tslib-1': 'npm:[email protected]',
'tslib-1-copy': 'npm:[email protected]',
};
});

await silentNpm('install');
await silentNpm('install');

await writeFile('./src/main.ts',
`
await writeFile('./src/main.ts',
`
import { __assign as __assign_0 } from 'tslib';
import { __assign as __assign_1 } from 'tslib-1';
import { __assign as __assign_2 } from 'tslib-1-copy';
Expand All @@ -29,13 +29,19 @@ export default async function () {
})
`);

const { stderr } = await ng('build', '--verbose', '--no-vendor-chunk', '--no-progress');
if (!/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy -> .+tslib-1/.test(stderr)) {
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
}
const { stderr } = await ng('build', '--verbose', '--no-vendor-chunk', '--no-progress');
const outFile = 'dist/test-project/main.js';

const outFile = 'dist/test-project/main.js';
await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy -> .+tslib-1/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js');
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'));
} else if (/\[DedupeModuleResolvePlugin\]:.+tslib-1 -> .+tslib-1-copy/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js');
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js'));
} else {
console.error(`\n\n\n${stderr}\n\n\n`);
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
}

await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
}