Skip to content

Commit aa75fa7

Browse files
feat: exportOnlyLocals was remove in favor new onlyLocals option (#957)
BREAKING CHANGE: rename `exportOnlyLocals` option to `onlyLocals` option
1 parent 49f3ff0 commit aa75fa7

7 files changed

+11
-13
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module.exports = {
117117
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
118118
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader |
119119
| **[`exportLocalsStyle`](#exportlocalsstyle)** | `{String}` | `asIs` | Setup style of exported classnames |
120-
| **[`exportOnlyLocals`](#exportonlylocals)** | `{Boolean}` | `false` | Export only locals |
120+
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
121121

122122
### `url`
123123

@@ -772,7 +772,7 @@ By default, the exported JSON keys mirror the class names (i.e `asIs` value).
772772

773773
| Name | Type | Description |
774774
| :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- |
775-
| **`asIs`** | `{String}` | Class names will be exported as is. |
775+
| **`'asIs'`** | `{String}` | Class names will be exported as is. |
776776
| **`'camelCase'`** | `{String}` | Class names will be camelized, the original class name will not to be removed from the locals |
777777
| **`'camelCaseOnly'`** | `{String}` | Class names will be camelized, the original class name will be removed from the locals |
778778
| **`'dashes'`** | `{String}` | Only dashes in class names will be camelized |
@@ -809,7 +809,7 @@ module.exports = {
809809
};
810810
```
811811

812-
### `exportOnlyLocals`
812+
### `onlyLocals`
813813

814814
Type: `Boolean`
815815
Default: `false`
@@ -828,7 +828,7 @@ module.exports = {
828828
test: /\.css$/i,
829829
loader: 'css-loader',
830830
options: {
831-
exportOnlyLocals: true,
831+
onlyLocals: true,
832832
},
833833
},
834834
],

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default function loader(content, map, meta) {
115115
result.messages = [];
116116
}
117117

118-
const { exportOnlyLocals: onlyLocals } = options;
118+
const { onlyLocals } = options;
119119

120120
const importItems = result.messages
121121
.filter((message) => (message.type === 'import' ? message : false))

src/options.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
}
9393
]
9494
},
95-
"exportOnlyLocals": {
95+
"onlyLocals": {
9696
"type": "boolean"
9797
}
9898
},

test/__snapshots__/validate-options.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ options.importLoaders should match some schema in anyOf
179179
exports[`validate options 18`] = `
180180
"CSS Loader Invalid Options
181181
182-
options.exportOnlyLocals should be boolean
182+
options.onlyLocals should be boolean
183183
"
184184
`;

test/exportOnlyLocals-option.test.js renamed to test/onlyLocals-option.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('modules', () => {
99
mode: 'local',
1010
localIdentName: '_[local]',
1111
},
12-
exportOnlyLocals: true,
12+
onlyLocals: true,
1313
},
1414
},
1515
};

test/validate-options.test.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ it('validate options', () => {
107107
expect(() => validate({ importLoaders: 2 })).not.toThrow();
108108
expect(() => validate({ importLoaders: '1' })).toThrowErrorMatchingSnapshot();
109109

110-
expect(() => validate({ exportOnlyLocals: true })).not.toThrow();
111-
expect(() => validate({ exportOnlyLocals: false })).not.toThrow();
112-
expect(() =>
113-
validate({ exportOnlyLocals: 'true' })
114-
).toThrowErrorMatchingSnapshot();
110+
expect(() => validate({ onlyLocals: true })).not.toThrow();
111+
expect(() => validate({ onlyLocals: false })).not.toThrow();
112+
expect(() => validate({ onlyLocals: 'true' })).toThrowErrorMatchingSnapshot();
115113
});

0 commit comments

Comments
 (0)