-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module.system.node.root_relative_dirname
lets you configure where r…
…oot relative paths resolve to Summary: When we see ``` [options] module.system.node.allow_root_relative=true module.system.node.root_relative_dirname=first module.system.node.root_relative_dirname=second ``` Then we'll resolve `import foo from 'path/to/foo'` 1. First in `<PROJECT_ROOT>/first/path/to/foo.js` 2. Second in `<PROJECT_ROOT>/second/path/to/foo.js` 3. Third in node_modules. Reviewed By: jbrown215 Differential Revision: D18234623 fbshipit-source-id: f569e599a9fb0191ba959cda89166ab1b77fd758
- Loading branch information
1 parent
e3f2902
commit d17ed03
Showing
26 changed files
with
309 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/.flowconfig
This file contains 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,4 @@ | ||
[options] | ||
module.system.node.allow_root_relative=true | ||
module.system.node.root_relative_dirname=first | ||
module.system.node.root_relative_dirname=second |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "user_code" = "user_code"; | ||
export default value; |
156 changes: 156 additions & 0 deletions
156
...e_system_node_root_relative_dirnames/config_module_system_node_root_relative_dirnames.exp
This file contains 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,156 @@ | ||
Error ----------------------------------------------------------------------------------------------------- test.js:16:2 | ||
|
||
Cannot cast `ambiguous` to empty because string literal `first_user_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:16:2 | ||
16| (ambiguous: empty) | ||
^^^^^^^^^ | ||
|
||
References: | ||
first/ambiguous.js:3:14 | ||
3| const value: "first_user_code" = "first_user_code"; | ||
^^^^^^^^^^^^^^^^^ [1] | ||
test.js:16:13 | ||
16| (ambiguous: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:19:2 | ||
|
||
Cannot cast `sub_ambiguous` to empty because string literal `first_user_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:19:2 | ||
19| (sub_ambiguous: empty) | ||
^^^^^^^^^^^^^ | ||
|
||
References: | ||
first/subdir/ambiguous.js:3:14 | ||
3| const value: "first_user_code" = "first_user_code"; | ||
^^^^^^^^^^^^^^^^^ [1] | ||
test.js:19:17 | ||
19| (sub_ambiguous: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:23:2 | ||
|
||
Cannot cast `user_code` to empty because string literal `first_user_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:23:2 | ||
23| (user_code: empty) | ||
^^^^^^^^^ | ||
|
||
References: | ||
first/user_code.js:3:14 | ||
3| const value: "first_user_code" = "first_user_code"; | ||
^^^^^^^^^^^^^^^^^ [1] | ||
test.js:23:13 | ||
23| (user_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:26:2 | ||
|
||
Cannot cast `sub_user_code` to empty because string literal `first_user_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:26:2 | ||
26| (sub_user_code: empty) | ||
^^^^^^^^^^^^^ | ||
|
||
References: | ||
first/subdir/user_code.js:3:14 | ||
3| const value: "first_user_code" = "first_user_code"; | ||
^^^^^^^^^^^^^^^^^ [1] | ||
test.js:26:17 | ||
26| (sub_user_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:30:2 | ||
|
||
Cannot cast `second_only_user_code` to empty because string literal `second_only_user_code` [1] is incompatible with | ||
empty [2]. | ||
|
||
test.js:30:2 | ||
30| (second_only_user_code: empty) | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
References: | ||
second/second_only_user_code.js:3:14 | ||
3| const value: "second_only_user_code" = "second_only_user_code"; | ||
^^^^^^^^^^^^^^^^^^^^^^^ [1] | ||
test.js:30:25 | ||
30| (second_only_user_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:33:2 | ||
|
||
Cannot cast `sub_second_only_user_code` to empty because string literal `second_only_user_code` [1] is incompatible with | ||
empty [2]. | ||
|
||
test.js:33:2 | ||
33| (sub_second_only_user_code: empty) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
References: | ||
second/subdir/second_only_user_code.js:3:14 | ||
3| const value: "second_only_user_code" = "second_only_user_code"; | ||
^^^^^^^^^^^^^^^^^^^^^^^ [1] | ||
test.js:33:29 | ||
33| (sub_second_only_user_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:37:2 | ||
|
||
Cannot cast `node_code` to empty because string literal `node_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:37:2 | ||
37| (node_code: empty) | ||
^^^^^^^^^ | ||
|
||
References: | ||
node_modules/node_code.js:3:14 | ||
3| const value: "node_code" = "node_code"; | ||
^^^^^^^^^^^ [1] | ||
test.js:37:13 | ||
37| (node_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------------- test.js:40:2 | ||
|
||
Cannot cast `sub_node_code` to empty because string literal `node_code` [1] is incompatible with empty [2]. | ||
|
||
test.js:40:2 | ||
40| (sub_node_code: empty) | ||
^^^^^^^^^^^^^ | ||
|
||
References: | ||
node_modules/subdir/node_code.js:3:14 | ||
3| const value: "node_code" = "node_code"; | ||
^^^^^^^^^^^ [1] | ||
test.js:40:17 | ||
40| (sub_node_code: empty) | ||
^^^^^ [2] | ||
|
||
|
||
Error ---------------------------------------------------------------------------------------------------- test.js:43:25 | ||
|
||
Cannot resolve module `nonexistent`. | ||
|
||
43| import nonexistent from 'nonexistent' | ||
^^^^^^^^^^^^^ | ||
|
||
|
||
Error ---------------------------------------------------------------------------------------------------- test.js:44:29 | ||
|
||
Cannot resolve module `subdir/nonexistent`. | ||
|
||
44| import sub_nonexistent from 'subdir/nonexistent' | ||
^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
||
|
||
Found 10 errors |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/first/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "first_user_code" = "first_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/first/subdir/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "first_user_code" = "first_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/first/subdir/user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "first_user_code" = "first_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/first/user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "first_user_code" = "first_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/node_modules/ambiguous.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/node_modules/node_code.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/node_modules/subdir/ambiguous.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/node_modules/subdir/node_code.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/second/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_user_code" = "second_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/second/second_only_user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_only_user_code" = "second_only_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/second/subdir/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_user_code" = "second_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
...s/config_module_system_node_root_relative_dirnames/second/subdir/second_only_user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_only_user_code" = "second_only_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/second/subdir/user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_user_code" = "second_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/second/user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "second_user_code" = "second_user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/subdir/ambiguous.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "user_code" = "user_code"; | ||
export default value; |
4 changes: 4 additions & 0 deletions
4
tests/config_module_system_node_root_relative_dirnames/subdir/user_code.js
This file contains 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,4 @@ | ||
// @flow | ||
|
||
const value: "user_code" = "user_code"; | ||
export default value; |
44 changes: 44 additions & 0 deletions
44
tests/config_module_system_node_root_relative_dirnames/test.js
This file contains 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,44 @@ | ||
// @flow | ||
|
||
/** | ||
* 1) All "ambiguous" code exists in first/, second/ and node_modules/. | ||
* first/ wins | ||
* 2) All "user_code" code exists in first/ and second/ | ||
* first/ wins | ||
* 3) All "second_only" code exists only in second/ | ||
* second/ wins | ||
* 4) All "node_code" code exists in only node_modules/ | ||
* node_modules/ wins | ||
*/ | ||
|
||
// These exist in both user code and node_modules, but user code wins | ||
import ambiguous from 'ambiguous'; | ||
(ambiguous: empty) | ||
|
||
import sub_ambiguous from 'subdir/ambiguous'; | ||
(sub_ambiguous: empty) | ||
|
||
// These exist in only user code | ||
import user_code from 'user_code'; | ||
(user_code: empty) | ||
|
||
import sub_user_code from 'subdir/user_code'; | ||
(sub_user_code: empty) | ||
|
||
// These exist in only user code, and only in second/ | ||
import second_only_user_code from 'second_only_user_code'; | ||
(second_only_user_code: empty) | ||
|
||
import sub_second_only_user_code from 'subdir/second_only_user_code'; | ||
(sub_second_only_user_code: empty) | ||
|
||
// These exist in only node code | ||
import node_code from 'node_code'; | ||
(node_code: empty) | ||
|
||
import sub_node_code from 'subdir/node_code'; | ||
(sub_node_code: empty) | ||
|
||
// These exist nowhere | ||
import nonexistent from 'nonexistent' | ||
import sub_nonexistent from 'subdir/nonexistent' |
Oops, something went wrong.