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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@paulio/shadow-svelte

v0.1.1

Published

P71: Svelte pre-processor enabling quick access to Svelte & SvelteKit functions through auto import.

Readme

Made to be Plundered Latest version Release date

P71: Shadow Svelte

Svelte pre-processor enabling quick access to Svelte & SvelteKit functions through auto import.

Default mappings for functions. You can modify the mappings and aliases via the customise pre-processor option.

Very simple implementation using regular expressions. Quick side project, thus CBA to do proper JavaScript parsing.

Usage

svelte.config.js

import shadowSvelte from '@paulio/shadow-svelte'

export default {
	preprocess: [shadowSvelte()],
}

Component.svelte

<script>
	const store = $writableStore(123)

	$onMount(() => {
		// ...
	})
</script>

Component.svelte (after pre-processing)

Because imported functions are aliased, there should be no conflict with the same manually imported function.

<script>
	import { onMount as __shadowSvelte__svelte__onMount } from 'svelte'
	import { writable as __shadowSvelte__svelte_store__writable } from 'svelte/store'

	const store = __shadowSvelte__svelte_store__writable(123)

	__shadowSvelte__svelte__onMount(() => {
		// ...
	})
</script>

Options

import shadowSvelte from '@paulio/shadow-svelte'

shadowSvelte({
	// Function allowing you to add, remove, and modify
	// mappings.
	customise: (mappings) => mappings,
})

Customise Mappings

svelte.config.js

import shadowSvelte from '@paulio/shadow-svelte'

export default {
	preprocess: [
		shadowSvelte({
			customise: (mappings) => {
				renameTickToTock(mappings)
				removeOnMount(mappings)
				addOnMountAsOnLoad(mappings)
				addObjectFreezeAsIced(mappings)
				return mappings
			},
		}),
	],
}

function findMappingIndexByKeyword(mappings, keyword) {
	for (let i = 0; i < mappings.length; i++) {
		if (mappings[i].keyword === keyword) {
			return i
		}
	}

	return -1
}

function renameTickToTock(mappings) {
	const index = findMappingIndexByKeyword('tick')
	mappings[index].keyword = 'tock'


function removeOnMount(mappings) {
	const index = findMappingIndexByKeyword('onMount')
	mappings.splice(index, 1)
}

function addOnMountAsOnLoad(mappings) {
	mappings.push({
		keyword: 'onLoad',
		name: 'onMount',
		// Unique enough to avoid naming conflicts
		as: '__shadowSvelte__svelte__onMount_as_onLoad',
		from: 'svelte',
	})
}

function addObjectFreezeAsIced(mappings) {
	mappings.push({
		keyword: 'iced',
		as: 'Object.freeze',
	})
}

Default Mappings

Default mappings. You can also modify the mappings via the customise pre-processor option.

{
	// $keyword: "The real function name"

	// 'svelte'
	$createContext: "createContext",
	$dispatcher: "createEventDispatcher",
	$flushSync: "flushSync",
	$fork: "fork",
	$getAbortSignal: "getAbortSignal",
	$getAllContext: "getAllContext",
	$getContext: "getContext",
	$hasContext: "hasContext",
	$hydratable: "hydratable",
	$hydrate: "hydrate",
	$mount: "mount",
	$onDestroy: "onDestroy",
	$onMount: "onMount",
	$rawSnippet: "createRawSnippet",
	$setContext: "setContext",
	$settled: "settled",
	$tick: "tick",
	$unmount: "unmount",
	$untrack: "untrack",

	// 'svelte/store'
	$writableStore: "writable",
	$readableStore: "readable",
	$readonlyStore: "readonly",
	$derivedStore: "derived",
	$getStoreValue: "get",

	// Console aliases
	$log: "console.log",
	$info: "console.info",
	$warn: "console.warn",
	$error: "console.error",
}

Made to be Plundered

Alternatively, Copy & paste files from /src into your project. Tests are written in Jest but should be easy to adapt or rewrite for whatever testing framework.