Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
afbf5a5
build(deps): bump thenify from 3.3.0 to 3.3.1
dependabot[bot] Mar 5, 2023
daefd9d
Merge pull request #289 from shd101wyy/dependabot/npm_and_yarn/thenif…
shd101wyy Mar 6, 2023
a904591
feat: Started using nix flake
shd101wyy May 23, 2023
114f055
build(deps): bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 11, 2023
b388bd0
build(deps): bump word-wrap from 1.2.3 to 1.2.4
dependabot[bot] Jul 18, 2023
0f24026
ci: Updated nix
shd101wyy Aug 21, 2023
55e892e
feat: Updated mermaid to version 10
shd101wyy Aug 21, 2023
58af25d
fix: Set package.json version to 0.7.7
shd101wyy Aug 21, 2023
a8208c8
fix: Fixed rendering mermaid in preview
shd101wyy Aug 22, 2023
7f89eaa
feat: Pass in system color scheme when webview finishes loading
shd101wyy Aug 22, 2023
7c8742b
feat: Updated katex to 0.16.8
shd101wyy Aug 22, 2023
0e87362
feat: Added jsdelivrCdnHost configuration option
shd101wyy Aug 22, 2023
96f3e11
doc: Updated README.md
shd101wyy Aug 22, 2023
a99660b
Merge pull request #295 from shd101wyy/feat/mermaid-v10
shd101wyy Aug 22, 2023
918b80f
fix: Removed ditaa.jar and plantuml.jar
shd101wyy Aug 23, 2023
fe77556
refactor: Removed ditaa related codes
shd101wyy Aug 23, 2023
4d557d2
feat: Updated prismjs to 1.29.0
shd101wyy Aug 23, 2023
8445677
feat: Supported to specify plantumlJarPath
shd101wyy Aug 23, 2023
774ed39
feat: Added kiroki support
shd101wyy Aug 23, 2023
9cd50c0
feat: Mark as version 0.7.8
shd101wyy Aug 23, 2023
4c5061e
fix: Better kroki handling
shd101wyy Aug 23, 2023
8d37a01
feat: Added crossnote modules
shd101wyy Aug 24, 2023
c86fdf6
fix: Fixed the tslint errors
shd101wyy Aug 26, 2023
633ff88
feat: Tried to switch to esbuild
shd101wyy Aug 29, 2023
4042dda
ci: Switched from travis to github workflow
shd101wyy Aug 29, 2023
05cdd32
fix: Cleaned up some files
shd101wyy Aug 29, 2023
2031445
fix: Removed js-sequence-diagram support
shd101wyy Aug 29, 2023
a9db53d
fix: Removed flowchart.js
shd101wyy Aug 29, 2023
fc160be
feat: Updated mermaid to 10.4.0
shd101wyy Aug 29, 2023
53ba505
fix: Restored vega
shd101wyy Aug 29, 2023
41a2083
fix: Removed more dependencies
shd101wyy Aug 29, 2023
b98c4ea
feat: Upgraded vega related dependencies
shd101wyy Aug 29, 2023
fb1e6be
Merge pull request #294 from shd101wyy/dependabot/npm_and_yarn/word-w…
shd101wyy Aug 29, 2023
f01d21b
Merge pull request #293 from shd101wyy/dependabot/npm_and_yarn/semver…
shd101wyy Aug 29, 2023
f7f9844
Merge branch 'master' of github-shd101wyy:shd101wyy/mume into crossno…
shd101wyy Aug 29, 2023
20f2ee2
fix: Upgraded cheerio
shd101wyy Aug 29, 2023
c9f1ae5
feat: Replaced zenuml with mermaid zenuml
shd101wyy Aug 29, 2023
1ee3760
ci: Migrated from tslint to eslint
shd101wyy Aug 30, 2023
f317061
refactor: Moved vega and vega-lite to package.json
shd101wyy Aug 30, 2023
494e78e
refactor: Removed all unnecessary 'require()'
shd101wyy Aug 30, 2023
4611b09
feat: Added @types/vscode-webview
shd101wyy Aug 30, 2023
0a44622
fix: Got both cjs and esm working
shd101wyy Aug 30, 2023
a472b0c
fix: Removed tslint and related packages
shd101wyy Aug 31, 2023
4885133
fix: Moved prismjs from package.json to src
shd101wyy Aug 31, 2023
5d7c3f7
ci: Moved all build files to ./out
shd101wyy Aug 31, 2023
dd2ab02
refactor: Removed all MathJax V2 files
shd101wyy Aug 31, 2023
2fee7fd
feat: Supported MathJax V3
shd101wyy Aug 31, 2023
023d40a
fix: Fixed mermaid error rendering in webview
shd101wyy Sep 1, 2023
2060cbb
ci: Fixed eslint for unnecessary prism.js file check
shd101wyy Sep 1, 2023
2bc312e
fix: Fixed the jest tests
shd101wyy Sep 1, 2023
c6c2468
doc: Updated doc for plantumlServer
shd101wyy Sep 1, 2023
44ef73f
Merge pull request #297 from shd101wyy/crossnote-migration
shd101wyy Sep 1, 2023
75fac4d
feat: Replaced BabyParse with PapaParse
shd101wyy Sep 1, 2023
604dec9
Merge pull request #298 from shd101wyy/feat/papaparse
shd101wyy Sep 1, 2023
89f616b
refactor: Re-organized the file structure
shd101wyy Sep 1, 2023
b3e8d67
refactor: Added new notebook/types.ts file
shd101wyy Sep 1, 2023
0e41084
refactor: Refactored the code
shd101wyy Sep 1, 2023
2aa4c22
refactor: Refactored the code
shd101wyy Sep 1, 2023
30a23ca
refactor: Refactored the code
shd101wyy Sep 1, 2023
137b246
feat: Renamed the package to crossnote
shd101wyy Sep 1, 2023
24dd66f
fix: Fixed some bugs
shd101wyy Sep 1, 2023
371cfa9
fix: Fixed some bugs
shd101wyy Sep 1, 2023
283c02b
fix: Fixed the puppeteer export
shd101wyy Sep 2, 2023
30788b3
Merge pull request #299 from shd101wyy/fix/puppeteer-export
shd101wyy Sep 2, 2023
ade373f
Merge branch 'master' of github-shd101wyy:shd101wyy/mume into crossno…
shd101wyy Sep 2, 2023
c8ac3f8
refactor: Re-organized the style (css|less) files
shd101wyy Sep 2, 2023
39f5618
feat: Set up gulp to run some tasks
shd101wyy Sep 2, 2023
8f8b7cd
feat: Supported to watch ./style files change
shd101wyy Sep 2, 2023
4561d34
feat: Supported to load configs from .crossnote
shd101wyy Sep 2, 2023
fde2ecf
refactor: Removed MarkdownEngine static modifySource
shd101wyy Sep 2, 2023
e1fc539
feat: Exposed more functions
shd101wyy Sep 3, 2023
cc561b4
refactor: Renamed some functions
shd101wyy Sep 3, 2023
8336225
fix: Fixed dynamic import of parser.js
shd101wyy Sep 3, 2023
4192b9f
feat: Better support for bundling web
shd101wyy Sep 4, 2023
ed23595
fix: Fixed some webview bugs
shd101wyy Sep 4, 2023
8e0a9fc
fix: Fixed less in browser
shd101wyy Sep 4, 2023
14296e7
fix: Fixed one code chunk output bug
shd101wyy Sep 4, 2023
ca6f95e
refactor: Removed unnecessary DESIGN.md
shd101wyy Sep 4, 2023
4ed2cd1
Merge pull request #301 from shd101wyy/crossnote-setup
shd101wyy Sep 4, 2023
c3bd85e
fix: Fixed missing fontawesome
shd101wyy Sep 4, 2023
cdf52a1
doc: Fixed doc
shd101wyy Sep 4, 2023
f076319
fix: Fixed code chunk text output
shd101wyy Sep 5, 2023
17a00dd
feat: Cached the kroki result
shd101wyy Sep 5, 2023
b944b1d
fix: Fallback to GET for the official puml server
shd101wyy Sep 5, 2023
050818f
feat: Improved the kroki rendering
shd101wyy Sep 5, 2023
ff783c1
Merge pull request #302 from shd101wyy/fix/font-awesome
shd101wyy Sep 5, 2023
0073d87
fix: Fixed MathJax config and refactored some code
shd101wyy Sep 5, 2023
c333eb9
feat: Added interpreter for js
shd101wyy Sep 5, 2023
25160fb
Merge pull request #303 from shd101wyy/fix/mathjax-config
shd101wyy Sep 5, 2023
1069467
fix: Fixed interpreting JS script
shd101wyy Sep 5, 2023
aa8f3d5
fix: Fixed polluted mathjax config (#304)
shd101wyy Sep 5, 2023
f52904a
GitHub issue templates (#305)
shd101wyy Sep 6, 2023
7b629fa
feat: Added config (#306)
shd101wyy Sep 6, 2023
f431982
Refactor webview and add backlinks support. (#307)
shd101wyy Sep 13, 2023
70fdb2e
fix: Fixed the windows path error (#308)
shd101wyy Sep 13, 2023
75b44cf
fix: Fixed list style and sidebar toc button style (#309)
shd101wyy Sep 13, 2023
a7cd981
feat: Supported to toggle always show backlinks in preview (#310)
shd101wyy Sep 14, 2023
2d07430
fix: Fixed mathjax rendering in preview (#311)
tcbbd Sep 15, 2023
b5d6651
Set up CI to publish the npm package. (#312)
shd101wyy Sep 15, 2023
b1f8c88
Fixed vue theme and added bitfield diagram support. (#313)
shd101wyy Sep 15, 2023
3fed6b2
0.8.15 (#314)
shd101wyy Sep 17, 2023
7eea3cb
Fix codeBlock html tag (#315)
wxy Sep 24, 2023
3db0b91
0.8.16 (#316)
shd101wyy Sep 24, 2023
4b8c977
feat: Added typedoc generated documentation website (#317)
shd101wyy Oct 1, 2023
0a3e948
doc: Updated README.md (#318)
shd101wyy Oct 1, 2023
2ec8403
0.8.17 (#319)
shd101wyy Oct 4, 2023
7d14e95
build(deps-dev): Bump postcss from 8.4.29 to 8.4.31 (#320)
dependabot[bot] Oct 4, 2023
b0be4ee
0.8.18 (#321)
shd101wyy Oct 5, 2023
9a21ae6
0.8.19 (#323)
shd101wyy Oct 6, 2023
dae47a8
fix: Improved scroll sync (#324)
shd101wyy Oct 6, 2023
f4c9c12
0.8.1 bug fixes (#325)
shd101wyy Oct 9, 2023
c906f48
fix: Fixed a bug of parsing slides (#326)
shd101wyy Oct 9, 2023
020f077
fix: Fixed an image bug and parsing slides bug (#327)
shd101wyy Oct 10, 2023
ef2beb5
fix: Fixed exporting reveal.js presentation (#328)
shd101wyy Oct 10, 2023
2226a6a
0.8.4 bug fixes (#329)
shd101wyy Oct 10, 2023
ba12c2e
0.8.5 bug fixes (#330)
shd101wyy Oct 13, 2023
402d89e
fix: Moved vega out from package.json (#331)
shd101wyy Oct 14, 2023
64eec7b
modify conditions for matplotlib option (#333)
Take-Me1010 Oct 15, 2023
dfffe53
0.9.2 (#334)
shd101wyy Oct 15, 2023
377c174
fix: Better handling of source map for importing files (#336)
shd101wyy Oct 15, 2023
9afc685
0.9.4 (#338)
shd101wyy Oct 21, 2023
701ab4f
fix: Fixed a katex rendering bug (#339)
shd101wyy Oct 23, 2023
29e70b2
build(deps): Bump @babel/traverse from 7.23.0 to 7.23.2 (#337)
dependabot[bot] Oct 23, 2023
fc27357
0.9.6 (#341)
shd101wyy Oct 26, 2023
0cf6c87
build(deps): Bump crypto-js from 4.1.1 to 4.2.0 (#340)
dependabot[bot] Oct 26, 2023
d16c031
doc: Add coc.nvim to error information (#345)
Freed-Wu Dec 10, 2023
b64a355
0.9.7 (#348)
shd101wyy Dec 10, 2023
0a133b6
feat: sidebarToc supports local caching (#349)
moonlitusun Mar 3, 2024
dc2d9fc
chore: update MermaidJS to v10.8.0 (#350)
oneWaveAdrian Mar 10, 2024
e37e4bc
build(deps): Bump es5-ext from 0.10.62 to 0.10.64 (#351)
dependabot[bot] Mar 10, 2024
99ff644
0.9.8 (#352)
shd101wyy Mar 10, 2024
047358e
fix: Fixed a minor in CHANGELOG and added one small test (#353)
shd101wyy Mar 10, 2024
28704eb
fix: long sidebarToc does not display completely (#354)
moonlitusun Mar 18, 2024
5254777
fix: Removed text as the default language selector for code blocks (#…
shd101wyy Mar 18, 2024
9708d58
0.9.10 (#359)
shd101wyy Sep 7, 2024
d0bf056
0.9.11 (#363)
shd101wyy Nov 8, 2024
845004b
build(deps): Bump cross-spawn from 7.0.3 to 7.0.6 (#364)
dependabot[bot] Mar 16, 2025
5f89579
build(deps): Bump nanoid from 3.3.7 to 3.3.8 (#365)
dependabot[bot] Mar 16, 2025
10db302
build(deps-dev): Bump esbuild from 0.19.12 to 0.25.0 (#368)
dependabot[bot] Mar 16, 2025
0af5da0
0.9.12 (#370)
shd101wyy Mar 16, 2025
f7f6ba3
fix: Fixed importing sharp package (#371)
shd101wyy Mar 16, 2025
fd6ac54
fix: Fixed prismjs that caused problem in vscode web (#372)
shd101wyy Mar 16, 2025
a8f5187
Fix splitting logic to handle diagrams starting with `<svg>` correctl…
shiftdownet Aug 15, 2025
b2773c1
0.9.15 (#378)
shd101wyy Aug 15, 2025
148c95f
Sync with upstream
kachkaev Sep 28, 2025
72e6b60
Merge branch 'upstream' into mume-to-crossnote
kachkaev Sep 28, 2025
d5b7cc2
Fix import paths
kachkaev Sep 28, 2025
dea5b8f
Update CHANGELOG
kachkaev Sep 28, 2025
3540b8d
Dedupe
kachkaev Sep 28, 2025
41ede15
Remove release script
kachkaev Sep 28, 2025
79b4f4c
wip
kachkaev Sep 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use_nix
use flake
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
build.js
gulpfile.js
tailwind.config.js
.eslintrc.js
jest.config.js
prettier.config.js
test.js
node_modules/**
out/**
styles/**
dependencies/**
src/prism/prism.js
postcss.config.js
babel-jest.config.js
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**@type {import('eslint').Linter.Config} */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
};
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: shd101wyy

---

**Describe the bug**
A clear and concise description of what the bug is.

**Environment**
- OS: Windows 11
- Crossnote: 0.8.0
- Node.js: 16.13.0
- Browser: Chrome 95.0.4638.69

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature Request] "
labels: feature request
assignees: shd101wyy

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Test"
on:
push:
branches:
- develop
pull_request:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: "Test"
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Install nodejs 20'
uses: actions/setup-node@v2
with:
node-version: '20'
- name: 'Build and test'
run: |
corepack enable
yarn install
yarn check:all
yarn test
34 changes: 34 additions & 0 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy typedoc to GitHub Pages
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
name: "Deploy typedoc to GitHub Pages"
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Install nodejs 20'
uses: actions/setup-node@v2
with:
node-version: '20'
- name: 'Build and test'
run: |
corepack enable
yarn install
yarn typedoc
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs # The folder the action should deploy.
clean: true
single-commit: true

10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ coverage
node_modules
out
test.js
test.mjs
.direnv
tsconfig.tsbuildinfo
yarn-error.log
.mume
mume
.crossnote
crossnote
styles/**/*.css
docs
4 changes: 0 additions & 4 deletions .husky/post-checkout

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/post-commit

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/post-merge

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/post-rewrite

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
npx lint-staged
12 changes: 8 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@
!*.less
!*.md
!*.ts
!*.tsx
!*.yaml
!*.yml


## same as in .gitignore
.DS_Store
coverage
node_modules
out
test.js


## special cases
dependencies/**
!dependencies/README.md
styles
styles/*.css

test.js
test.mjs
test/markdown/test-files/**

src/prism/prism.js
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
This changelog is for the fork, not the [original mume library](https://github.com/shd101wyy/mume/).
This changelog is for the fork, not the [original crossnote library](https://github.com/shd101wyy/crossnote/).

## Unreleased

- Sync with upstream ([#43](https://github.com/gicentre/mume-with-litvis/pull/43))

## 0.34.0

Expand Down
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ _<https://github.com/shd101wyy/markdown-preview-enhanced>_
University of Illinois/NCSA
Open Source License

```txt
Copyright (c) 2017 Yiyi Wang
```
Copyright (c) 2017 ~ 2023 Yiyi Wang
All rights reserved.

Developed by: Yiyi Wang
https://github.com/shd101wyy/mume
https://github.com/shd101wyy/crossnote
```

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Mume with litvis
# Crossnote with litvis

[![Build Status](https://travis-ci.org/gicentre/mume-with-litvis.svg?branch=master)](https://travis-ci.org/gicentre/mume-with-litvis)
[![Build Status](https://travis-ci.org/gicentre/crossnote-with-litvis.svg?branch=master)](https://travis-ci.org/gicentre/crossnote-with-litvis)

This project is a fork of [`mume`](https://github.com/shd101wyy/mume), which is the cor library behind for [Markdown Preview Enhanced for Atom](https://atom.io/packages/markdown-preview-enhanced) and [Markdown Preview Enhanced for VSCode](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced#review-details).
Most of the code in this fork is inherited from the upstream repository and is thus courtesy of [@shd101wyy](https://github.com/shd101wyy) and other [contributors](https://github.com/shd101wyy/mume/graphs/contributors) to `mume`.
This project is a fork of [`crossnote`](https://github.com/shd101wyy/crossnote), which is the cor library behind for [Markdown Preview Enhanced for Atom](https://atom.io/packages/markdown-preview-enhanced) and [Markdown Preview Enhanced for VSCode](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced#review-details).
Most of the code in this fork is inherited from the upstream repository and is thus courtesy of [@shd101wyy](https://github.com/shd101wyy) and other [contributors](https://github.com/shd101wyy/crossnote/graphs/contributors) to `crossnote`.

The fork produces an npm module called [`mume-with-litvis`](https://www.npmjs.com/package/mume-with-litvis), which enables _Literate Visualisation_ ([litvis](http://litvis.org/)) in rendered markdown previews.
The fork produces an npm module called [`crossnote-with-litvis`](https://www.npmjs.com/package/crossnote-with-litvis), which enables _Literate Visualisation_ ([litvis](http://litvis.org/)) in rendered markdown previews.

Litvis functionality has been designed and developed at [giCentre](https://www.gicentre.net/) by [Jo Wood](https://github.com/jwoLondon), [Alexander Kachkaev](https://github.com/kachkaev) and [Jason Dykes](https://github.com/jsndyks).
This research was in part supported by the EU under the EC Grant Agreement No. FP7-IP-608142 to Project [VALCRI](http://valcri.org/).

## Setup

- [for Atom users](https://github.com/gicentre/markdown-preview-enhanced-with-litvis)
- [for VSCode users](https://github.com/gicentre/vscode-markdown-preview-enhanced-with-litvis)
9 changes: 9 additions & 0 deletions babel-jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('@babel/core').TransformOptions} */
module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: ['@babel/transform-runtime', 'babel-plugin-transform-import-meta'],
};
110 changes: 110 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
const { context, build } = require('esbuild');
const { dependencies, devDependencies } = require('./package.json');
const { tailwindPlugin } = require('esbuild-plugin-tailwindcss');

/**
* @type {import('esbuild').BuildOptions}
*/
const sharedConfig = {
entryPoints: ['./src/index.ts'],
bundle: true,
minify: true,
// sourcemap: true,
external: [
'fs',
'path',
'child_process',
'os',
'vm',
'stream',
'node:fs/promises',
'url',
// === from package.json
...Object.keys(dependencies),
...Object.keys(devDependencies),
],
};

/**
* @type {import('esbuild').BuildOptions}
*/
const cjsConfig = {
...sharedConfig,
platform: 'node', // For CJS
outfile: './out/cjs/index.cjs',
target: 'node16',
};

/**
* @type {import('esbuild').BuildOptions}
*/
const esmConfig = {
...sharedConfig,
// TODO: Support browser
platform: 'neutral', // For ESM
outfile: './out/esm/index.mjs',
};

/**
* @type {import('esbuild').BuildOptions}
*/
const webviewConfig = {
entryPoints: ['./src/webview/preview.tsx', './src/webview/backlinks.tsx'],
bundle: true,
minify: true,
platform: 'browser',
// outfile: './out/webview/index.js',
outdir: './out/webview',
loader: {
'.png': 'dataurl',
'.woff': 'dataurl',
'.woff2': 'dataurl',
'.eot': 'dataurl',
'.ttf': 'dataurl',
'.svg': 'dataurl',
},
plugins: [tailwindPlugin({})],
};

async function main() {
try {
if (process.argv.includes('--watch')) {
// CommonJS
const cjsContext = await context({
...cjsConfig,
sourcemap: true,
});

// ESM
const esmContext = await context({
...esmConfig,
sourcemap: true,
});

// Webview
const webviewContext = await context({
...webviewConfig,
sourcemap: true,
});

await Promise.all([
cjsContext.watch(),
esmContext.watch(),
webviewContext.watch(),
]);
} else {
// CommonJS
await build(cjsConfig);

// ESM
await build(esmConfig);

// Webview
await build(webviewConfig);
}
} catch (error) {
console.error(error);
}
}

main();
Loading