Skip to content

Commit c5c424a

Browse files
authored
feat: expose createFilter util (#8562)
1 parent d357e33 commit c5c424a

File tree

20 files changed

+55
-27
lines changed

20 files changed

+55
-27
lines changed

docs/guide/api-plugin.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ normalizePath('foo\\bar') // 'foo/bar'
517517
normalizePath('foo/bar') // 'foo/bar'
518518
```
519519
520+
## Filtering, include/exclude pattern
521+
522+
Vite exposes [`@rollup/pluginutils`'s `createFilter`](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) function to encourage Vite specific plugins and integrations to use the standard include/exclude filtering pattern, which is also used in Vite core itself.
523+
520524
## Client-server Communication
521525

522526
Since Vite 2.9, we provide some utilities for plugins to help handle the communication with clients.

packages/plugin-react/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
4545
"@babel/plugin-transform-react-jsx-self": "^7.17.12",
4646
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
47-
"@rollup/pluginutils": "^4.2.1",
4847
"react-refresh": "^0.13.0"
4948
},
5049
"peerDependencies": {

packages/plugin-react/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import path from 'path'
22
import type { ParserOptions, TransformOptions, types as t } from '@babel/core'
33
import * as babel from '@babel/core'
4-
import { createFilter } from '@rollup/pluginutils'
5-
import { normalizePath } from 'vite'
4+
import { createFilter, normalizePath } from 'vite'
65
import type { Plugin, PluginOption, ResolvedConfig } from 'vite'
76
import {
87
addRefreshWrapper,

packages/plugin-vue-jsx/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@babel/core": "^7.18.2",
3939
"@babel/plugin-syntax-import-meta": "^7.10.4",
4040
"@babel/plugin-transform-typescript": "^7.18.4",
41-
"@rollup/pluginutils": "^4.2.1",
4241
"@vue/babel-plugin-jsx": "^1.1.1"
4342
},
4443
"devDependencies": {

packages/plugin-vue-jsx/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as babel from '@babel/core'
55
import jsx from '@vue/babel-plugin-jsx'
66
// @ts-expect-error missing type
77
import importMeta from '@babel/plugin-syntax-import-meta'
8-
import { createFilter, normalizePath } from '@rollup/pluginutils'
8+
import { createFilter, normalizePath } from 'vite'
99
import type { ComponentOptions } from 'vue'
1010
import type { Plugin } from 'vite'
1111
import type { Options } from './types'

packages/plugin-vue-jsx/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
2-
import type { FilterPattern } from '@rollup/pluginutils'
2+
import type { FilterPattern } from 'vite'
33

44
export interface FilterOptions {
55
include?: FilterPattern

packages/plugin-vue/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,5 @@
4747
"source-map": "^0.6.1",
4848
"vite": "workspace:*",
4949
"vue": "^3.2.37"
50-
},
51-
"dependencies": {
52-
"@rollup/pluginutils": "^4.2.1"
5350
}
5451
}

packages/plugin-vue/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs'
22
import type { Plugin, ViteDevServer } from 'vite'
3-
import { createFilter } from '@rollup/pluginutils'
3+
import { createFilter } from 'vite'
44
/* eslint-disable import/no-duplicates */
55
import type {
66
SFCBlock,

packages/plugin-vue/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import path from 'path'
22
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
33
import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
4-
import { normalizePath } from '@rollup/pluginutils'
54
import type { RawSourceMap } from 'source-map'
65
import type { EncodedSourceMap as TraceEncodedSourceMap } from '@jridgewell/trace-mapping'
76
import { TraceMap, eachMapping } from '@jridgewell/trace-mapping'
87
import type { EncodedSourceMap as GenEncodedSourceMap } from '@jridgewell/gen-mapping'
98
import { addMapping, fromMap, toEncodedMap } from '@jridgewell/gen-mapping'
10-
import { transformWithEsbuild } from 'vite'
9+
import { normalizePath, transformWithEsbuild } from 'vite'
1110
import {
1211
createDescriptor,
1312
getPrevDescriptor,

packages/vite/LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,28 @@ License: MIT
535535
By: Rich Harris
536536
Repository: rollup/plugins
537537

538+
> The MIT License (MIT)
539+
>
540+
> Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
541+
>
542+
> Permission is hereby granted, free of charge, to any person obtaining a copy
543+
> of this software and associated documentation files (the "Software"), to deal
544+
> in the Software without restriction, including without limitation the rights
545+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
546+
> copies of the Software, and to permit persons to whom the Software is
547+
> furnished to do so, subject to the following conditions:
548+
>
549+
> The above copyright notice and this permission notice shall be included in
550+
> all copies or substantial portions of the Software.
551+
>
552+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
553+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
554+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
555+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
556+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
557+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
558+
> THE SOFTWARE.
559+
538560
---------------------------------------
539561

540562
## @vue/compiler-core

0 commit comments

Comments
 (0)