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

snowpack-plugin-json5

v1.0.0

Published

Snowpack plugin for using json5

Downloads

5

Readme

snowpack-plugin-json5

Snowpack plugin for using json5.

What it does

When developing web applications, we often use JSON files in order to define content (e.g. for internationalization) or extract some form of configuration. Especially in the former case, we usually end up with one or more huge JSON files, probably a couple or hundred or even thousand lines long.

Using json5 over plain json can help organizing, structuring and maintaining those files, e.g. by using comments, custom line breaks and trailing commas (amonst other features).

Meet the snowpack-plugin-json5, a plugin for Snowpack that allows you to import .json5 files just like you would import json5 files. Think of it as the Snowpack equivalent for the json5-loader for Webpack.

How to install

You can get the snowpack-plugin-json5 via npm by either adding it as a new devDependency to your package.json file and running npm install, or running the following command:

npm install snowpack-plugin-json5

Note: This plugin is only compatible with Snowpack version 3.x.

How to setup

To use snowpack-plugin-json5, add it to the list of plugin in your snowpack.config.js file. For example:

  /** @type {import("snowpack").SnowpackUserConfig } */
  module.exports = {
    plugins: [
+     'snowpack-plugin-json5'
    ],
  };

If you are using TypeScript, you must also define .json as a known module type. To do so, add the following declaration to your custom types file (a file ending with .d.ts, sometimes called typings.d.ts or static.d.ts):

declare module '*.json5' {
  const value: any;
  export default value;
}

How to use

Once installed and setup, importing .json5 files works exactly like importing .json files by using default imports (see Snowpack documentation for importing json files). For example:

import de from './assets/de.json5';
import en from './assets/en.json5';

// ... use the values ...