-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css): redirect named locals to default export when named export …
…is disabled
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
test/configCases/css/default-exports-parser-options/index.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,19 @@ | ||
import * as style1 from "./style.module.css?namespace"; | ||
import style2 from "./style.module.css?default"; | ||
import { foo } from "./style.module.css?named"; | ||
|
||
it("should able to import with default and named exports", () => { | ||
expect(style1.default).toEqual(nsObj({ foo: '-_style_module_css_namespace-foo' })); | ||
expect(style1.foo).toEqual("-_style_module_css_namespace-foo"); | ||
expect(style2).toEqual(nsObj({ foo: '-_style_module_css_default-foo' })); | ||
expect(foo).toEqual("-_style_module_css_named-foo"); | ||
}); | ||
|
||
it("should able to import with different default and namex dynamic export", (done) => { | ||
import("./style.module.css?namespace").then((style1) => { | ||
expect(style1.default).toEqual(nsObj({ foo: '-_style_module_css_namespace-foo' })); | ||
expect(style1.foo).toEqual('-_style_module_css_namespace-foo'); | ||
|
||
done(); | ||
}, done) | ||
}); |
3 changes: 3 additions & 0 deletions
3
test/configCases/css/default-exports-parser-options/style.module.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 @@ | ||
.foo { | ||
color: red; | ||
} |
20 changes: 20 additions & 0 deletions
20
test/configCases/css/default-exports-parser-options/webpack.config.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,20 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "node", | ||
mode: "development", | ||
devtool: false, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css/, | ||
parser: { | ||
namedExports: false | ||
}, | ||
type: "css/module" | ||
} | ||
] | ||
}, | ||
experiments: { | ||
css: true | ||
} | ||
}; |
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