# lezer-loader

> Lezer loader module for webpack

Latest version **0.3.0** (published 2022-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install lezer-loader
pnpm add lezer-loader
yarn add lezer-loader
bun add lezer-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-06-26 |
| First published | 2022-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jared Hughes |
| Maintainers | jared-hughes |
| Keywords | webpack, lezer, loader |

## Links

- npm: https://www.npmjs.com/package/lezer-loader
- Repository: https://github.com/jared-hughes/lezer-loader
- Homepage: https://github.com/jared-hughes/lezer-loader#readme
- Issues: https://github.com/jared-hughes/lezer-loader/issues
- npm.io page: https://npm.io/package/lezer-loader

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2022-06-26
- 0.2.0 — 2022-06-12
- 0.1.0 — 2022-01-28

## README

# lezer-loader

Lezer loader module for webpack.

## Limitations

No options are supported yet.

`@external` imports in the grammar file do not get marked as webpack dependencies. If you need to re-build your grammar file based on the imports, just edit your grammar file to trigger the webpack re-build.

## Basic Usage

Usage, in `webpack.config.js`:

```js
{
  // ...
  module: {
    rules: [
      {
        test: /\.grammar$/,
        use: "lezer-loader",
      },
    ];
  }
  // ...
}
```

Usage, in your JavaScript files (supposing the file is named `syntax.grammar`):

```js
// editor.js
import parser from "./syntax.grammar";
```

For TypeScript declarations:

```ts
// syntax.grammar.d.ts
import { LRParser } from "@lezer/lr";

declare const parser: LRParser;
export default parser;
```

## External Token Usage

To reference external tokens, they have to first be defined in your grammar file:

```c
// syntax.grammar
@external tokens insertSemicolon from "./tokens" { insertSemi }
```

Then to import them:

```js
// tokens.js
import { insertSemi } from "./syntax.grammar";
```

For TypeScript declarations:

```ts
export const insertSemi: number;
```

---
_Source: https://npm.io/package/lezer-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
