# @dumbjs/preland

Latest version **0.0.4** (published 2026-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dumbjs/preland
pnpm add @dumbjs/preland
yarn add @dumbjs/preland
bun add @dumbjs/preland
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2026-04-09 |
| First published | 2023-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 71.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 11 |
| Maintainers | barelyreaper |

## Links

- npm: https://www.npmjs.com/package/@dumbjs/preland
- Repository: https://github.com/dumbjs/preland
- Homepage: https://github.com/dumbjs/preland#readme
- Issues: https://github.com/dumbjs/preland/issues
- npm.io page: https://npm.io/package/@dumbjs/preland

## Dependencies (9)

- [acorn](https://npm.io/package/acorn.md) ^8.16.0
- [sucrase](https://npm.io/package/sucrase.md) ^3.35.1
- [acorn-jsx](https://npm.io/package/acorn-jsx.md) ^5.3.2
- [acorn-walk](https://npm.io/package/acorn-walk.md) ^8.3.5
- [acorn-jsx-walk](https://npm.io/package/acorn-jsx-walk.md) ^2.0.0
- [acorn-class-fields](https://npm.io/package/acorn-class-fields.md) ^1.0.0
- [acorn-import-assertions](https://npm.io/package/acorn-import-assertions.md) ^1.9.0
- [@barelyhuman/astring-jsx](https://npm.io/package/@barelyhuman/astring-jsx.md) ^2.0.4
- [acorn-static-class-features](https://npm.io/package/acorn-static-class-features.md) ^1.0.0

## Recent versions

- 0.0.4 (latest) — 2026-04-09
- 0.0.0-beta.14 (beta) — 2024-07-11
- 0.0.2 — 2024-10-22
- 0.0.1 — 2024-10-18
- 0.0.0-beta.13 — 2024-07-11
- 0.0.0-beta.12 — 2024-07-11
- 0.0.0-beta.11 — 2024-04-03
- 0.0.0-beta.10 — 2024-03-22
- 0.0.0-beta.9 — 2024-03-21
- 0.0.0-beta.8 — 2024-02-14
- 0.0.0-beta.7 — 2024-02-14
- 0.0.0-beta.6 — 2023-11-25
- 0.0.0-beta.5 — 2023-11-24
- 0.0.0-beta.4 — 2023-11-14
- 0.0.0-beta.3 — 2023-11-14
- … 4 more at https://npm.io/package/@dumbjs/preland/versions

## README

<p align="center">
    <img width="1200" alt="header" src="https://github.com/dumbjs/preland/assets/43572006/49e9d708-4b88-4922-9094-7ad25d53906e">
</p>

> **Pre**act Is**land**

Framework Agnostic utils to generate atomic islands for preact components

- [What is this?](#what-is-this)
- [Highlights](#highlights)
- [Usage](#usage)
- [API](#api)
  - [`@dumbjs/preland`](#dumbjspreland)
  - [`@dumbjs/preland/ast`](#dumbjsprelandast)
- [License](#license)

## What is this?

`preland` is a set of utilities that allow you to `read`, `find` , `transform`
and `generate` island components for preact. None of the utlities in this set
have any dependency on any bundler or framework and just statically analyse the
given code to look for preact islands.

## Highlights

- Tiny
- Supports [Typescript](https://www.typescriptlang.org)
- Handles individual named island exports from the same file
- Provides utils to help parse and generate preact compatible ASTs and add
  `imports` to it

## Usage

- Installation as simple as adding `@dumbjs/preland` to your dependencies.

  ```sh
  $ npm i @dumbjs/preland
  ```

## API

### `@dumbjs/preland`

```ts
export function readSourceFile(file: any): any
export function findIslands(sourceCode: any): {
  id: any
  node: any
  nodeItem: any
}[]
export function islandNodeToTemplate(island: any): {
  server: any
  client: string
}
export function getExportedNodes(astBody: any): any
export function generateServerTemplate(name: any): string
export function generateClientTemplate(name: any): string
/**
 *
 * @param {import("acorn").Node} functionAST
 * @param {object} options
 * @param {string[]} options.transpiledIdentifiers , identifiers to look for when
 * searching the function ast. These are generally `_jsx` and `_jsxs` when working with
 * the `automatic` JSX Runtime in bundlers but might differ in your scenario
 * @returns
 */
export function isFunctionIsland(
  functionAST: import('acorn').Node,
  {
    transpiledIdentifiers,
  }?: {
    transpiledIdentifiers: string[]
  }
): boolean
export function getIslandName(name: any): string
export const DEFAULT_TRANSPILED_IDENTIFIERS: string[]
```

### `@dumbjs/preland/ast`

```ts
export function walker(ast: any, visitors: any): void
export function astFromCode(code: any): import('acorn').Program
export function codeFromAST(ast: any): any
/**
 * Takes in an AST node and returns the name of the default
 * export for it
 * @param {*} ast
 * @returns
 */
export function getDefaultExportName(ast: any): any
export function getDefaultExport(ast: any): any[]
/**
 * NOT A PURE FUNCTION!
 * modifies the passed AST with the
 * requested import
 *
 * Note:
 * This function does not rename / or add a new identifier for the
 * requested import as that could add in a lot more complexity
 * and is easier handled in the user land. Changing and renaming
 * import specifier would also need proper tranformation to be handled
 * for cases where the imports might be responsible for things
 * like JSX.
 * @returns
 */
export function addImportToAST(ast: any): (
  name: string,
  from: string,
  {
    named,
  }: {
    named: boolean
  }
) => void
export function getNamedExport(ast: any, name: any): any
/**
 * NOT A PURE FUNCTION!
 * removes the export from the passed AST
 */
export function removeExportFromAST(ast: any): (
  name: string,
  options: {
    named: boolean
  }
) => void
export function isTopLevelFunction(parents: any): any
```

## License

[MIT](/LICENSE)

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