{"id":41519,"library":"minwgsl","title":"minwgsl","description":"A WGSL (WebGPU Shading Language) minifier written in Rust, compiled to WebAssembly for use in Node.js and browsers. Current stable version is 1.0.3, with frequent updates. It reduces WGSL shader size by removing comments, whitespace, and renaming variables. Key differentiators: Rust-based performance, TypeScript support, and works both in Node.js and browser environments via WebAssembly.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/robertpakalns/minwgsl","tags":["javascript","wgsl","minifier","webgpu","typescript"],"install":[{"cmd":"npm install minwgsl","lang":"bash","label":"npm"},{"cmd":"yarn add minwgsl","lang":"bash","label":"yarn"},{"cmd":"pnpm add minwgsl","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only; CommonJS require will not work unless using dynamic import.","wrong":"const minify = require('minwgsl').minify","symbol":"minify","correct":"import { minify } from 'minwgsl'"},{"note":"MinifyOptions is a TypeScript type, so import type is recommended to avoid runtime inclusion.","wrong":"import { MinifyOptions } from 'minwgsl'","symbol":"MinifyOptions","correct":"import type { MinifyOptions } from 'minwgsl'"},{"note":"The default export is an object containing minify function; not callable directly.","wrong":"import minwgsl from 'minwgsl'; minwgsl(...)","symbol":"default","correct":"import minwgsl from 'minwgsl'; minwgsl.minify(...)"}],"quickstart":{"code":"import { minify } from 'minwgsl';\n\nconst wgsl = `\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> @builtin(position) vec4<f32> {\n    // This is a vertex shader\n    let pos = vec2<f32>(0.0, 0.0);\n    return vec4<f32>(pos, 0.0, 1.0);\n}\n`;\n\nconst options = {\n    removeComments: true,\n    removeWhitespace: true,\n    renameIdentifiers: true,\n};\n\nconst minified = minify(wgsl, options);\nconsole.log(minified.code);\n// Expected output: @vertex fn main(@builtin(vertex_index)vertexIndex:u32)->@builtin(position)vec4<f32>{let pos=vec2<f32>(0.0,0.0);return vec4<f32>(pos,0.0,1.0);}","lang":"typescript","description":"Minifies a simple WGSL vertex shader using all available options."},"warnings":[{"fix":"Set renameIdentifiers to false in options if you need to preserve original names.","message":"The minifier may rename identifiers, which can break WGSL code that relies on reflection or string replacements.","severity":"gotcha","affected_versions":"all"},{"fix":"Validate WGSL before minification using a WGSL parser.","message":"Minified code may not be valid WGSL if the input has errors; minifier assumes valid input.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a bundler like Webpack or Vite, or load the WASM manually with @webassemblyjs.","message":"The package uses WebAssembly; browser usage requires a bundler or direct WASM loading.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.0.3':24 'base':44 'browser':19,54 'comment':35 'compil':11 'current':20 'differenti':41 'environ':55 'frequent':26 'javascript':58 'key':40 'languag':6 'minifi':7,60 'minwgsl':1 'node.js':17,52 'perform':45 'reduc':29 'remov':34 'renam':38 'rust':10,43 'rust-bas':42 'shade':5 'shader':31 'size':32 'stabl':21 'support':47 'typescript':46,62 'updat':27 'use':15 'variabl':39 'version':22 'via':56 'webassembl':13,57 'webgpu':4,61 'wgsl':3,30,59 'whitespac':36 'work':49 'written':8","created_at":"2026-06-04T18:52:48.506630+00:00","updated_at":"2026-06-04T18:52:48.506630+00:00","problems":[{"fix":"Run 'npm install minwgsl' and ensure your project uses ESM (set type: module in package.json or use .mjs file).","cause":"Package not installed or ESM module not resolved correctly.","error":"Error: Cannot find module 'minwgsl'"},{"fix":"Use 'import { minify } from 'minwgsl'' instead of 'import minwgsl from 'minwgsl''.","cause":"Importing default export instead of named export.","error":"TypeError: minwgsl.minify is not a function"},{"fix":"Ensure you have imported minify correctly and call it with the WGSL string and options object.","cause":"Forgetting to call minify with arguments or misconfigured import.","error":"TypeError: minify is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/robertpakalns/minwgsl#readme","github":"https://github.com/robertpakalns/minwgsl","docs":null,"changelog":null,"pypi":null,"npm":"minwgsl","openapi_spec":null,"status_page":null,"smithery":null,"categories":["development"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}