Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 95fd52d

Browse files
committed
feat: replace await-to-js with betterr
The library await-to-js was replaced with betterr for error handling. This change was applied in the getCssModuleImports and getCssModule functions in the src/utils/css-module.ts file. The package.json and pnpm-lock.yaml files were updated to reflect this change.
1 parent 30e1c6e commit 95fd52d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"release": "nr typecheck && nr test run && nr build && nlx publint && nlx bumpp && npm publish"
3333
},
3434
"dependencies": {
35-
"await-to-js": "^3.0.0",
3635
"camelcase-keys": "^9.1.3",
3736
"defu": "^6.1.4",
3837
"knitwork": "^1.1.0",
@@ -51,6 +50,7 @@
5150
"@ryoppippi/eslint-config": "npm:@jsr/ryoppippi__eslint-config",
5251
"@sveltejs/kit": "^2.5.20",
5352
"@types/node": "^22.1.0",
53+
"betterr": "^5.1.0",
5454
"eslint": "^9.8.0",
5555
"eslint-plugin-format": "^0.1.2",
5656
"eslint-plugin-svelte": "^2.43.0",

pnpm-lock.yaml

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/css-module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { readFile } from 'node:fs/promises';
22
import camelcaseKeys from 'camelcase-keys';
3-
import to from 'await-to-js';
43
import { transform } from 'lightningcss';
54
import MagicString from 'magic-string';
65
import type { StaticImport } from 'mlly';
76
import { parseStaticImport, pathToFileURL, resolvePath } from 'mlly';
87
import { stringToUint8Array, uint8ArrayToString } from 'uint8array-extras';
8+
import { betterr } from 'betterr';
99
import type { ResolvedOptions } from '../options';
1010

1111
type getCssModuleImportsProps = {
@@ -44,7 +44,7 @@ export async function getCssModuleImports(
4444
return { path: s.toString(), defaultImport, imp };
4545
}
4646

47-
const [err, resolved] = await to(resolvePath(specifier, {
47+
const { err, data: resolved } = await betterr(async () => resolvePath(specifier, {
4848
url: filename == null ? undefined : pathToFileURL(filename),
4949
}));
5050

@@ -66,7 +66,7 @@ export type CssModule = {
6666

6767
export async function getCssModule({ path, ...rest }: ResolvedModuleImport, options: ResolvedOptions): Promise<CssModule> {
6868
const { moduleNameingPattern: pattern } = options;
69-
const [err, code] = await to(readFile(path, { encoding: 'utf-8' }));
69+
const { err, data: code } = await betterr(async () => readFile(path, { encoding: 'utf-8' }));
7070

7171
if (err != null) {
7272
console.error(`Failed to read css module: ${path}`);

0 commit comments

Comments
 (0)