Unable to compile new background files

I created a new directory called auth with a ts file called login.ts. login content:
import type { PlasmoMessaging } from "@plasmohq/messaging";
import apiInstance from "~sp-routes/apiInstance";

console.log("authLogin");

export type LoginRequest = {
email: string;
password: string;
}

const handler: PlasmoMessaging.MessageHandler<LoginRequest> = async (req, res) => {
console.log("Login request received");
console.log(req);
try {
const response = await apiInstance.post("/login",
{
email: req.body.email,
password: req.body.password,
}
);
console.log(response);
res.send({
success: true,
message: "Login successful"
});
} catch (error) {
console.error(error);
res.send({
success: false,
message: "Login failed"
});
}
}

export default handler;
import type { PlasmoMessaging } from "@plasmohq/messaging";
import apiInstance from "~sp-routes/apiInstance";

console.log("authLogin");

export type LoginRequest = {
email: string;
password: string;
}

const handler: PlasmoMessaging.MessageHandler<LoginRequest> = async (req, res) => {
console.log("Login request received");
console.log(req);
try {
const response = await apiInstance.post("/login",
{
email: req.body.email,
password: req.body.password,
}
);
console.log(response);
res.send({
success: true,
message: "Login successful"
});
} catch (error) {
console.error(error);
res.send({
success: false,
message: "Login failed"
});
}
}

export default handler;
I tried removing stopped the pnpm dev command, deleted the.plasmo and build directory, and installed a vscode auto-restart-typescript-eslint-servers plugin. After running pnpm dev, the new background login handler is still not being compiled. I also tried renaming the file but no luck. Has anybody else come across this issue?
No description
1 Reply
TechDevOscar
TechDevOscarOP•3d ago
Does Plasmo have reserved keywords? If I rename the authHook directory to messages, it seems to work. 🤔

Did you find this page helpful?