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

esbuild-plugin-wildcard-imports

v0.0.15

Published

Wildcard imports for esbuild.

Downloads

43

Readme

Coverage report


Limitations & Known issues

  • Only works with platform=node and bundle=true

  • The majority of the automated tests covers format=cjs

  • Dynamic imports with top-level await won't work with format=cjs

FAQ

  • Does it work with format=esm?

    • The esm output format was tested to the extent necessary to attain 100% code coverage; however, it was not thoroughly examined for all conceivable scenarios and opportunities.
  • Does format=cjs mean the plugin only works with a CommonJS codebase?

    • Not at all, you can use the plugin with your ES codebase. The format=cjs is about the esbuild output format. The library has been tested and works with ES modules.
  • Does it work with non-Node.js platforms?

    • I haven't had the time to write tests to cover non-Node.js platforms, so I intentionally limited the usage to on the Node.js for now.
  • Are there any plans to migrate it to Go?

    • Yes but I need to learn Go first.

Behaviors

  • The node_modules folders are always ignored.

  • Only the following kind of paths are supported:

    • dynamic-import
    • import-statement
    • require-call

    See https://esbuild.github.io/plugins/#on-resolve-arguments

  • It acts on paths containing one of these characters: ? + * { } [ ] ( ).

  • It uses fast-glob as the matching engine.

    See https://github.com/mrmlnc/fast-glob


Instalation

pnpm add esbuild-plugin-wildcard-imports --save-dev
yarn add esbuild-plugin-wildcard-imports --dev
npm install esbuild-plugin-wildcard-imports --save-dev

Usage examples

Basic use

import * as esbuild from 'esbuild'
import wildcardImports from 'esbuild-plugin-wildcard-imports'

await esbuild.build({
  plugins: [wildcardImports()]
})

With custom ignore patterns

import * as esbuild from 'esbuild'
import wildcardImports from 'esbuild-plugin-wildcard-imports'

await esbuild.build({
  plugins: [
    wildcardImports({
      ignore: ['**/{build,dist}', '**/foo', '**/bar']
    })
  ]
})

Options

| name | type | optional | notes | | ------ | ---------- | -------- | --------------------------- | | ignore | string[] | yes | same semantics of fast-glob |


Some examples where the plugin applies

  • CommonJS

  • ESM export aggregation

  • ESM import and re-export

  • ESM Dynamic Import