| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
lang: En | Ko
A Vite bundler configuration package that supports library builds with minimal setup.
vite has become a versatile build tool supporting various frameworks beyond Vue.js, including React. It also provides a Library Mode for bundling libraries, making it a strong alternative to Rollup. With its fast build speed and optimized bundling environment, it is gaining popularity as a package bundler.
However, without prior knowledge of core concepts and configuration methods for library builds, setting up an efficient configuration file can be challenging. To effectively utilize Vite’s Library Mode, multiple factors must be considered.
tsup is an esbuild-based bundler that simplifies bundling TypeScript libraries. It is useful for basic bundling tasks. However, it does not provide automatic polyfill insertion or transpilation based on browserslist, meaning additional tools or configurations may be required for an optimized build in specific environments. Additionally, since it is based on esbuild, it lacks compatibility with Rollup plugins, limiting access to Rollup’s extensive plugin ecosystem.
To address these limitations, pite provides a more intuitive and flexible library build environment. While maintaining the strengths of both vite and tsup, pite offers presets that enable seamless configuration for various environments, allowing stable library builds without complex setup.
📦 @naverpay/browserslist-config
A Shareable Browserslist Config package that reflects Naver Pay’s supported browser range.
📦 publint
publint is an npm package linter that ensures optimal compatibility with Vite, Rollup, and other environments.
A package inspired by publint, designed to enforce best practices specific to Naver Pay’s internal standards.
Run the following command to install as a devDependencies:
npm install --save-dev @naverpay/piteOr, if using pnpm:
pnpm add -D @naverpay/pitenode: >=18 vite: >=6.0.10 tsup: >=8.3.5
Import createViteConfig in vite.config.ts and set up the configuration.
import { createViteConfig } from '@naverpay/pite'
export default createViteConfig({
cwd: process.cwd(),
entry: ['src/index.ts'],
outputs: [
{ format: 'es', dist: 'dist/es' },
{ format: 'cjs', dist: 'dist/cjs' },
],
cssFileName: 'style.css',
visualize: true,
publint: {severity: 'error'},
includeRequiredPolyfill: ['fetch', 'Promise'],
skipRequiredPolyfillCheck: ['Symbol'],
options: {
minify: true,
sourcemap: true,
},
})Run the following command to bundle the library:
vite buildOnce the build is complete, the bundled files will be generated in the dist/es and dist/cjs directories.
| Option Name | Type | Description |
|---|---|---|
| *entry | string | string[] | Record<string, string> | Entry file path (supports glob patterns) |
| cwd | string | Current working directory (default: '.') |
| outputs | { format: 'es' | 'cjs'; dist: string }[] | Specifies module format and output directory |
| cssFileName | string | Output CSS file name |
| visualize | boolean | PluginVisualizerOptions | Enables rollup-plugin-visualizer |
| publint | { severity?: 'error' | 'warn' | 'off' } | Specifies severity for publint checks (error: exit with code 1, warn: show warnings only, off: disable check) |
| includeRequiredPolyfill | string[] | List of required polyfills to be injected |
| skipRequiredPolyfillCheck | string[] | List of polyfills to skip injection check |
| options | BuildOptions | Additional Vite build options |
By default, pite detects code that requires polyfills based on the project's browserslist and raises an error if necessary. This ensures that the library functions correctly across different environments while preventing unnecessary polyfill injections that may increase build size.
The includeRequiredPolyfill and skipRequiredPolyfillCheck options allow you to adjust the polyfill injection criteria and processing behavior. These options provide flexibility in applying polyfills based on project requirements.
Check out the configurations and build outputs of example libraries built using pite.
import { createViteConfig } from '@naverpay/pite'
export default createViteConfig({
cwd: '.',
entry: ['!./src/**/*.bench.ts', '!./src/**/*.test.ts', './src/**/*.ts'],
outputs: [
{
format: 'cjs',
dist: 'dist',
},
{
format: 'es',
dist: 'dist',
},
],
skipRequiredPolyfillCheck: [
// https://bugs.chromium.org/p/v8/issues/detail?id=12681
'es.array.push',
// https://bugzilla.mozilla.org/show_bug.cgi?id=1767541
'es.array.includes',
// https://issues.chromium.org/issues/40672866
'es.array.reduce',
// https://github.com/zloirock/core-js/issues/480#issuecomment-457494016 safari bug
'es.string.trim',
// https://github.com/zloirock/core-js/commit/9017066b4cb367c6609e4473d43d6e6dad8031a5#diff-59f90be4cf68f9d13d2dce1818780ae968bf48328da4014b47138adf527ec0fcR1066
'es.regexp.flags',
// https://bugs.webkit.org/show_bug.cgi?id=188794
'es.array.reverse',
],
})import { createViteConfig } from '@naverpay/pite'
export default createViteConfig({
cwd: '.',
entry: ['./src/index.ts'],
skipRequiredPolyfillCheck: [
'esnext.json.parse'
],
options: {
minify: false,
},
})MIT License © 2025 NaverPay
| Back | FazBrowse Home | New Git URL |