@rollup/plugin-swc
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -5,2 +5,3 @@ 'use strict'; | ||
var pluginutils = require('@rollup/pluginutils'); | ||
var core = require('@swc/core'); | ||
@@ -10,2 +11,3 @@ var smob = require('smob'); | ||
function swc(input = {}) { | ||
const filter = pluginutils.createFilter(input.include, input.exclude); | ||
const swcOptions = smob.merge({}, input.swc || {}, { | ||
@@ -27,3 +29,5 @@ jsc: { | ||
name: 'swc', | ||
transform(code) { | ||
transform(code, id) { | ||
if (!filter(id)) | ||
return null; | ||
return core.transform(code, { | ||
@@ -30,0 +34,0 @@ ...swcOptions, |
@@ -0,1 +1,2 @@ | ||
import { createFilter } from '@rollup/pluginutils'; | ||
import { transform } from '@swc/core'; | ||
@@ -5,2 +6,3 @@ import { merge } from 'smob'; | ||
function swc(input = {}) { | ||
const filter = createFilter(input.include, input.exclude); | ||
const swcOptions = merge({}, input.swc || {}, { | ||
@@ -22,3 +24,5 @@ jsc: { | ||
name: 'swc', | ||
transform(code) { | ||
transform(code, id) { | ||
if (!filter(id)) | ||
return null; | ||
return transform(code, { | ||
@@ -25,0 +29,0 @@ ...swcOptions, |
{ | ||
"name": "@rollup/plugin-swc", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"publishConfig": { | ||
@@ -65,6 +65,7 @@ "access": "public" | ||
"dependencies": { | ||
"smob": "^1.0.0" | ||
"@rollup/pluginutils": "^5.0.1", | ||
"smob": "^1.4.0" | ||
}, | ||
"devDependencies": { | ||
"@swc/core": "^1.3.58", | ||
"@swc/core": "^1.3.78", | ||
"rollup": "^3.0.0-7", | ||
@@ -71,0 +72,0 @@ "typescript": "^4.8.3" |
@@ -51,4 +51,8 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-swc | ||
The plugin accepts an object as input parameter to modify the default behaviour. | ||
This object has an `swc` property to provide library specific [Options](https://swc.rs/docs/configuration/swcrc). | ||
### `swc` | ||
- Type: [Options](https://swc.rs/docs/configuration/swcrc) | ||
- Default: `undefined` | ||
```typescript | ||
@@ -62,2 +66,18 @@ import type { Options as SWCOptions } from '@swc/core'; | ||
### `exclude` | ||
- Type: `String` | `Array[...String]` | ||
- Default: `null` | ||
A [picomatch pattern](https://github.com/micromatch/picomatch), | ||
or array of patterns, which specifies the files in the build the plugin should _ignore_. By default no files are ignored. | ||
### `include` | ||
- Type: `String` | `Array[...String]` | ||
- Default: `null` | ||
A [picomatch pattern](https://github.com/micromatch/picomatch), | ||
or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted. | ||
## Alternatives | ||
@@ -64,0 +84,0 @@ |
import type { Plugin } from 'rollup'; | ||
import { createFilter } from '@rollup/pluginutils'; | ||
import type { Options as SWCOptions } from '@swc/core'; | ||
@@ -9,2 +10,4 @@ import { transform } from '@swc/core'; | ||
export function swc(input: Options = {}): Plugin { | ||
const filter = createFilter(input.include, input.exclude); | ||
const swcOptions: SWCOptions = merge({}, input.swc || {}, { | ||
@@ -27,3 +30,5 @@ jsc: { | ||
name: 'swc', | ||
transform(code) { | ||
transform(code, id) { | ||
if (!filter(id)) return null; | ||
return transform(code, { | ||
@@ -30,0 +35,0 @@ ...swcOptions, |
@@ -0,1 +1,2 @@ | ||
import type { FilterPattern } from '@rollup/pluginutils'; | ||
import type { Options as SWCOptions } from '@swc/core'; | ||
@@ -5,2 +6,6 @@ | ||
swc?: SWCOptions; | ||
include?: FilterPattern; | ||
exclude?: FilterPattern; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8138
123
91
4
+ Added@rollup/pluginutils@^5.0.1
+ Added@rollup/pluginutils@5.1.3(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedpicomatch@4.0.2(transitive)
Updatedsmob@^1.4.0