diff --git a/build.mjs b/build.mjs index 42d1555..2a56572 100644 --- a/build.mjs +++ b/build.mjs @@ -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, @@ -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" @@ -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); @@ -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: "*" diff --git a/package-lock.json b/package-lock.json index 01d2b21..3037582 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "fdo-plugins", "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", @@ -16,9 +16,9 @@ } }, "node_modules/@anikitenko/fdo-sdk": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@anikitenko/fdo-sdk/-/fdo-sdk-1.0.7.tgz", - "integrity": "sha512-sFZUVtj1N37JgvPrE3Vw1LV+a+2sV8YEI3X35b0xZ3S5JEm86axPhEtlH1XDP7rCCAT42u6FvjPiXdyDE/DWlw==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@anikitenko/fdo-sdk/-/fdo-sdk-1.0.10.tgz", + "integrity": "sha512-1G437KlYaDvjaQ2WXFiKPPirSvVH3em245P1cEjl2EQ62Yuz+P8NjJcb+NxW/j+wwHPn0SchkcdhVipeEBEoOg==", "license": "ISC", "dependencies": { "@blueprintjs/icons": "^5.17.1" diff --git a/package.json b/package.json index 5d14c74..5e72d1e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/example_plugin.ts b/src/example_plugin.ts index 341e41c..b4f3b78 100644 --- a/src/example_plugin.ts +++ b/src/example_plugin.ts @@ -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",