-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add autoResolveMultiImports option (#234)
* feat: add autoResolveMultiImports option * test: add test cases for autoResolveMultiImports option * docs: add for autoResolveMultiImports option
- Loading branch information
1 parent
37fe030
commit 23b3560
Showing
30 changed files
with
219 additions
and
58 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
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
3 changes: 3 additions & 0 deletions
3
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with duplicates/bar.css
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,3 @@ | ||
.a {} | ||
|
||
.b {} |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with duplicates/foo.css
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 @@ | ||
.b {} |
5 changes: 5 additions & 0 deletions
5
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with duplicates/input.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,5 @@ | ||
import './foo.css'; | ||
import './bar.css'; | ||
|
||
<div styleName="a"></div>; | ||
<div styleName="b"></div>; |
12 changes: 12 additions & 0 deletions
12
...xtures/react-css-modules/throws if autoResolveMultipleImport with duplicates/options.json
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,12 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"../../../../src", | ||
{ | ||
"generateScopedName": "[name]__[local]", | ||
"autoResolveMultipleImports": true | ||
} | ||
] | ||
], | ||
"throws": "Cannot resolve styleName \"b\" because it is present in multiple imports:\n\n\t./foo.css\n\t./bar.css\n\nYou can resolve this by using a named import, e.g:\n\n\timport foo from \"./foo.css\";\n\t<div styleName=\"foo.b\" />\n\n" | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with no match/bar.css
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,3 @@ | ||
.a {} | ||
|
||
.b {} |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with no match/foo.css
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 @@ | ||
.b {} |
4 changes: 4 additions & 0 deletions
4
test/fixtures/react-css-modules/throws if autoResolveMultipleImport with no match/input.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 @@ | ||
import './foo.css'; | ||
import './bar.css'; | ||
|
||
<div styleName="c"></div>; |
12 changes: 12 additions & 0 deletions
12
...fixtures/react-css-modules/throws if autoResolveMultipleImport with no match/options.json
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,12 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"../../../../src", | ||
{ | ||
"generateScopedName": "[name]__[local]", | ||
"autoResolveMultipleImports": true | ||
} | ||
] | ||
], | ||
"throws": "Could not resolve the styleName 'c'." | ||
} |
3 changes: 3 additions & 0 deletions
3
...modules/throws if unset autoResolveMultipleImport with multiple anonymous imports/bar.css
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,3 @@ | ||
.a {} | ||
|
||
.b {} |
1 change: 1 addition & 0 deletions
1
...modules/throws if unset autoResolveMultipleImport with multiple anonymous imports/foo.css
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 @@ | ||
.b {} |
4 changes: 4 additions & 0 deletions
4
...odules/throws if unset autoResolveMultipleImport with multiple anonymous imports/input.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 @@ | ||
import './foo.css'; | ||
import './bar.css'; | ||
|
||
<div styleName="a"></div>; |
11 changes: 11 additions & 0 deletions
11
...es/throws if unset autoResolveMultipleImport with multiple anonymous imports/options.json
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,11 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"../../../../src", | ||
{ | ||
"generateScopedName": "[name]__[local]" | ||
} | ||
] | ||
], | ||
"throws": "Cannot use anonymous style name 'a' with more than one stylesheet import without setting 'autoResolveMultipleImports' to true." | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/uses autoResolveMultipleImport no duplicates/bar.css
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 @@ | ||
.a {} |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/uses autoResolveMultipleImport no duplicates/foo.css
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 @@ | ||
.b {} |
5 changes: 5 additions & 0 deletions
5
test/fixtures/react-css-modules/uses autoResolveMultipleImport no duplicates/input.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,5 @@ | ||
import './foo.css'; | ||
import './bar.css'; | ||
|
||
<div styleName="a"></div>; | ||
<div styleName="b"></div>; |
11 changes: 11 additions & 0 deletions
11
test/fixtures/react-css-modules/uses autoResolveMultipleImport no duplicates/options.json
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,11 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"../../../../src", | ||
{ | ||
"generateScopedName": "[name]__[local]", | ||
"autoResolveMultipleImports": true | ||
} | ||
] | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
test/fixtures/react-css-modules/uses autoResolveMultipleImport no duplicates/output.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,8 @@ | ||
"use strict"; | ||
|
||
require("./foo.css"); | ||
|
||
require("./bar.css"); | ||
|
||
<div className="bar__a"></div>; | ||
<div className="foo__b"></div>; |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/uses autoResolveMultipleImport on runtime/bar.css
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 @@ | ||
.a {} |
1 change: 1 addition & 0 deletions
1
test/fixtures/react-css-modules/uses autoResolveMultipleImport on runtime/foo.css
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 @@ | ||
.b {} |
8 changes: 8 additions & 0 deletions
8
test/fixtures/react-css-modules/uses autoResolveMultipleImport on runtime/input.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,8 @@ | ||
import './foo.css'; | ||
import './bar.css'; | ||
|
||
const styleNameA = 'a'; | ||
const styleNameB = 'b'; | ||
|
||
<div styleName={styleNameA}></div>; | ||
<div styleName={styleNameB}></div>; |
Oops, something went wrong.