npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tsup-preset-solid

v2.2.0

Published

Preset for building your SolidJS package with tsup.

Downloads

13,929

Readme

tsup-preset-solid

pnpm npm downloads

Preset for building your SolidJS packages with ease using tsup (powered by esbuild).

Features

  • Preconfigured - Just install, set your entries and you're done.

  • Fast - Uses esbuild under the hood.

  • SolidStart support - Includes solid export condition with preserved JSX.

  • Best practices - Ensures that the built library works well with Solid's tooling ecosystem.

  • Development and server entries - Creates a separate entry for development, server-side rendering and production form a single source.

  • Multiple entries - Supports multiple package entries. (submodules)

  • Automatic package.json configuration - Automatically writes export fields to package.json based on passed options.

Warning This preset is tailored towards a specific usage, mainly for primitives libraries or small headless libraries, so diverging from the happy path may cause unexpected results. Please report any issues you find.

Quick start

Install it:

npm i -D tsup tsup-preset-solid
# or
pnpm add -D tsup tsup-preset-solid
# or
yarn add -D tsup tsup-preset-solid

Add it to your tsup.config.ts

// tsup.config.ts
import { defineConfig } from 'tsup'
import * as preset from 'tsup-preset-solid'

const preset_options: preset.PresetOptions = {
    // array or single object
    entries: [
        // default entry (index)
        {
            // entries with '.tsx' extension will have `solid` export condition generated
            entry: 'src/index.tsx',
            // set `true` or pass a specific path to generate a development-only entry
            dev_entry: 'src/dev.tsx',
            // set `true` or pass a specific path to generate a server-only entry
            server_entry: true,
        },
        {
            // non-default entries with "index" filename should have a name specified
            name: 'additional',
            entry: 'src/additional/index.ts',
            dev_entry: true,
        },
        {
            entry: 'src/shared.ts',
        },
    ],
    // Set to `true` to remove all `console.*` calls and `debugger` statements in prod builds
    drop_console: true,
    // Set to `true` to generate a CommonJS build alongside ESM
    cjs: false,
}

export default defineConfig(config => {
    const watching = !!config.watch

    const parsed_data = preset.parsePresetOptions(preset_options, watching)

    if (!watching) {
        const package_fields = preset.generatePackageExports(parsed_data)

        console.log(`\npackage.json: \n${JSON.stringify(package_fields, null, 2)}\n\n`)

        /*
            will update ./package.json with the correct export fields
        */
        preset.writePackageJson(package_fields)
    }

    return preset.generateTsupOptions(parsed_data)
})

Add required fields and scripts to your package.json

{
    "type": "module",
    "files": ["dist"],
    "scripts": {
        "build": "tsup",
        "dev": "tsup --watch"
    }
}

Usage gotchas

  1. solid export condition

    This preset will automatically add solid export condition to your package.json if you have any .tsx entry files. This is required for SolidStart to work properly.

  2. "type": "module"

    This preset requires your package to be a module.

  3. Needs ESM

    This preset requires your package to be ESM. If you want to support CJS additionally, you can set cjs: true in the options. Other export format are not supported.

  4. development-only solid export issue

    Currently SolidStart has an issue with development and solid export condition. (solid-start issue)

    This can be "fixed" by overriding the @rollup/plugin-node-resolve dependency in your package.json:

    {
        "pnpm": {
            "overrides": {
                "@rollup/plugin-node-resolve": "13.3.0"
            }
        }
    }