Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ async function compilePlugins() {
return await esbuild.build({
entryPoints: filesToProcess,
outdir: outDir,
outExtension: { '.js': '.mjs' },
bundle: true,
format: "esm",
minify: false,
minify: true,
treeShaking: true,
platform: "node",
sourcesContent: false,
Expand All @@ -80,9 +81,9 @@ async function compilePlugins() {
let source = await fs.promises.readFile(args.path, { encoding: 'utf-8' });

// Remove `extends FDO_SDK`, `super();`, and `import` statements
source = source.replace(/extends\s+\w+\s?/g, "");
source = source.replace(/super\(\);/g, "");
source = source.replace(/import\s.*?;?\n/g, "");
//source = source.replace(/extends\s+\w+\s?/g, "");
//source = source.replace(/super\(\);/g, "");
//source = source.replace(/import\s.*?;?\n/g, "");

return {
contents: source, loader: "ts"
Expand All @@ -97,13 +98,13 @@ async function extractMetadataAndPushS3() {
try {
fs.readdir(outDir, function(err, files) {
if (err) return {errors: [err]};
files = files.filter(fn => fn.endsWith('.js'));
files = files.filter(fn => fn.endsWith('.mjs'));
for (const file of files) {
const filePath = path.join(path.resolve(outDir), file);
import(filePath).then(plugin => {
const PluginClass = plugin.default;
const pluginInstance = new PluginClass();
const pluginName = FDO_SDK.generatePluginName(file.replace(".js", ""));
const pluginName = FDO_SDK.generatePluginName(file.replace(".mjs", ""));
const pluginVersion = pluginInstance.metadata.version;
console.log("Plugin name: " + pluginName);
console.log("Plugin version: " + pluginVersion);
Expand All @@ -113,7 +114,7 @@ async function extractMetadataAndPushS3() {
if (err) throw err;
const command = new PutObjectCommand({
Bucket: "fdo-plugins",
Key: pluginName + "/" + pluginVersion + "/" + pluginName + ".js",
Key: pluginName + "/" + pluginVersion + "/" + pluginName + ".mjs",
Body: data,
ContentType: "application/javascript",
IfNoneMatch: "*"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": "node build.mjs"
},
"dependencies": {
"@anikitenko/fdo-sdk": "^1.0.6",
"@anikitenko/fdo-sdk": "^1.0.10",
"@aws-sdk/client-s3": "^3.744.0",
"esbuild": "^0.25.0",
"glob": "^11.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/example_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FDO_SDK, FDOInterface, PluginMetadata} from '@anikitenko/fdo-sdk';
class MyPlugin extends FDO_SDK implements FDOInterface {
private readonly _metadata: PluginMetadata = {
name: "MyPlugin",
version: "1.0.1",
version: "1.0.2",
author: "AleXvWaN",
description: "A sample FDO plugin",
icon: "COG",
Expand Down