Make webpack respect dependencies vs peerDependencies when deciding dependency is external (#7545)

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2023-04-13 16:01:43 +03:00
1 parent adf67fb6a7
commit 7dc0ce7192
19 files changed
+231 -44

No files matched your search

@@ -0,0 +1,3 @@
const toModuleMatcherRegExp = x => new RegExp(`^${x}(/.*)*$`);
module.exports = { toModuleMatcherRegExp };
@@ -0,0 +1,57 @@
import { toModuleMatcherRegExp } from "./to-module-matcher-reg-exp";
describe('to-module-matcher-reg-exp', () => {
let regExp;
beforeEach(() => {
regExp = toModuleMatcherRegExp("some-package");
});
it('given exactly matching package, matches', () => {
const targetString = 'some-package';
const [match] = targetString.match(regExp);
expect(match).toBeTruthy()
});
it('given matching package with entrypoint, matches', () => {
const targetString = 'some-package/some-entrypoint';
const [match] = targetString.match(regExp);
expect(match).toBeTruthy()
});
it('given matching package with directory, matches', () => {
const targetString = 'some-package/some-directory/some-other-directory';
const [match] = targetString.match(regExp);
expect(match).toBeTruthy()
});
it('given package that starts with same name but is still different, does not match', () => {
const targetString = 'some-package-but-still-different';
const actual = targetString.match(regExp);
expect(actual).toBeNull()
});
it('given package that starts with something else, does not match', () => {
const targetString = 'different-some-package';
const actual = targetString.match(regExp);
expect(actual).toBeNull()
});
it('given irrelevant package, does not match', () => {
const targetString = 'some-other-package';
const actual = targetString.match(regExp);
expect(actual).toBeNull()
});
});