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

feat: move to ESM #29

Merged
merged 53 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6c42331
feat(org-cite): add org-cite types
tefkah Mar 19, 2022
ab4269d
feat(esm): change package locks
tefkah Mar 29, 2022
8792baa
feat(esm): change compile target to esm
tefkah Mar 29, 2022
52633d5
feat(esm): make build succesful with esm target
tefkah Mar 29, 2022
1a3f307
feat(esm): update @types/jest
tefkah Mar 29, 2022
ffe45d6
feat(esm): update [email protected]
tefkah Mar 29, 2022
6828920
feat(esm): recklessly update all unified deps
tefkah Mar 29, 2022
16b4e2a
feat(esm): make uniorg-parse compile
tefkah Mar 29, 2022
cfb0a56
fix(esm): add ignores to uniorg-rehype for now
tefkah Mar 30, 2022
ca5ef3d
fix: update jest
tefkah Apr 1, 2022
74c3e92
fix(esm): make tests run
tefkah Apr 1, 2022
8276c9c
fix(esm): make tests run
tefkah Apr 1, 2022
7df5354
fix: fix most import bugs
tefkah Apr 1, 2022
6b064f7
fix: make org-stringify pass test by ignoring incorrect property
tefkah Apr 1, 2022
6ea8a73
fix: make uniorg slug run by expecting error
tefkah Apr 1, 2022
0c2f2fb
fix: type issues in org-to-hast
tefkah Apr 4, 2022
f8eb6ee
fix: type of org2rehype plugin
tefkah Apr 4, 2022
1711676
fix: fix uniorg-rehype types
tefkah Apr 4, 2022
cf9d130
fix: uniorg-parse types
tefkah Apr 4, 2022
d3999b1
fix: remove fixed ts-expect-error uniorg-slug
tefkah Apr 4, 2022
fd51ac1
fix: fix types orgast-util-to-string
tefkah Apr 4, 2022
97c9e1e
fix: add possible type in org-parse
tefkah Apr 4, 2022
1d75f67
fix: make code not have children
tefkah Apr 4, 2022
db562ef
revert: make code have children
tefkah Apr 4, 2022
797d349
fix: actually fix types orgast-util-to-string
tefkah Apr 4, 2022
ed1b8a3
fix: pass all tests
tefkah Apr 4, 2022
d24250b
fix: change old apis in examples
tefkah Apr 4, 2022
5026307
fix: update lock file
tefkah Apr 4, 2022
beaa0ca
fix: actually use the correct version of unified
tefkah Apr 4, 2022
5c6ae83
fix: update locks and node version
tefkah Apr 4, 2022
8f191dd
fix: add ts-expect-errors for raw html nodes
tefkah Apr 4, 2022
074e6cf
fix: don't add tests to the build
tefkah Apr 4, 2022
3e85b80
fix: actually save files before commiting
tefkah Apr 4, 2022
85539f5
fix: update the package locks to 16 AGAIN
tefkah Apr 4, 2022
41e2c1b
fix: update the package locks to 16 AGAIN
tefkah Apr 4, 2022
38a8b33
fix: rearrange tsconfigs
tefkah Apr 5, 2022
ddb0623
fix: change npm install to ci
tefkah Apr 5, 2022
57ea5a2
fix: upgrade lerna because GH actions looooooves 4.0 so much
tefkah Apr 5, 2022
7d7c114
fix: change ci arbitrarily
tefkah Apr 5, 2022
8273b17
fix: don't mispellt
tefkah Apr 5, 2022
115191e
fix: add orgast-util-to-string to ts paths
tefkah Apr 5, 2022
fcb55ad
fix: add lerna link step
tefkah Apr 5, 2022
16aef34
fix: maybe bootstrap is kinda important
tefkah Apr 5, 2022
f315d31
fix: hmmm maybe if i change the package locks again
tefkah Apr 5, 2022
e8ca9fb
fix: i don't even know anymore man
tefkah Apr 5, 2022
0c5ef06
Merge remote-tracking branch 'origin/feat/esm' into 'origin/master'
rasendubi Apr 9, 2022
64c2643
Revert "feat(org-cite): add org-cite types"
rasendubi Apr 9, 2022
6c48632
docs: remove the note about ESM
rasendubi Apr 9, 2022
e3a36df
fix: specify file extension in all relative imports
rasendubi Apr 10, 2022
08ae355
fix(org-braindump): fix file renaming
rasendubi Apr 10, 2022
861e797
fix(extract-keywords-example): fix example
rasendubi Apr 10, 2022
5886deb
refactor: cleanup
rasendubi Apr 10, 2022
b6490ff
fix: Paragraph is not a GreaterElement
rasendubi Apr 10, 2022
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
32 changes: 10 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The rest of the syntax should work fine and exactly the same way as in Emacs (in
# Packages

This repository contains the following packages:

- [`uniorg`][uniorg] — Typescript definitions of uniorg syntax tree
- [`uniorg-parse`][uniorg-parse] — Parse org-mode files to uniorg syntax trees
- [`uniorg-stringify`][uniorg-stringify] — Stringify uniorg syntax tree to org-mode string
Expand Down Expand Up @@ -85,15 +86,12 @@ uniorg is compatible with [unified](https://github.com/unifiedjs/unified) ecosys
For example, here's how you transform an org-mode to html.

```js
import unified from 'unified';
import { unified } from 'unified';
import parse from 'uniorg-parse';
import uniorg2rehype from 'uniorg-rehype';
import stringify from 'rehype-stringify';

const processor = unified()
.use(parse)
.use(uniorg2rehype)
.use(stringify);
const processor = unified().use(parse).use(uniorg2rehype).use(stringify);

processor
.process(`* org-mode example\n your text goes here`)
Expand All @@ -103,7 +101,7 @@ processor
Plugins for code syntax highlight ([rehype-highlight](https://github.com/rehypejs/rehype-highlight), [@mapbox/rehype-prism](https://github.com/mapbox/rehype-prism)) and latex-formatting ([rehype-katex](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex), [rehype-mathjax](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-mathjax)) should work out of the box:

```js
import unified from 'unified';
import { unified } from 'unified';
import parse from 'uniorg-parse';
import uniorg2rehype from 'uniorg-rehype';
import highlight from 'rehype-highlight';
Expand All @@ -117,28 +115,18 @@ const processor = unified()
.use(katex)
.use(stringify);

processor.process(`* org-mode example
processor
.process(
`* org-mode example
When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

#+begin_src js
console.log('uniorg is cool!');
#+end_src
`).then((file) => console.log(file.contents));
```

# A note about ESM

unified ecosystem has just migrated to pure ESM packages. However, the ESM support across JS ecosystem is still immature.

- [Next.js 11.1 has just landed ESM support as an experimental feature](https://nextjs.org/blog/next-11-1#es-modules-support)
- [Gatsby still does not support ESM](https://github.com/gatsbyjs/gatsby/discussions/31599)

Of course, there are workarounds but I believe that moving to pure ESM packages is more pain to the users at this point. That’s why uniorg is still using commonjs packages. However, **this makes uniorg incompatible with the latest versions of unified packages.**

**If you install packages from unified ecosystem (e.g., unified, vfile, to-vfile), you should pin them to the previous major version as follows:**
```sh
npm install unified@9 vfile@4 to-vfile@6
`
)
.then((file) => console.log(file.contents));
```

# License
Expand Down
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

12 changes: 6 additions & 6 deletions examples/example/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var unified = require('unified');
var createStream = require('unified-stream');
var uniorgParse = require('uniorg-parse');
var uniorg2rehype = require('uniorg-rehype');
var html = require('rehype-stringify');
import { unified } from 'unified';
import { stream } from 'unified-stream';
import uniorgParse from 'uniorg-parse';
import uniorg2rehype from 'uniorg-rehype';
import html from 'rehype-stringify';

var processor = unified().use(uniorgParse).use(uniorg2rehype).use(html);

process.stdin.pipe(createStream(processor)).pipe(process.stdout);
process.stdin.pipe(stream(processor)).pipe(process.stdout);
Loading