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

@tdi/svcli

v0.0.24

Published

This is no more than a POC. A quickly written temporary solution for basic common setups until better tools arrive.

Downloads

5

Readme

Disclaimer

This is no more than a POC. A quickly written temporary solution for basic common setups until better tools arrive.

Commands

command | description |----|----| npx @tdi/svcli --setup | Interactively initialize/configure a svelte package with a few modular template options. npx @tdi/svcli --preprocess | Preprocess svelte files. Requires a svelte.config.js file which is created by npx @tdi/svcli --setup

Purpose

We aid in configuring a few basics for svelte-preprocess, postcss, tailwind, typescript, eslint, mdsvex, and svelte-check. Additionally, we try to preprocess your svelte files so they can be truly sharable.

We install npm packages, create initial config files or interactive diff update existing files. Some things, notably rollup, will have a config snippets dumped to terminal for copy/paste into actual config since we do not currently support updating them directly.

svelte.config.js

We currently add a few non-standard properties to svelte.config.js. Note that their names may spontaneously change in future versions. The reasoning behind their inclusion are below

Property | Type | Description |------|----|---| outDir | string | Where to output/save the preprocessed files. srcDir | string | Where to look for the original source files to process. Note that we search a directory for all matching files. This is vastly different than webpack/rollup which are given entrypoint files and walk all imports. extensions | string[] | File extensions to preprocess. copyFileGlob | Glob[] | Globs matching all files we should copy over to the output directory. This will only match files inside srcDir and will not match any files we preprocess nor any that match the copyExcludeFileGlob. If you have js files, you will need ./**/*.js in here. Any non svelte import that isn't handled by another preprocessor will need a glob to copy it. copyExcludeFileGlob | Glob[] | Globs matching all files we should not copy over, even if they match a copyFileGlob. Exists to allow copyFileGlob to be more permissive and match everything if need be. This should be set to match any files a preprocessor will run on, like ./**/*.ts.

Note that unless copyFileGlob only matches js files, your component is likely not sharable without the end dev modifying their bundler. Unfortunately, svelte's ecosystem is small for more than 1 reason atm, and shareability of components is certainly 1 of them. If you have css/image/audio/video/json/etc imports, you should be able to utilize svelte-preprocess's babel support to eliminate them instead of your bundler.

copyFileGlob/copyExcludeFileGlob will be renamed or removed in future version. They will exist until I figure out how to handel non svelte/js imports properly (ie. until I learn how to babel like a madman). Utilizing babel for imports might hurt chunking performance since the goto solution involves inlining.

Note that the end dev's bundler configuration will run on us as well, including their svelte preprocessors. There is currently no way to scope svelte preprocessors to your own project in rollup. This probably isn't a big deal for most use cases, but could cause problems.

Preprocessing Example

Create the svelte.config.js file appropriately

// svelte.config.js
const sveltePreprocess = require("svelte-preprocess")
const {mdsvex} = require("mdsvex")

const createPreprocessors = ({sourceMap}={})=>{
  return [
    sveltePreprocess({
      sourceMap: sourceMap ?? false,
      typescript: true,
      postcss:true
    }),
    mdsvex()
  ]
}
module.exports={
  "createPreprocessors": createPreprocessors,
  "preprocess": createPreprocessors({sourceMap: true}),
  "extensions": [".svelte",".svx"],
  "outDir": "./out",
  "srcDir": "./src",
  "copyFileGlob": [
    "./src/**/*.js",
  ],
  "copyExcludeFileGlob": [
    "./src/**/*.ts",
    "./src/**/*.tsx",
    "./src/**/*.css",
    "./src/**/*.pcss",
    "./node_modules/**/*",
  ] ,
}

Once configured, you can simply run svcli

# Clear the output directory. (currently a required step)
npx @tdi/svcli --clean
# Preprocess all svelte files. (also copies any file matching copyFileGlob)
npx @tdi/svcli --preprocess
# Compile any other files you require, such as typescript, with the appropriate tools.
tsc --outDir ./out