Skip to content

Commit

Permalink
Try with require.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Mad-Kat committed Nov 24, 2024
1 parent 98996ea commit a2c047d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Build Yak
run: pnpm run build
- name: Build benchmark suite
run: cd packages/benchmarks && pnpm install && pnpm run codspeed
run: cd packages/benchmarks && pnpm run codspeed
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
Expand Down
44 changes: 25 additions & 19 deletions packages/benchmarks/letters/gen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { writeFile } from "fs";
import * as swc from "@swc/core";
// import path from "path";

// const wasmPath = path.resolve(
// process.cwd(),
// "node_modules",
// "yak-swc/target/wasm32-wasi/release/yak_swc.wasm",
// );

// Function to generate the content of JapaneseLetterComponent.tsx for Kanji characters
async function generateKanjiComponentFile() {
Expand Down Expand Up @@ -302,25 +309,24 @@ export const KanjiLetterComponent${
if (lib === "next-yak") {
const compiled =
"// @ts-nocheck\n" +
swc
.transformSync(fileContent, {
filename: "/foo/index.tsx",
jsc: {
experimental: {
plugins: [["yak-swc", { basePath: "/foo/" }]],
},
target: "es2022",
loose: false,
minify: {
compress: false,
mangle: false,
},
preserveAllComments: true,
},
minify: false,
isModule: true,
})
.code // Remove __styleYak import
swc.transformSync(fileContent, {
filename: "/foo/index.tsx",
jsc: {
experimental: {
plugins: [[require.resolve("yak-swc"), { basePath: "/foo/" }]],
},
target: "es2022",
loose: false,
minify: {
compress: false,
mangle: false,
},
preserveAllComments: true,
},
minify: false,
isModule: true,
}).code
// Remove __styleYak import
.replace(/import[^;\n]+yak.module.css";/, "")
// Replace __styleYak usage to a string
.replace(/__styleYak.(\w+)/g, `"$1"`);
Expand Down

0 comments on commit a2c047d

Please sign in to comment.