Skip to content

Commit

Permalink
fix outdated code
Browse files Browse the repository at this point in the history
  • Loading branch information
chauff committed Nov 1, 2024
1 parent 771d94d commit 632fefa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 34 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,8 @@ In short:
2. Once happy, increment the version number in [manifest.json](manifest.json), let's assume the version number increases from `1.0.2` to `1.0.3`. Commit.
3. Then create a tag that matches the new version number by running `git tag -a 1.0.3 -m "1.0.3"` and then `git push origin 1.0.3`
4. Check the Actions tab on GitHub, it should now be running the "Release Obsidian plugin" action (this can take some time).
5. If there are build issues, and it isn't an error in the plugin itself, it is probably about outdated package versions. Check step 3 above.
5. If there are build issues, and it isn't an error in the plugin itself, it is probably about outdated package versions.
6. If for some reason the build fails and you want to retrigger the build without updating the versioning do this:
1. Delete the tag number locally `git tag -d 1.0.3`
2. Recreate the tag `git tag 1.0.3`
3. Force push to trigger the workflow `git push -f origin 1.0.3`
77 changes: 44 additions & 33 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
import esbuild from "esbuild";
import process from "process";
import builtins from 'builtin-modules'
import builtins from "builtin-modules";

const banner =
`/*
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === 'production');
const prod = process.argv[2] === "production";

esbuild.build({
banner: {
js: banner,
},
entryPoints: ['main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins],
format: 'cjs',
watch: !prod,
target: 'es2018',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));
// Build options
const buildOptions = {
banner: {
js: banner,
},
entryPoints: ["main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins,
],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
};

// Check if we're in production mode
if (prod) {
// Regular build for production
esbuild.build(buildOptions).catch(() => process.exit(1));
} else {
// Use the context API for watch mode
esbuild.context(buildOptions).then((context) => {
context.watch().catch(() => process.exit(1));
});
}

0 comments on commit 632fefa

Please sign in to comment.