-
Notifications
You must be signed in to change notification settings - Fork 693
feat: add require.context support
#822
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
Closed
EvanBacon
wants to merge
43
commits into
react:main
from
EvanBacon:@evanbacon/require-context/resolve-file-paths
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
d37ca65
feat: add `resolveContext` method for matching files
EvanBacon faf5df7
Apply suggestions from code review
EvanBacon 87bf0af
Update HasteFS.js
EvanBacon 0d59e7f
Update HasteFS.js
EvanBacon 5852acb
Add require context changes
EvanBacon 12fcb4c
Merge branch 'main' into @evanbacon/require-context/resolve-file-paths
EvanBacon 360ee19
Add all require.context changes
EvanBacon f9a84b0
Merge branch 'main' into @evanbacon/require-context/resolve-file-paths
EvanBacon 7b78806
pr feedback
EvanBacon 1b807f3
Move buffer sha upstream
EvanBacon 797a92c
fix types
EvanBacon 6f795ac
fix lint
EvanBacon 0cd6a1f
normalize matching file patterns
EvanBacon b8336fd
fix lint
EvanBacon 645443b
revert changes
EvanBacon 6e25851
fix tests
EvanBacon ec0ac71
move sha1 back up
EvanBacon 2b59675
rename function
EvanBacon 182b4e8
Update Transformer-test.js
EvanBacon 2baf25d
restructure to use privateState
EvanBacon 5f110e6
added tests
EvanBacon 063e99a
Update traverseDependencies-test.js
EvanBacon 4b965fb
resolvedContexts
EvanBacon 56c6a66
Update graphOperations.js
EvanBacon 9d469a5
Overhaul traverseDependencies tests, some API/behaviour changes
motiz88 b88384a
Merge branch '@evanbacon/require-context/resolve-file-paths' of https…
motiz88 c66d112
Fix getTransformFn after absolute path change
motiz88 7e4308e
Add require.context integration test
motiz88 0795f6c
Make order of keys in context module deterministic
motiz88 ec46ce0
Add integration test for require and context with the same first arg
motiz88 2550dc8
Remove contextParams from Module type and processModule args
motiz88 d96a3bc
Tighten incremental edge cases + add more tests
motiz88 e05634f
Fix order sensitive test snapshot
motiz88 a7dd372
Add some line breaks to context module template
motiz88 7600f9e
Merge remote-tracking branch 'upstream/main' into @evanbacon/require-…
motiz88 6bf2b5a
Fix up types post Flow upgrade
motiz88 4aae435
id --> debugId, add tests
motiz88 2172d42
Remove debugId, getContextModuleId
motiz88 612562c
Rewrite DeltaCalculator context tests and fix bugs
motiz88 6404eb0
Light cleanup + file header fixes
motiz88 6833b44
Update HasteFS.js
EvanBacon 49b97a3
PR Feedback
EvanBacon fbaf8bb
Merge branch 'main' into @evanbacon/require-context/resolve-file-paths
motiz88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @flow strict-local | ||
| * @format | ||
| */ | ||
|
|
||
| import HasteFS from '../HasteFS'; | ||
|
|
||
| jest.mock('../lib/fast_path', () => ({ | ||
| resolve: (a, b) => b, | ||
| relative: jest.requireActual('path').relative, | ||
| })); | ||
|
|
||
| describe('matchFilesWithContext', () => { | ||
| it(`matches files against context`, () => { | ||
| const hfs = new HasteFS({ | ||
| rootDir: '/', | ||
| files: new Map([ | ||
| [ | ||
| '/foo/another.js', | ||
| // $FlowFixMe: mocking files | ||
| {}, | ||
| ], | ||
| [ | ||
| '/bar.js', | ||
| // $FlowFixMe: mocking files | ||
| {}, | ||
| ], | ||
| ]), | ||
| }); | ||
|
|
||
| // Test non-recursive skipping deep paths | ||
| expect( | ||
| hfs.matchFilesWithContext('/', { | ||
| filter: new RegExp( | ||
| // Test starting with `./` since this is mandatory for parity with Webpack. | ||
| /^\.\/.*/, | ||
| ), | ||
| recursive: false, | ||
| }), | ||
| ).toEqual(['/bar.js']); | ||
|
|
||
| // Test inner directory | ||
| expect( | ||
| hfs.matchFilesWithContext('/foo', { | ||
| filter: new RegExp(/.*/), | ||
| recursive: true, | ||
| }), | ||
| ).toEqual(['/foo/another.js']); | ||
|
|
||
| // Test recursive | ||
| expect( | ||
| hfs.matchFilesWithContext('/', { | ||
| filter: new RegExp(/.*/), | ||
| recursive: true, | ||
| }), | ||
| ).toEqual(['/foo/another.js', '/bar.js']); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.