Skip to content

Commit d4379a2

Browse files
authored
Update all dependencies (#251)
1 parent 7f90169 commit d4379a2

File tree

12 files changed

+1180
-1508
lines changed

12 files changed

+1180
-1508
lines changed

.changeset/mighty-lobsters-joke.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"next-yak": patch
3+
"yak-swc": patch
4+
---
5+
6+
Updated all dependencies

packages/benchmarks/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

packages/example/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

packages/example/vitest.config.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
/// <reference types="vitest" />
2-
import { defineConfig } from "vite";
3-
import react from "@vitejs/plugin-react"
1+
import react from "@vitejs/plugin-react";
2+
import { defineConfig, mergeConfig } from "vitest/config";
43

54
// https://vitejs.dev/config/
6-
export default defineConfig({
7-
plugins:
8-
[
9-
react()
10-
],
11-
test: {
12-
globals: true,
13-
environment: "jsdom",
5+
export default mergeConfig(
6+
{
7+
plugins: [react()],
8+
},
9+
defineConfig({
10+
test: {
11+
globals: true,
12+
environment: "jsdom",
1413

15-
// This is only necessary because we use Vitest and Jest (to see verify that both work)
16-
// and they should use different snapshot names
17-
resolveSnapshotPath: (testPath, snapshotExtension) =>
18-
testPath.replace('__tests__', '__tests__/__vite_snapshots__') + snapshotExtension,
19-
}
20-
});
14+
// This is only necessary because we use Vitest and Jest (to see verify that both work)
15+
// and they should use different snapshot names
16+
resolveSnapshotPath: (testPath, snapshotExtension) =>
17+
testPath.replace("__tests__", "__tests__/__vite_snapshots__") +
18+
snapshotExtension,
19+
},
20+
}),
21+
);

packages/next-yak/loaders/css-loader.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { LoaderContext } from "webpack";
2-
import { resolveCrossFileConstant } from "./lib/resolveCrossFileSelectors.js";
31
import { relative } from "path";
2+
import type { LoaderContext } from "webpack";
43
import type { YakConfigOptions } from "../withYak/index.js";
4+
import { resolveCrossFileConstant } from "./lib/resolveCrossFileSelectors.js";
55

66
/**
77
* Transform typescript to css
@@ -22,6 +22,11 @@ export default async function cssExtractLoader(
2222
if (err) {
2323
return callback(err);
2424
}
25+
if (!source) {
26+
return callback(
27+
new Error(`Source code for ${this.resourcePath} is empty`),
28+
);
29+
}
2530
const { experiments } = this.getOptions();
2631
const debugLog = createDebugLogger(this, experiments?.debug);
2732

@@ -36,8 +41,22 @@ export default async function cssExtractLoader(
3641
});
3742
}
3843

39-
function extractCss(code: string): string {
40-
const codeParts = code.split("/*YAK Extracted CSS:\n");
44+
function extractCss(code: string | Buffer<ArrayBufferLike>): string {
45+
let codeString: string;
46+
47+
if (typeof code === "string") {
48+
codeString = code;
49+
} else if (code instanceof Buffer) {
50+
codeString = code.toString("utf-8");
51+
} else if (code instanceof ArrayBuffer) {
52+
codeString = new TextDecoder("utf-8").decode(code);
53+
} else {
54+
throw new Error(
55+
"Invalid input type: code must be string, Buffer, or ArrayBuffer",
56+
);
57+
}
58+
59+
const codeParts = codeString.split("/*YAK Extracted CSS:\n");
4160
let result = "";
4261
for (let i = 1; i < codeParts.length; i++) {
4362
const codeUntilEnd = codeParts[i].split("*/")[0];
@@ -59,7 +78,10 @@ function createDebugLogger(
5978
return () => {};
6079
}
6180
const debugType = debugOptions === true ? "ts" : debugOptions.type;
62-
return (messageType: "ts" | "css" | "css resolved", message: string) => {
81+
return (
82+
messageType: "ts" | "css" | "css resolved",
83+
message: string | Buffer<ArrayBufferLike> | undefined,
84+
) => {
6385
if (messageType === debugType || debugType === "all") {
6486
console.log(
6587
"🐮 Yak",

packages/next-yak/loaders/lib/resolveCrossFileSelectors.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import path from "path";
21
import babel from "@babel/core";
2+
import path from "path";
33
// @ts-expect-error - this is used by babel directly so we ignore that it is not typed
44
import babelPlugin from "@babel/plugin-syntax-typescript";
5-
import type { Compilation, LoaderContext } from "webpack";
65
import { getCssModuleLocalIdent } from "next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js";
6+
import type { Compilation, LoaderContext } from "webpack";
77

88
const yakCssImportRegex =
99
// Make mixin and selector non optional once we dropped support for the babel plugin
@@ -227,7 +227,19 @@ async function parseFile(
227227
const tranformedSource = new Promise<string>((resolve, reject) => {
228228
loader.loadModule(filePath, (err, source) => {
229229
if (err) return reject(err);
230-
resolve(source || "");
230+
let sourceString: string;
231+
if (typeof source === "string") {
232+
sourceString = source;
233+
} else if (source instanceof Buffer) {
234+
sourceString = source.toString("utf-8");
235+
} else if (source instanceof ArrayBuffer) {
236+
sourceString = new TextDecoder("utf-8").decode(source);
237+
} else {
238+
throw new Error(
239+
"Invalid input type: code must be string, Buffer, or ArrayBuffer",
240+
);
241+
}
242+
resolve(sourceString || "");
231243
});
232244
});
233245

packages/yak-swc/Cargo.lock

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

packages/yak-swc/css_in_js_parser/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ keywords = ["css", "parser", "css-in-js"]
1010
categories = ["parser-implementations", "web-programming"]
1111

1212
[dependencies]
13-
serde = { version = "1.0.203", features = ["derive"] }
14-
serde_json = "1.0.119"
13+
serde = { version = "1.0.217", features = ["derive"] }
14+
serde_json = "1.0.134"
1515
serde_repr = "0.1"
1616

1717
[dev-dependencies]

packages/yak-swc/relative_posix_path/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ categories = ["filesystem", "os::unix-apis", "os::windows-apis"]
1212

1313
[dependencies]
1414
lazy_static = "1.4.0"
15-
pathdiff = "0.2.1"
16-
regex = "1.10.3"
15+
pathdiff = "0.2.3"
16+
regex = "1.10.3"

packages/yak-swc/yak_swc/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
1010
lazy_static = "1.4.0"
11-
serde = "1.0.203"
12-
serde_json = "1.0.120"
13-
swc_core = { version = "5.0.1", features = ["ecma_plugin_transform"] }
11+
serde = "1.0.217"
12+
serde_json = "1.0.134"
13+
swc_core = { version = "5.0.4", features = ["ecma_plugin_transform"] }
1414
css_in_js_parser = { path = "../css_in_js_parser" }
1515
relative_posix_path = { path = "../relative_posix_path" }
1616
itertools = "0.13.0"
1717
percent-encoding = "2.3.1"
18-
rustc-hash = "2.0.0"
18+
rustc-hash = "2.1.0"
1919

2020
[dev-dependencies]
21-
divan = "0.1.14"
21+
divan = "0.1.17"
2222
regex = "1.10.3"
23-
swc = "5.0.1"
23+
swc = "5.0.2"
2424
swc_ecma_transforms_testing = "5.0.0"
2525
swc_ecma_parser = "5.0.0"
2626
testing = "5.0.0"

0 commit comments

Comments
 (0)