Make JSX work
This commit is contained in:
@@ -13,15 +13,17 @@ const contexts = await Promise.all(
|
|||||||
entryPoints: [`./plugins/${p}`],
|
entryPoints: [`./plugins/${p}`],
|
||||||
outfile: `dist/${p}/index.js`,
|
outfile: `dist/${p}/index.js`,
|
||||||
format: "iife",
|
format: "iife",
|
||||||
jsxFactory: "VCR.createElement",
|
globalName: "VencordPlugin",
|
||||||
jsxFragment: "VCR.Fragment",
|
jsxFactory: "Vencord.Webpack.Common.React.createElement",
|
||||||
|
jsxFragment: "Vencord.Webpack.Common.React.Fragment",
|
||||||
external: ["@vencord/types/*"],
|
external: ["@vencord/types/*"],
|
||||||
plugins: [vencordDep],
|
plugins: [vencordDep],
|
||||||
footer: { js: `//# sourceURL=${encodeURI(p)}` },
|
footer: { js: `return VencordPlugin;\n//# sourceURL=${encodeURI(p)}` },
|
||||||
minify: !isDev,
|
minify: !isDev,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
sourcemap: "linked",
|
sourcemap: "linked",
|
||||||
logLevel: "info"
|
logLevel: "info",
|
||||||
|
tsconfig: "./build/tsconfig.json"
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
7
build/tsconfig.json
Normal file
7
build/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Work around https://github.com/evanw/esbuild/issues/2460
|
||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "react"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ const names = {
|
|||||||
webpack: "Vencord.Webpack",
|
webpack: "Vencord.Webpack",
|
||||||
"webpack/common": "Vencord.Webpack.Common",
|
"webpack/common": "Vencord.Webpack.Common",
|
||||||
utils: "Vencord.Util",
|
utils: "Vencord.Util",
|
||||||
"utils/types": "Vencord.Plugins.External",
|
|
||||||
api: "Vencord.Api",
|
api: "Vencord.Api",
|
||||||
components: "Vencord.Components"
|
components: "Vencord.Components"
|
||||||
};
|
};
|
||||||
@@ -15,14 +14,11 @@ export default globalExternalsWithRegExp({
|
|||||||
|
|
||||||
let varName = names[path];
|
let varName = names[path];
|
||||||
if (!varName) {
|
if (!varName) {
|
||||||
const altMapping = names[path.split("/")[0]];
|
const elements = path.split("/");
|
||||||
if (!altMapping) throw new Error("Unknown module path: " + modulePath);
|
varName = names[elements.shift()];
|
||||||
|
if (!varName) throw new Error("Unknown module path: " + modulePath);
|
||||||
|
|
||||||
varName =
|
if (varName !== "Vencord.Util" || elements[0] === "types") varName += "." + elements.join(".");
|
||||||
altMapping +
|
|
||||||
"." +
|
|
||||||
// @ts-ignore
|
|
||||||
path.split("/")[1].replaceAll("/", ".");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { GlobalContextMenuPatchCallback, addGlobalContextMenuPatch, removeGlobalContextMenuPatch } from "@vencord/types/api/ContextMenu";
|
||||||
import { definePluginSettings } from "@vencord/types/api/settings";
|
import { definePluginSettings } from "@vencord/types/api/settings";
|
||||||
import definePlugin, { OptionType } from "@vencord/types/utils/types";
|
import definePlugin, { OptionType } from "@vencord/types/utils/types";
|
||||||
import { findStoreLazy } from "@vencord/types/webpack";
|
import { findStoreLazy } from "@vencord/types/webpack";
|
||||||
|
import { Menu } from "@vencord/types/webpack/common";
|
||||||
|
|
||||||
// This is already a webpack common so maybe don't search it again.
|
// This is already a webpack common so maybe don't search it again.
|
||||||
// just an example heh :3
|
// just an example heh :3
|
||||||
@@ -14,7 +16,19 @@ const settings = definePluginSettings({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
definePlugin({
|
const patchContextMenu: GlobalContextMenuPatchCallback = (navId, children) => () => {
|
||||||
|
children.unshift((
|
||||||
|
<Menu.MenuItem
|
||||||
|
id="example-context-menu-item"
|
||||||
|
label="read if cute"
|
||||||
|
action={() => {
|
||||||
|
alert(":3");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
name: "MyExamplePlugin",
|
name: "MyExamplePlugin",
|
||||||
description: "Very cute plugin",
|
description: "Very cute plugin",
|
||||||
authors: [
|
authors: [
|
||||||
@@ -30,10 +44,15 @@ definePlugin({
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
console.log(this.name, "just started");
|
console.log(this.name, "just started");
|
||||||
|
|
||||||
|
addGlobalContextMenuPatch(patchContextMenu);
|
||||||
|
|
||||||
console.log(UserStore.getCurrentUser().username, "is", settings.store.cuteSetting);
|
console.log(UserStore.getCurrentUser().username, "is", settings.store.cuteSetting);
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
console.log(this.name, "just stopped");
|
console.log(this.name, "just stopped");
|
||||||
|
|
||||||
|
removeGlobalContextMenuPatch(patchContextMenu);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user