Skip to content

Commit

Permalink
Add exportName option to rollup plugin
Browse files Browse the repository at this point in the history
FEATURE: Support an `exportName` option to the Rollup plugin.

Closes #18
See https://discuss.codemirror.net/t/is-there-anyway-to-configure-exportname-when-using-rollup/7594
  • Loading branch information
marijnh committed Jan 8, 2024
1 parent 2051c4f commit c5de538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -22,4 +22,6 @@ export default {
}
```

The plugin can be passed `lezer({exportName})` option to configure the name of the parser export.

The code is licensed under an MIT license.
3 changes: 2 additions & 1 deletion src/rollup-plugin-lezer.js
Expand Up @@ -2,7 +2,7 @@ import {resolve, dirname} from "path"
import {promises as fs} from "fs"
import {buildParserFile} from "./index.js"

export function lezer() {
export function lezer(config = {}) {
let built = Object.create(null)

return {
Expand All @@ -23,6 +23,7 @@ export function lezer() {
let build = built[base] || (built[base] = fs.readFile(base, "utf8").then(code => buildParserFile(code, {
fileName: base,
moduleStyle: "es",
exportName: config.exportName,
warn: message => this.warn(message)
})))
return build.then(result => m[2] ? result.terms : result.parser)
Expand Down

0 comments on commit c5de538

Please sign in to comment.