{"id":14198,"library":"unplugin-info","title":"Unplugin Info","description":"Unplugin Info is a versatile build-time plugin that exports essential build-related information as a virtual module, making it accessible within your application's runtime code. It captures details such as build timestamps, Git commit SHA, CI environment variables, and `package.json` data. This allows developers to easily inspect the production version of their application, verify deployments, or configure behavior based on build context. The current stable version is 1.3.2, with frequent patch and minor releases addressing bug fixes and adding support for new features or bundlers. Its key differentiator is its 'unplugin' architecture, providing seamless integration across various build tools like Vite, Rollup, Webpack, Rspack, esbuild, and specific frameworks like Nuxt, Astro, Quasar, and Vue CLI, all from a single codebase. It also provides dedicated TypeScript typings for virtual modules.","status":"active","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/yjl9903/unplugin-info","tags":["javascript","debug","config","unplugin","build","vite","vite-plugin","webpack","rspack","typescript"],"install":[{"cmd":"npm install unplugin-info","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-info","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-info","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Nuxt module integration.","package":"@nuxt/kit","optional":true},{"reason":"Required for Nuxt module integration and type inference.","package":"@nuxt/schema","optional":true},{"reason":"Required when using with Rspack.","package":"@rspack/core","optional":true},{"reason":"Required when using with esbuild.","package":"esbuild","optional":true},{"reason":"Required when using with Rollup (or bundlers like Vite that use Rollup internally).","package":"rollup","optional":true},{"reason":"Required when using with Vite.","package":"vite","optional":true},{"reason":"Required when using with Webpack or compatible tools like Vue CLI/Quasar (webpack mode).","package":"webpack","optional":true}],"imports":[{"note":"The Vite integration exports a default function. Ensure you're in an ESM context for `import` statements.","wrong":"import { Info } from 'unplugin-info/vite'; // Incorrect named import\nconst Info = require('unplugin-info/vite'); // CommonJS import in ESM context","symbol":"Vite Plugin","correct":"import Info from 'unplugin-info/vite';"},{"note":"Webpack configurations often use CommonJS `require`. The module exports a function that needs to be called to instantiate the plugin.","wrong":"import Info from 'unplugin-info/webpack'; // Webpack config typically uses CommonJS for plugin instantiation\nInfo(); // Missing call to the default function","symbol":"Webpack Plugin","correct":"require('unplugin-info/webpack')();"},{"note":"Nuxt modules are typically registered as a string path in the `modules` array. Options are passed via the top-level `info` key in `nuxt.config.ts`.","wrong":"import Info from 'unplugin-info/nuxt'; // Not how Nuxt modules are typically registered\nmodules: [Info]","symbol":"Nuxt Module","correct":"modules: ['unplugin-info/nuxt']"},{"note":"To get type inference for the virtual modules (e.g., `~build/info`), you need to reference the client types either via a triple-slash directive in a `.d.ts` file or by adding `unplugin-info/client` to the `types` array in your `tsconfig.json`.","wrong":"import { BuildInfo } from 'unplugin-info/client'; // Incorrect import of ambient types","symbol":"TypeScript Types","correct":"/// <reference types=\"unplugin-info/client\" />\n// or in tsconfig.json\n\"types\": [\"unplugin-info/client\"]"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport Info from 'unplugin-info/vite';\n\n// vite.config.ts\nexport default defineConfig({\n  plugins: [\n    Info({\n      /**\n       * Customize what information to include\n       *\n       * @default true\n       */\n      git: true, // Includes Git commit SHA, branch, etc.\n      buildTime: true, // Includes the build timestamp\n      ci: true, // Includes CI environment variables\n      packageJson: true, // Includes package.json version\n      /**\n       * Custom information to add to the virtual module\n       */\n      custom: {\n        myCustomKey: 'myCustomValue',\n        envVar: process.env.MY_ENV_VAR ?? ''\n      }\n    })\n  ]\n});\n\n// src/main.ts (or any client-side file)\n// Make sure to add \"unplugin-info/client\" to your tsconfig.json\n\nimport buildInfo from '~build/info';\nimport buildGit from '~build/git';\nimport buildCI from '~build/ci';\nimport buildPackage from '~build/package';\n\nconsole.log('Application Build Info:', buildInfo);\nconsole.log('Git Info:', buildGit);\nconsole.log('CI Info:', buildCI);\nconsole.log('Package Info:', buildPackage);\n\ndocument.getElementById('app')!.innerHTML = `\n  <h1>App Info</h1>\n  <p>Build Time: ${new Date(buildInfo.time).toLocaleString()}</p>\n  <p>Git Commit: ${buildGit.shortHash}</p>\n  <p>CI: ${buildCI.name || 'Local'}</p>\n  <p>Version: ${buildPackage.version}</p>\n  <p>Custom: ${buildInfo.custom.myCustomKey} - ${buildInfo.custom.envVar}</p>\n`;","lang":"typescript","description":"This quickstart demonstrates configuring `unplugin-info` with Vite and then accessing the generated build, Git, CI, and package information within a client-side TypeScript file. It shows how to include custom data and environment variables."},"warnings":[{"fix":"Update import paths from `~build/info` to `~build/git` and `~build/ci` for corresponding data. Refactor code that relied on `commitsSinceLastTag`.","message":"The package underwent a significant breaking change in version 1.0 (migrated from v0), re-organizing the virtual modules. Git and CI-related information were moved from the single `~build/info` module to dedicated `~build/git` and `~build/ci` modules, respectively. Additionally, `commitsSinceLastTag` was removed from `~build/git`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Add `\"unplugin-info/client\"` to the `types` array in your `tsconfig.json`'s `compilerOptions`, or add a triple-slash directive `/// <reference types=\"unplugin-info/client\" />` in a `.d.ts` file within your project.","message":"When using `unplugin-info` with TypeScript, you must explicitly declare the virtual modules to the TypeScript compiler, otherwise, imports like `import buildInfo from '~build/info'` will result in type errors (e.g., 'Cannot find module '~build/info' or its corresponding type declarations.').","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure Git is installed and the project is a Git repository during the build. For environments where Git info is not available or desired, you can disable `git: false` in the plugin options or add fallbacks in your application code.","message":"The plugin relies on Git commands to fetch repository information. If Git is not installed or the project is not a Git repository (e.g., in a deployed environment or CI without Git clone), Git-related fields (`~build/git`) might be empty or throw errors during the build process, depending on the environment.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.2':74 'access':25 'across':102 'ad':85 'address':81 'allow':49 'also':128 'applic':28,59 'architectur':98 'astro':117 'base':65 'behavior':64 'bug':82 'build':9,16,37,67,104,140 'build-rel':15 'build-tim':8 'bundler':91 'captur':33 'ci':42 'cli':121 'code':31 'codebas':126 'commit':40 'config':138 'configur':63 'context':68 'current':70 'data':47 'debug':137 'dedic':130 'deploy':61 'detail':34 'develop':50 'differenti':94 'easili':52 'environ':43 'esbuild':111 'essenti':14 'export':13 'featur':89 'fix':83 'framework':114 'frequent':76 'git':39 'info':2,4 'inform':18 'inspect':53 'integr':101 'javascript':136 'key':93 'like':106,115 'make':23 'minor':79 'modul':22,135 'new':88 'nuxt':116 'package.json':46 'patch':77 'plugin':11,144 'product':55 'provid':99,129 'quasar':118 'relat':17 'releas':80 'rollup':108 'rspack':110,146 'runtim':30 'seamless':100 'sha':41 'singl':125 'specif':113 'stabl':71 'support':86 'time':10 'timestamp':38 'tool':105 'type':132 'typescript':131,147 'unplugin':1,3,97,139 'variabl':44 'various':103 'verifi':60 'versatil':7 'version':56,72 'virtual':21,134 'vite':107,141,143 'vite-plugin':142 'vue':120 'webpack':109,145 'within':26","created_at":"2026-04-20T01:58:26.296019+00:00","updated_at":"2026-04-20T01:58:26.296019+00:00","problems":[{"fix":"Add `\"unplugin-info/client\"` to the `types` array in `tsconfig.json` or add `/// <reference types=\"unplugin-info/client\" />` to a `.d.ts` file.","cause":"TypeScript compiler is unaware of the virtual module types.","error":"Cannot find module '~build/info' or its corresponding type declarations."},{"fix":"Correctly import the virtual module using `import buildInfo from '~build/info';` (or `~build/git`, etc.) as an ESM import.","cause":"Attempting to use `BuildInfo` (or `BuildGit`, etc.) as a global variable instead of importing the virtual module.","error":"ReferenceError: BuildInfo is not defined (or similar for other virtual modules)"},{"fix":"Verify the correct import path for your bundler, e.g., `import Info from 'unplugin-info/vite';` for Vite, `require('unplugin-info/webpack')` for Webpack, etc. Ensure the package is installed.","cause":"Incorrect import path for the specific bundler plugin.","error":"Rollup failed to resolve import \"unplugin-info/vite\" from \"vite.config.ts\"."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://yjl9903.github.io/unplugin-info/","github":"https://github.com/yjl9903/unplugin-info","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/unplugin-info","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}