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

@hpcc-js/vite-plugins

v1.5.2

Published

Various vite plugins

Readme

@hpcc-js/vite-plugins

Build Dojo 1.x AMD applications with Vite.

This package provides the dojo() Vite plugin that resolves Dojo module ids with the real Dojo loader config at build time, transforms AMD modules into an ESM graph for Rollup/Vite, and preserves Dojo runtime behavior where needed.

This plugin is based on the excellent work of dojo-webpack-plugin.

Install

vite and dojo are peer dependencies.

npm install --save-dev @hpcc-js/vite-plugins vite
npm install --save dojo

If your app uses Dijit/DojoX widgets, also install those packages:

npm install --save dijit dojox dojo-util

Usage

// vite.config.ts
import { defineConfig } from "vite";
import { dojo } from "@hpcc-js/vite-plugins";

export default defineConfig({
    plugins: [
        dojo({
            loaderConfig: {
                baseUrl: ".",
                paths: { app: "src" },
                packages: [
                    { name: "dojo", location: "./node_modules/dojo" },
                    { name: "dijit", location: "./node_modules/dijit" },
                    { name: "dojox", location: "./node_modules/dojox" }
                ]
            },
            locales: ["en", "de"]
        })
    ]
});
// src/main.js
define(["dojo/dom", "dojo/text!app/banner.txt"], function (dom, banner) {
    dom.byId("banner").textContent = banner;

    // Async require becomes a split chunk.
    require(["app/about"], function (about) {
        console.log(about.text);
    });
});
<script type="module" src="./src/main.js"></script>

Demo App

The package includes a full sample app in tests-demo/ that exercises:

  • declarative Dijit layout with dojo/parser
  • dojo/has!
  • dojo/text!
  • dojo/i18n!
  • async require([...]) chunking

When using Dijit themes, set build.cssMinify: false. Dijit stylesheets still include legacy IE declarations (for example #zoom: 1) that Vite's default CSS minifier rejects.

Options

dojo({
    loaderConfig,
    environment,
    buildEnvironment,
    locales,
    coerceUndefinedToFalse,
    runtimeFeatures,
    async,
    esmInterop,
    globalContext,
    globalRequireMode,
    moduleReplacement
});
  • loaderConfig (required): Dojo loader config object, a function of environment, or a module id exporting either.
  • environment: Passed to loaderConfig when loaderConfig is a function.
  • buildEnvironment: Build-time override for environment.
  • locales: Locales to include for dojo/i18n! roots. Defaults to all locales in the root bundle. Use [] for root only.
  • coerceUndefinedToFalse: Treat undefined has features as false at build time.
  • runtimeFeatures: has feature names that must be evaluated at runtime even if present in loader config.
  • async: Allow proxied loader extensions to resolve asynchronously on the client.
  • esmInterop: How ESM dependencies are passed into AMD factories. "default" (default) unwraps default export, "namespace" passes namespace object.
  • globalContext: Path used to resolve relative mids passed to free/global require(...). Defaults to Vite root.
  • globalRequireMode: "reference" (default) or "context" for how global require dependencies are resolved.
  • moduleReplacement: Array of replacement rules { test: RegExp, replace } for resolved absMids.

Built-in replacements:

| Module id | Replaced with | | ------------------------------- | -------------------- | | dojo/selector/_loader!default | dojo/selector/lite | | dojo/request/default! | dojo/request/xhr |

Loader Extensions

| Extension | Handling | | ------------- | -------- | | dojo/has! | Evaluated at build time when possible, otherwise emitted as runtime conditional over statically imported branches | | dojo/text! | Inlined as a string | | dojo/i18n! | Emits root and selected locale bundles, then resolves through dojo/i18n runtime logic | | other plugin ids | Proxied to runtime via loader load() |

For loaders that require sync access to additional deps, use dojo/loaderProxy in a replacement rule.

Declarative Widgets and dojo/parser

dojo/parser resolves data-dojo-type module ids from markup at runtime, so those ids do not appear in static imports automatically. Include those widget modules in an AMD dependency array somewhere in your graph so they are bundled and registered.

Runtime and CSP

The plugin evaluates AMD module bodies with new Function(...) so Dojo modules that depend on sloppy mode behavior (notably dojo/_base/declare) continue to work.

This means:

  • script-src CSP must allow unsafe-eval.
  • module bodies are preserved as source strings, with sourceURL comments for debugging.

Package Exports

  • @hpcc-js/vite-plugins: plugin entry (dojo) and public types.
  • @hpcc-js/vite-plugins/runtime: runtime module export.

Tests

Vitest test projects are defined in vitest.config.ts.

npm test
npm run test-node
npm run test-browser
DOJO_TEST_FILTER=loaders npm test

Test cases live under tests/TestCases/ and are built with Vite before execution.

Development Scripts

npm run clean
npm run build
npm run watch
npm run bundle
npm run bundle-watch
npm run bundle-serve
npm run build:example
npm run preview:example
npm run lint
npm run docs
npm run coverage

Notes:

  • build runs both type generation and Vite bundling.
  • build:example and preview:example currently target example/vite.config.ts.
  • the checked-in demo app is in tests-demo/.

License

Apache-2.0