Skip to content

Commit

Permalink
Merge pull request #347 from aminwhat/patch-1
Browse files Browse the repository at this point in the history
Update +page.md
  • Loading branch information
elijah-potter authored Jan 2, 2025
2 parents b56af6b + 613d0a2 commit dd32dc7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let harper = require('harper.js');
import * as harper from 'harper.js';

async function main() {
// We cannot use `WorkerLinter` on Node.js since it relies on web-specific APIs.
Expand Down
4 changes: 2 additions & 2 deletions packages/harper.js/examples/commonjs-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node index.cjs"
"start": "node index.js"
},
"dependencies": {
"harper.js": "^0.13.0"
"harper.js": "^0.14.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Today, it serves as the foundation for our [Obsidian plugin](/docs/integrations/
`harper.js` is an ECMAScript module designed to be easy to import into any project.
On the inside, it uses a copy of Harper's core algorithm compiled to [WebAssembly](https://webassembly.org/).

It can be imported [natively in a browser](./CDN) or through [npm](https://www.npmjs.com/package/harper.js).
It can be imported [natively in a browser](./CDN) or through [npm](https://www.npmjs.com/package/harper.js) and [consumed in Node.js](./node).

@install-pkg(harper.js)
15 changes: 15 additions & 0 deletions packages/web/src/routes/docs/harperjs/node/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Using Harper in Node.js
---

Harper.js can run in Node.js.
There is just one consideration: as described in [more detailed here](./linting), we cannot use the `WorkerLinter`.
That means we must use the `LocalLinter`.

Additionally, since `harper.js` is an ECMAScript module, it must be imported in a relatively recent version of Node.js.

## Example Code

The example below can be found in [the Harper monorepo.](https://github.com/Automattic/harper/tree/master/packages/harper.js/examples/commonjs-simple)

@code(../../../../../../harper.js/examples/commonjs-simple/index.js)
4 changes: 4 additions & 0 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export default defineConfig({
title: 'Linting',
to: '/docs/harperjs/linting'
},
{
title: 'Node.js',
to: '/docs/harperjs/node'
},
{
title: 'CDN',
to: '/docs/harperjs/CDN'
Expand Down

0 comments on commit dd32dc7

Please sign in to comment.