Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retool build to produce plugin markdown files, minified/non-minified builds, and compatible JS code #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lapluviosilla
Copy link

I retooled the esbuild a bit to produce the plugin markdown files and amplenote compatible code files to make it a bit easier to update and publish plugins.
I also wanted a solution that worked better for iterative development over commit/pushing and using the Github Developers Plugin

Issues it resolves:

  1. Amplenote expects the code block to return a javascript object and also complains if the code block ends in a semi-colon. This means that the IIFE esmodule that ESBuild produces by default cannot be copy pasted without some edits. The two edits that must be done by hand are:
    1. Add a return statement inside the IIFE module return plugin_default;
    2. Remove the semi-colon at the end of the code
  2. The plugin metadata table and README cannot be versioned together with the code since they currently just live in Amplenote.

What This Pull Request Does

This pull request fixes these issues by including the readme and metadata in the build, applying some post-build changes to the code to amplenote-ify it, and producing working markdown files with non-minified and minified code options.

The build will now produce 4 files:

  1. build/compiled.js (This is the same as before, except for the small edits mentioned above)
  2. build/compiled.min.js
  3. build/plugin.md
  4. build/plugin.min.md

The build now uses a new PLUGIN_README.md and plugin.config.js files for the plugin readme and table metadata respectively.

Notes about plugin.config.js:

  • You can put the instructions markdown in the plugin.config.js without worrying about escaping newlines as you normally would in a table markdown cell. The build will format it appropriately in the output markdown table.
  • Settings is an array of plugin setting keys. The output metadata table will have a row per setting.

The content of the Markdown file can be easily copy/pasted into the plugin note using the Markdown plugin

These plugin changes are backwards compatible! The plugin developer can just use the build/compiled.js as before ignoring the new markdown builds if they prefer to just copy the code into their amplenote plugin note and not use the repo to version their readme and metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant