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

trans-loader

v0.2.0

Published

You don't need **npm** and **bundler**.

Readme

trans-loader

You don't need npm and bundler.

You need just a service-worker script.

What this script does...

  • Transform .js with babel on service-worker
  • Transform .ts and .tsx with typescript on service-worker
  • Load modules from jspm.io and cache them on serviceWorker.

CAUTION!

  • development only. Do not use for production.
  • It works only for modern browser(ES2015+ and ES Modules ready).

How to use

Put dist/sw.js as /sw.js on your app root.

wget https://raw.githubusercontent.com/mizchi/trans-loader/master/dist/sw.js

Rewrite your entry js like below.

Before

<script src="/main.js"></script>

After

<script type=module>
(async () => {
  const run = () => import('/main.js') // your entry js
  if (navigator.serviceWorker.controller) {
    run()
  } else {
    const reg = await navigator.serviceWorker.register("/sw.js");
    await navigator.serviceWorker.ready;
    navigator.serviceWorker.addEventListener('controllerchange', run)
  }
})()
</script>

See working demo

Example 1: Compiled with babel

// /your-entry.js
import React from "react";
import ReactDOM from "react-dom";
ReactDOM.render(<h1>Hello</h1>, document.querySelector(".root"));

Example 2: Load relative file

index.html
sw.js
main.js
components/App.js
// main.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";
ReactDOM.render(<App />, document.querySelector(".root"));

Example 3: Load typescript

index.html
sw.js
main.js
components/App.tsx
// main.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App.tsx"; // You need extension yet...
ReactDOM.render(<App />, document.querySelector(".root"));

Example 4: Loading with package.json's version

index.html
sw.js
main.js
package.json

package.json

{
  "dependencies": {
    "react": "16.4.1",
    "react-dom": "16.4.1"
  }
}

Log

trans-loader: Cache https://dev.jspm.io/[email protected]
trans-loader: Cache https://dev.jspm.io/[email protected]

How it works

Rewrite npm module path to dev.jspm.io. See this code

// before
import React from "react";
// after
import React from "https://dev.jspm.io/react";

Advanced: How to build your own trans-loader

Rewrite this babel setting and rebuild this project.

// src/transformWithBabel.js
import { transform } from "@babel/core/lib/transform";
import pluginSyntaxDynamicImport from "@babel/plugin-syntax-dynamic-import";
import flow from "@babel/preset-flow";
import react from "@babel/preset-react";
import rewriteModulePath from "./rewriteModulePath";

export function transformWithBabel(source, filename = "") {
  return transform(source, {
    presets: [flow, react],
    plugins: [
      pluginSyntaxDynamicImport,
      [
        rewriteModulePath,
        {
          filename
        }
      ]
    ]
  }).code;
}

TODO

  • Support package.json to load with version
  • Can load without extname for .ts

LICENSE

MIT