Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: minimum supported Node.js version is 18.12.0 #1583

Merged
merged 11 commits into from
Apr 4, 2024
4 changes: 2 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"Contex",
"vspace",
"commitlint",
"eslintcache"
"eslintcache",
"akait"
],

"ignorePaths": [
"CHANGELOG.md",
"package.json",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ logs
*.log
npm-debug.log*
.eslintcache
.cspellcache

/coverage
/dist
Expand Down
82 changes: 43 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ type importFn =
media: string,
resourcePath: string,
supports?: string,
layer?: string
layer?: string,
) => boolean;
};
```
Expand Down Expand Up @@ -315,16 +315,16 @@ type modules =
getLocalIdent: (
context: LoaderContext,
localIdentName: string,
localName: string
localName: string,
) => string;
namedExport: boolean;
exportGlobals: boolean;
exportLocalsConvention:
| "asIs"
| "camelCase"
| "camelCaseOnly"
| "as-is"
| "camel-case"
| "camel-case-only"
| "dashes"
| "dashesOnly"
| "dashes-only"
| ((name: string) => string);
exportOnlyLocals: boolean;
};
Expand Down Expand Up @@ -489,7 +489,10 @@ To import from multiple modules use multiple `composes:` rules.

```css
:local(.className) {
composes: edit highlight from "./edit.css", button from "module/button.css", classFromThisModule;
composes:
edit highlight from "./edit.css",
button from "module/button.css",
classFromThisModule;
background: red;
}
```
Expand Down Expand Up @@ -599,7 +602,7 @@ module.exports = {
localIdentContext: path.resolve(__dirname, "src"),
localIdentHashSalt: "my-custom-hash",
namedExport: true,
exportLocalsConvention: "camelCase",
exportLocalsConvention: "as-is",
exportOnlyLocals: false,
},
},
Expand All @@ -620,7 +623,7 @@ type auto =
| ((
resourcePath: string,
resourceQuery: string,
resourceFragment: string
resourceFragment: string,
) => boolean);
```

Expand Down Expand Up @@ -726,7 +729,7 @@ type mode =
| ((
resourcePath: string,
resourceQuery: string,
resourceFragment: string
resourceFragment: string,
) => "local" | "global" | "pure" | "icss");
```

Expand Down Expand Up @@ -1094,7 +1097,7 @@ Type:
type getLocalIdent = (
context: LoaderContext,
localIdentName: string,
localName: string
localName: string,
) => string;
```

Expand Down Expand Up @@ -1135,21 +1138,13 @@ Type:
type namedExport = boolean;
```

Default: `false`
Default: Depends on the value of the `esModule` option. If the value of the `esModule` options is `true`, this value will also be `true`, otherwise it will be `false`.

Enables/disables ES modules named export for locals.

> **Warning**
>
> Names of locals are converted to camelcase, i.e. the `exportLocalsConvention` option has
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
> which are not valid JavaScript identifiers may run into problems which do not implement the entire
> modules specification.

> **Warning**
>
> It is not allowed to use JavaScript reserved words in css class names unless
> `exportLocalsConvention` is `"asIs"`.
> It is not allowed to use the `default` reserved word in css classes.

**styles.css**

Expand All @@ -1167,8 +1162,10 @@ Enables/disables ES modules named export for locals.
```js
import * as styles from "./styles.css";

// If using `exportLocalsConvention: "camel-case-only"`:
console.log(styles.fooBaz, styles.bar);
// or if using `exportLocalsConvention: "asIs"`:

// If using `exportLocalsConvention: "as-is"`:
console.log(styles["foo-baz"], styles.bar);
```

Expand Down Expand Up @@ -1236,29 +1233,35 @@ Type:

```ts
type exportLocalsConvention =
| "asIs"
| "camelCase"
| "camelCaseOnly"
| "as-is"
| "camel-case"
| "camel-case-only"
| "dashes"
| "dashesOnly"
| "dashes-only"
| ((name: string) => string);
```

Default: based on the `modules.namedExport` option value, if `true` - `camelCaseOnly`, otherwise `asIs`
Default: Depends on the value of the `modules.namedExport` option, if `true` - `as-is`, otherwise `camel-case-only`.

> **Warning**
>
> Names of locals are converted to camelcase when the named export is `false`, i.e. the `exportLocalsConvention` option has
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
> which are not valid JavaScript identifiers may run into problems which do not implement the entire modules specification.

Style of exported class names.

###### `string`

By default, the exported JSON keys mirror the class names (i.e `asIs` value).
By default, the exported JSON keys mirror the class names (i.e `as-is` value).

| Name | Type | Description |
| :-------------------: | :------: | :----------------------------------------------------------------------------------------------- |
| **`'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 |
| **`'dashesOnly'`** | `string` | Dashes in class names will be camelized, the original class name will be removed from the locals |
| Name | Type | Description |
| :---------------------: | :------: | :----------------------------------------------------------------------------------------------- |
| **`'as-is'`** | `string` | Class names will be exported as is. |
| **`'camel-case'`** | `string` | Class names will be camelized, the original class name will not to be removed from the locals |
| **`'camel-case-only'`** | `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 |
| **`'dashes-only'`** | `string` | Dashes in class names will be camelized, the original class name will be removed from the locals |

**file.css**

Expand All @@ -1284,7 +1287,7 @@ module.exports = {
loader: "css-loader",
options: {
modules: {
exportLocalsConvention: "camelCase",
exportLocalsConvention: "camel-case-only",
},
},
},
Expand Down Expand Up @@ -1333,7 +1336,7 @@ module.exports = {
name.replace(/-/g, "_"),
// dashesCamelCase
name.replace(/-+(\w)/g, (match, firstLetter) =>
firstLetter.toUpperCase()
firstLetter.toUpperCase(),
),
];
},
Expand Down Expand Up @@ -1770,7 +1773,8 @@ With the help of the `/* webpackIgnore: true */`comment, it is possible to disab
.class {
/* Disabled url handling for the second url in the 'background' declaration */
color: red;
background: url("./url/img.png"),
background:
url("./url/img.png"),
/* webpackIgnore: true */ url("./url/img.png");
}

Expand Down Expand Up @@ -1904,7 +1908,7 @@ module.exports = {
alias: {
"/assets/unresolved/img.png": path.resolve(
__dirname,
"assets/real-path-to-img/img.png"
"assets/real-path-to-img/img.png",
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (api) => {
"@babel/preset-env",
{
targets: {
node: "12.13.0",
node: "18.12.0",
},
},
],
Expand Down
5 changes: 4 additions & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
"*": ["prettier --write --ignore-unknown", "cspell --no-must-find-files"],
"*": [
"prettier --cache --write --ignore-unknown",
"cspell --cache --no-must-find-files",
],
"*.js": ["eslint --cache --fix"],
};
Loading
Loading