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

esdev

v0.1.1

Published

Tiny process to transform files and serve them transformed, that's all. The rest is up to you.

Downloads

5

Readme

esdev

Tiny process to transform files and serve them transformed, that's all. The rest is up to you.

yarn add esdev -D
  • Default support to Typescript, JSX and Vue files. Ready to use out-of-the-box.
  • Small footprint. Esdev only relies on two packages, acorn and mime, with esbuild as the default transformer.
  • No need to serve the build folder. Everything works from the root of your package and can be served static.
  • Extendable. Use your own transformers. Your own serve tool, your own minifier... No lock-in at all !
  • Rely on the Modern Web specification, from modules to WICG/import-maps.
  • No resolver algorithm. It's handled natively by the browser, without extra-cost.
  • Hot reloading using servor.

Can be seen as an alternative to vite or snowpack.

Use

  1. Add build-import-map.json to map original files with transpiled ones.
<script type="module" src="build/build-import-map.json"></script>
  1. Serve your files using servor. It watch your files, transpile and reload your browser on changes.
esdev serve
  1. Build.
esdev build
  1. Optional. Build on changes, this is useful if you want to use your own choice of tool to serve your files.
esdev watch

Config API

A esdev.config.js file at the root of your project (same directory as index.html) is used to configure the transformers and other esdev options.

module.exports = {
  outputDir: "./build/",   // Where to store the compiled native files and the build import-map
  inputDir: "./src/", // Where to apply the transformers
  transformers: {
    [EXTENSION_NAME]: (string) => {
      body: [NEW_STRING],
      "Content-Type": [NEW_NATIVE_CONTENT_TYPE], // Must be a Content-Type known by the browser
      postTransform: [EXTENSION_NAME_1, EXTENSION_NAME_2] // Post apply registered transformers
    },
  }
};

Below the default esdev.config.js, it registers transformers for Vue-SFC, JSX and Typescript files using esbuild and a custom Vue Compiler:

const esbuildTransform = async (string, loader) => {
  const esbuild = (await import("esbuild")).default;
  const service = await esbuild.startService();
  const { js } = await service.transform(string, { loader });
  service.stop();
  return { body: js, "Content-Type": "application/javascript" };
};

module.exports = {
  outputDir: "./build/",
  inputGlob: "./src/**/*",
  jsx: (source) => esbuildTransform(source, "jsx"),
  tsx: (source) => esbuildTransform(source, "tsx"),
  ts: (source) => esbuildTransform(source, "ts"),
  vue: (source) => ({
    body: vueCompile(source),
    "Content-Type": "application/javascript",
    postTransform: ["ts"],
  }),
};

But you can also decide to transform txt files like so:

module.exports = {
  transformers: {
    txt: (source) => ({
      body: `export default \`${source.replace(/`/g, '\\`')}\``,
      "Content-Type": "application/javascript",
    })
  }
}

It's up to you !

Import Maps

For now you may need to polyfill the WICG/import-maps spec. You can add the es-module-shims polyfill using the Heritage package manager, using Snowpack or via the CDN.

heritage add es-module-shims
<script defer src="web_modules/es-module-shims/0.4.6/es-module-shims.js"></script>
<script type="importmap-shim" src="build/build-import-map.json"></script>
<script type="module-shim">
  import App from "./index.tsx";
</script>

That's all.

Information

To have the command esdev available you need to have yarn binor npm bin in your PATH like so:

export PATH=$(yarn bin):$PATH

Otherwise you need to use this command ./node_modules/.bin/esdev from the root of your package.

Limitation