Skip to content

Commit c1f33ee

Browse files
committed
fix: interop default for cjs require
1 parent 6e0c16c commit c1f33ee

File tree

7 files changed

+46
-33
lines changed

7 files changed

+46
-33
lines changed

src/esbuild.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import LightningCSS from './index'
1212
* @example
1313
* ```ts
1414
* import { build } from 'esbuild'
15-
*
16-
* build({
17-
* plugins: [require('unplugin-lightningcss/esbuild')()],
18-
* })
19-
* ```
15+
* import LightningCSS from 'unplugin-lightningcss/esbuild'
16+
*
17+
* build({ plugins: [LightningCSS()] })
18+
```
2019
*/
21-
export default LightningCSS.esbuild as typeof LightningCSS.esbuild
20+
const esbuild = LightningCSS.esbuild as typeof LightningCSS.esbuild
21+
export default esbuild
22+
export { esbuild as 'module.exports' }

src/farm.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import LightningCSS from './index'
1212
* @example
1313
* ```ts
1414
* // farm.config.js
15-
* import LightningCSS from 'unplugin-lightningcss/farm'
15+
* import Starter from 'unplugin-lightningcss/farm'
1616
*
1717
* export default {
18-
* plugins: [LightningCSS()],
18+
* plugins: [Starter()],
1919
* }
2020
* ```
2121
*/
22-
export default LightningCSS.farm as typeof LightningCSS.farm
22+
const farm = LightningCSS.farm as typeof LightningCSS.farm
23+
export default farm
24+
export { farm as 'module.exports' }

src/rolldown.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import LightningCSS from './index'
1212
* @example
1313
* ```ts
1414
* // rolldown.config.js
15-
* import LightningCSS from 'unplugin-lightningcss/rolldown'
15+
* import Starter from 'unplugin-lightningcss/rolldown'
1616
*
1717
* export default {
18-
* plugins: [LightningCSS()],
18+
* plugins: [Starter()],
1919
* }
2020
* ```
2121
*/
22-
export default LightningCSS.rolldown as typeof LightningCSS.rolldown
22+
const rolldown = LightningCSS.rolldown as typeof LightningCSS.rolldown
23+
export default rolldown
24+
export { rolldown as 'module.exports' }

src/rollup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import LightningCSS from './index'
1212
* @example
1313
* ```ts
1414
* // rollup.config.js
15-
* import LightningCSS from 'unplugin-lightningcss/rollup'
15+
* import Starter from 'unplugin-lightningcss/rollup'
1616
*
1717
* export default {
18-
* plugins: [LightningCSS()],
18+
* plugins: [Starter()],
1919
* }
2020
* ```
2121
*/
22-
export default LightningCSS.rollup as typeof LightningCSS.rollup
22+
const rollup = LightningCSS.rollup as typeof LightningCSS.rollup
23+
export default rollup
24+
export { rollup as 'module.exports' }

src/rspack.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
/**
2-
* This entry file is for Vite plugin.
2+
* This entry file is for Rspack plugin.
33
*
44
* @module
55
*/
66

77
import LightningCSS from './index'
88

99
/**
10-
* Vite plugin
10+
* Rspack plugin
1111
*
1212
* @example
13-
* ```ts
13+
* ```js
1414
* // rspack.config.js
1515
* import LightningCSS from 'unplugin-lightningcss/rspack'
1616
*
17-
* export default {
18-
* plugins: [LightningCSS()],
17+
* default export {
18+
* plugins: [LightningCSS()],
1919
* }
2020
* ```
2121
*/
22-
export default LightningCSS.rspack as typeof LightningCSS.rspack
22+
const rspack = LightningCSS.rspack as typeof LightningCSS.rspack
23+
export default rspack
24+
export { rspack as 'module.exports' }

src/vite.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import LightningCSS from './index'
1111
*
1212
* @example
1313
* ```ts
14-
* // vite.config.js
15-
* import LightningCSS from 'unplugin-lightningcss/vite'
14+
* // vite.config.ts
15+
* import Starter from 'unplugin-lightningcss/vite'
1616
*
17-
* export default {
18-
* plugins: [LightningCSS()],
19-
* }
17+
* export default defineConfig({
18+
* plugins: [Starter()],
19+
* })
2020
* ```
2121
*/
22-
export default LightningCSS.vite as typeof LightningCSS.vite
22+
const vite = LightningCSS.vite as typeof LightningCSS.vite
23+
export default vite
24+
export { vite as 'module.exports' }

src/webpack.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
/**
2-
* This entry file is for Vite plugin.
2+
* This entry file is for webpack plugin.
33
*
44
* @module
55
*/
66

77
import LightningCSS from './index'
88

99
/**
10-
* Vite plugin
10+
* Webpack plugin
1111
*
1212
* @example
13-
* ```ts
13+
* ```js
1414
* // webpack.config.js
1515
* import LightningCSS from 'unplugin-lightningcss/webpack'
1616
*
17-
* export default {
18-
* plugins: [LightningCSS()],
17+
* default export {
18+
* plugins: [LightningCSS()],
1919
* }
2020
* ```
2121
*/
22-
export default LightningCSS.webpack as typeof LightningCSS.webpack
22+
const webpack = LightningCSS.webpack as typeof LightningCSS.webpack
23+
export default webpack
24+
export { webpack as 'module.exports' }

0 commit comments

Comments
 (0)