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
54 changes: 2 additions & 52 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import esbuild from "esbuild";
import process from "process";
import fs from "fs";
import { builtinModules, createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';

const require = createRequire(import.meta.url);
import { builtinModules } from 'node:module';

const banner =
`/*
Expand All @@ -15,51 +11,6 @@ if you want to view the source, please visit the github repository of this plugi

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

// punycode is a deprecated Node.js built-in; filter it from externals so the
// npm `punycode` package gets bundled instead. Some transitive deps use the
// package-path form `require('punycode/')` which Electron can't resolve at
// runtime unless it is inlined by esbuild.
const externalModules = builtinModules.filter(m => m !== 'punycode');

/** Resolves `punycode/` (trailing-slash package-path form) to the npm package. */
const punycodePlugin = {
name: 'punycode-fix',
setup(build) {
build.onResolve({ filter: /^punycode\/$/ }, async (args) => {
const result = await build.resolve('punycode', {
resolveDir: args.resolveDir,
kind: args.kind,
});
return result;
});
},
};

/**
* Inlines pdfjs-dist's worker file as a JS string module.
* PdfView.ts imports it and creates a Blob URL at runtime — no external
* worker file needed, works in Electron's sandboxed renderer.
*/
const pdfWorkerPlugin = {
name: 'pdf-worker-inline',
setup(build) {
const workerPath = require.resolve('pdfjs-dist/build/pdf.worker.min.js');

build.onResolve({ filter: /^pdfjs-worker-src$/ }, () => ({
path: workerPath,
namespace: 'pdf-worker-text',
}));

build.onLoad({ filter: /.*/, namespace: 'pdf-worker-text' }, async (args) => {
const content = await fs.promises.readFile(args.path, 'utf-8');
return {
contents: `module.exports = ${JSON.stringify(content)};`,
loader: 'js',
};
});
},
};

const context = await esbuild.context({
banner: {
js: banner,
Expand All @@ -81,8 +32,7 @@ const context = await esbuild.context({
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...externalModules],
plugins: [punycodePlugin, pdfWorkerPlugin],
...builtinModules],
format: "cjs",
target: "es2018",
logLevel: "info",
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "viewitall",
"name": "View It All",
"version": "1.5.0",
"version": "2.0.1",
"minAppVersion": "0.15.0",
"description": "View and edit MS (.docx - .xlsx - .csv - .pptx ) and more file types directly inside the app — no external apps needed.",
"description": "View and edit Word documents (.docx) natively in Obsidian.",
"author": "ROOCKY.dev",
"authorUrl": "https://roocky.dev",
"fundingUrl": "https://ko-fi.com/r00cky",
Expand Down
Loading
Loading