@vgpu/wgsl weekly downloads statistics
By vgpu · npm · Vite plugins
WGSL shader compilation, runtime resolution, and webpack/vite loaders for vgpu.
@vgpu/wgsl has 422,990 recorded weekly downloads on npm, an increase of 8.7% over the past 30 days, ranking #421 of 3,247 tracked listings.
About @vgpu/wgsl
@vgpu/wgsl
@vgpu/wgsl turns WGSL files into JavaScript shader-source modules and resolves WGSL-to-WGSL imports before bundling. It includes a resolver/runtime, webpack and Vite integrations, and a TypeScript ambient-types sub-export for import shader from "./shader.wgsl".
The resolver preserves shader entry-point names for WebGPU pipeline creation while mangling non-entry helpers and imports to avoid cross-module symbol collisions. Loader integrations also wire transitive .wgsl imports into bundler watch/HMR systems.
Installation
pnpm add @vgpu/wgsl
npm install @vgpu/wgsl
yarn add @vgpu/wgsl
TypeScript setup
Add a project .d.ts file (for example wgsl-env.d.ts):
/// <reference types="@vgpu/wgsl/wgsl-types" />
Or add the package type to tsconfig.json:
{
"compilerOptions": {
"types": ["@vgpu/wgsl/wgsl-types"]
}
}
This is required for TypeScript to accept .wgsl imports. If you cannot use the sub-export, a local fallback is:
declare module "*.wgsl" {
import type { ShaderSource } from "@vgpu/wgsl";
const source: ShaderSource;
export default source;
}
Bundler integrations
Webpack 5
Recommended rule:
module.exports = { module: { rules: [{ test: /\.wgsl$/, loader: "@vgpu/wgsl/loader-webpack" }] } };
Verbose/options form (advanced):
module.exports = {
module: {
rules: [
{
test: /\.wgsl$/,
loader: require.resolve("@vgpu/wgsl/loader-webpack"),
options: { minify: true },
},
],
},
};
minify defaults to false; set it to true for the production preset: strip comments/whitespace and safely shorten supported private identifiers. Use { minify: { whitespace: true } } for whitespace-only output.
Vite 5+
import { wgslVitePlugin } from "@vgpu/wgsl/loader-vite";
export default { plugins: [wgslVitePlugin()] };
Pass wgslVitePlugin({ minify: true }) for the production preset: strip comments/whitespace and safely shorten supported private identifiers. Use { minify: { whitespace: true } } for whitespace-only output.
Next.js / Turbopack (Next >= 15.5)
Recommended string form:
import type { NextConfig } from "next";
const config: NextConfig = {
turbopack: {
rules: {
"*.wgsl": {
loaders: ["@vgpu/wgsl/loader-webpack"],
as: "*.js",
},
},
},
};
export default config;
Verbose/options form (advanced; object loaders require options by the Next TypeScript type):
import type { NextConfig } from "next";
const config: NextConfig = {
turbopack: {
rules: {
"*.wgsl": {
loaders: [{ loader: "@vgpu/wgsl/loader-webpack", options: { minify: true } }],
as: "*.js",
},
},
},
};
export default config;
Use legacy experimental.turbo.rules on older Next 15.0-15.2 apps. The as: "*.js" mapping is required because Turbopack's webpack-loader bridge expects loaders to return JavaScript.
WGSL syntax
WGSL modules can import named exports from other WGSL files:
import { helper_color } from "./helper.wgsl";
@fragment
fn fs_main() -> @location(0) vec4f {
return helper_color();
}
Imported files export normal WGSL declarations:
export fn helper_color() -> vec4f { return vec4f(0.1, 0.2, 0.3, 1.0); }
See examples/next-wgsl/app/*.wgsl and packages/wgsl/tests/*.test.ts for more examples.
Mangling and entry-point preservation
Non-entry helpers and imported symbols may be renamed to _vgsl_<hash>__<name> to avoid collisions between modules. WebGPU entry-point functions annotated with @vertex, @fragment, or @compute are preserved, so pipeline creation keeps working:
device.createRenderPipeline({
layout: "auto",
vertex: { module, entryPoint: "vs_main" },
fragment: { module, entryPoint: "fs_main", targets: [{ format }] },
});
Bindings and override constants are likewise exposed by their shader-visible names; when a reflected item needs a generated name, use its mangledName field.
Reflection API
import { reflectSource, resolveShader } from "@vgpu/wgsl/runtime";
const resolved = await resolveShader({ entry: "./shader.wgsl" });
const fragment = resolved.reflection.entryPoints.find((entry) => entry.stage === "fragment");
// Synchronous single-source reflection for main API (vgpu)/runtime WGSL strings.
// Use resolveShader() for import graphs.
const reflection = reflectSource(`
struct Params { time: f32 }
@group(0) @binding(0) var<uniform> params: Params;
@fragment fn main() -> @location(0) vec4f { return vec4f(params.time); }
`);
resolveShader() returns { wgsl, deps, cacheKey, ast, sourceMap, diagnostics, reflection }. reflectSource(wgsl, path?) returns the same frozen ReflectionFacade shape for a single raw WGSL string without resolving imports; if the source contains WGSL imports it throws and points callers to resolveShader().
Reflection currently exposes:
| Field | Description |
|---|---|
reflection.entryPoints | { name, mangledName, stage, workgroupSize? } for @vertex, @fragment, and @compute functions. |
reflection.bindings | { group, binding, name, type, kind, addressSpace?, access?, struct?, layout?, bindingLayout? } for discovered resources, including BGL-precise layouts. |
reflection.overrides | { name, mangledName, defaultValue? } for override constants. |
reflection.featuresRequired | Feature names from enable ...; directives. |
reflection.structs / reflection.aliases | Reflected host-visible type declarations with original and mangled names. |
reflection.hostShareableLayouts | Naga-standard host-shareable layouts for uniform/storage resources. |
Minify option…
Description from the npm listing.
- webgpu
- graphics
- rendering
- wgsl
- shader
- webpack-loader
- vite-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 @vgpu/wgsl alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@vgpu/wgsl. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.