-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat: support .
in exports
field
#11919
Changes from all commits
a982c2c
123c1dd
047c8b9
96ee934
9dfe2f6
ab67dab
c82f084
5c97bf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "__mocks__", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,26 +126,61 @@ describe('findNodeModule', () => { | |
}); | ||
}); | ||
|
||
it('passes packageFilter to the resolve module when using the default resolver', () => { | ||
it('wraps passed packageFilter to the resolve module when using the default resolver', () => { | ||
const packageFilter = jest.fn(); | ||
|
||
// A resolver that delegates to defaultResolver with a packageFilter implementation | ||
userResolver.mockImplementation((request, opts) => | ||
opts.defaultResolver(request, {...opts, packageFilter}), | ||
); | ||
|
||
Resolver.findNodeModule('test', { | ||
basedir: '/', | ||
Resolver.findNodeModule('./test', { | ||
basedir: path.resolve(__dirname, '../__mocks__/'), | ||
resolver: require.resolve('../__mocks__/userResolver'), | ||
}); | ||
|
||
expect(mockResolveSync).toHaveBeenCalledWith( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we now wrap the function, it's not actually passed as is through, so I had to make some changes so |
||
'test', | ||
expect.objectContaining({ | ||
packageFilter, | ||
}), | ||
expect(packageFilter).toHaveBeenCalledWith( | ||
expect.objectContaining({name: '__mocks__'}), | ||
expect.any(String), | ||
); | ||
}); | ||
|
||
describe('conditions', () => { | ||
const conditionsRoot = path.resolve(__dirname, '../__mocks__/conditions'); | ||
|
||
test('resolves without exports, just main', () => { | ||
const result = Resolver.findNodeModule('main', { | ||
basedir: conditionsRoot, | ||
conditions: ['require'], | ||
}); | ||
|
||
expect(result).toEqual( | ||
path.resolve(conditionsRoot, './node_modules/main/file.js'), | ||
); | ||
}); | ||
|
||
test('resolves with import', () => { | ||
const result = Resolver.findNodeModule('import', { | ||
basedir: conditionsRoot, | ||
conditions: ['import'], | ||
}); | ||
|
||
expect(result).toEqual( | ||
path.resolve(conditionsRoot, './node_modules/import/file.js'), | ||
); | ||
}); | ||
|
||
test('resolves with require', () => { | ||
const result = Resolver.findNodeModule('require', { | ||
basedir: conditionsRoot, | ||
conditions: ['require'], | ||
}); | ||
|
||
expect(result).toEqual( | ||
path.resolve(conditionsRoot, './node_modules/require/file.js'), | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('resolveModule', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this anymore as this just tests that the condition
node
,browser
etc of the main entry point are supported, and since we add support to jest itself for the entry point (and the things we test don't have amain
), the rest works.