Skip to content

Commit 8463ce8

Browse files
committed
refactor: update module declarations and test cases to support base64 imports
1 parent a899336 commit 8463ce8

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

lib/__tests__/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
declare module "*?file";
2+
declare module "*?base64";
3+
declare module "*?binary";
4+
declare module "*?buffer";
5+
declare module "*?text";
16
declare module "*?raw";
27
declare module "*.md";

lib/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ describe("Raw plugin", () => {
2727

2828
test("test raw import with auto ext", async ({ expect }) => {
2929
await esbuild.build({ ...buildOptions, entryPoints: [path.resolve(__dirname, "test1.ts")] });
30-
const fileContent = fs.readFileSync(path.resolve(__dirname, "../src/index.ts"), "utf-8");
30+
const fileContent = fs.readFileSync(path.resolve(__dirname, "../src/index.ts"));
3131
// @ts-ignore
3232
const generatedCodeContent = (await import("./dist/test1.js")).getText();
33-
expect(fileContent).toBe(generatedCodeContent);
33+
expect(generatedCodeContent).toBe(fileContent.toString("base64"));
3434
});
3535

3636
test("throws error if no file is found", async ({ expect }) => {

lib/__tests__/test1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// test auto complete
22

3-
import text from "../src?raw";
3+
import text from "../src?base64";
44

55
export const getText = () => text;

0 commit comments

Comments
 (0)