Skip to content

Commit

Permalink
feat: exportOnlyLocals was remove in favor new onlyLocals option (#…
Browse files Browse the repository at this point in the history
…957)

BREAKING CHANGE: rename `exportOnlyLocals` option to `onlyLocals` option
  • Loading branch information
evilebottnawi committed Jun 11, 2019
1 parent 49f3ff0 commit aa75fa7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -117,7 +117,7 @@ module.exports = {
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader |
| **[`exportLocalsStyle`](#exportlocalsstyle)** | `{String}` | `asIs` | Setup style of exported classnames |
| **[`exportOnlyLocals`](#exportonlylocals)** | `{Boolean}` | `false` | Export only locals |
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |

### `url`

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

| Name | Type | Description |
| :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- |
| **`asIs`** | `{String}` | Class names will be exported as is. |
| **`'asIs'`** | `{String}` | Class names will be exported as is. |
| **`'camelCase'`** | `{String}` | Class names will be camelized, the original class name will not to be removed from the locals |
| **`'camelCaseOnly'`** | `{String}` | Class names will be camelized, the original class name will be removed from the locals |
| **`'dashes'`** | `{String}` | Only dashes in class names will be camelized |
Expand Down Expand Up @@ -809,7 +809,7 @@ module.exports = {
};
```

### `exportOnlyLocals`
### `onlyLocals`

Type: `Boolean`
Default: `false`
Expand All @@ -828,7 +828,7 @@ module.exports = {
test: /\.css$/i,
loader: 'css-loader',
options: {
exportOnlyLocals: true,
onlyLocals: true,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -115,7 +115,7 @@ export default function loader(content, map, meta) {
result.messages = [];
}

const { exportOnlyLocals: onlyLocals } = options;
const { onlyLocals } = options;

const importItems = result.messages
.filter((message) => (message.type === 'import' ? message : false))
Expand Down
2 changes: 1 addition & 1 deletion src/options.json
Expand Up @@ -92,7 +92,7 @@
}
]
},
"exportOnlyLocals": {
"onlyLocals": {
"type": "boolean"
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/validate-options.test.js.snap
Expand Up @@ -179,6 +179,6 @@ options.importLoaders should match some schema in anyOf
exports[`validate options 18`] = `
"CSS Loader Invalid Options
options.exportOnlyLocals should be boolean
options.onlyLocals should be boolean
"
`;
Expand Up @@ -9,7 +9,7 @@ describe('modules', () => {
mode: 'local',
localIdentName: '_[local]',
},
exportOnlyLocals: true,
onlyLocals: true,
},
},
};
Expand Down
8 changes: 3 additions & 5 deletions test/validate-options.test.js
Expand Up @@ -107,9 +107,7 @@ it('validate options', () => {
expect(() => validate({ importLoaders: 2 })).not.toThrow();
expect(() => validate({ importLoaders: '1' })).toThrowErrorMatchingSnapshot();

expect(() => validate({ exportOnlyLocals: true })).not.toThrow();
expect(() => validate({ exportOnlyLocals: false })).not.toThrow();
expect(() =>
validate({ exportOnlyLocals: 'true' })
).toThrowErrorMatchingSnapshot();
expect(() => validate({ onlyLocals: true })).not.toThrow();
expect(() => validate({ onlyLocals: false })).not.toThrow();
expect(() => validate({ onlyLocals: 'true' })).toThrowErrorMatchingSnapshot();
});

0 comments on commit aa75fa7

Please sign in to comment.