Supported bundlers
Bun

Usage with Bun

Installation

# npm
npm i -D @wyw-in-js/bun
# yarn
yarn add --dev @wyw-in-js/bun
# pnpm
pnpm add -D @wyw-in-js/bun
# bun
bun add -d @wyw-in-js/bun

Configuration

Bun plugins are configured via the Bun.build() API:

import wyw from '@wyw-in-js/bun';
 
await Bun.build({
  entrypoints: ['src/index.ts'],
  outdir: 'dist',
  plugins: [
    wyw({
      filter: /\.[cm]?[jt]sx?$/,
    }),
  ],
});

Transforming libraries in node_modules

By default, the Bun plugin skips transforming files from node_modules for performance.

To transform a specific library, enable transformLibraries and narrow include/exclude:

wyw({
  transformLibraries: true,
  include: [/node_modules\\/(?:@fluentui)\\//],
});

Disabling vendor prefixing

Stylis adds vendor-prefixed CSS by default. To disable it (and reduce CSS size), pass prefixer: false:

wyw({
  prefixer: false,
});

Keeping CSS comments

WyW can preserve CSS comments (for example, /*rtl:ignore*/) via keepComments.

Bun currently strips CSS comments in the final extracted CSS output (including directives like /*rtl:ignore*/). Bun may keep top-level /*!...*/ license comments, but comments inside rules are dropped.

wyw({
  keepComments: true,
  // or keep only matching comments:
  // keepComments: /rtl:/,
});