@@ -4,20 +4,12 @@ import {
4
4
generateTypescript ,
5
5
generateYAML
6
6
} from '@intlify/bundle-utils'
7
- import {
8
- assign ,
9
- generateCodeFrame ,
10
- isArray ,
11
- isEmptyObject ,
12
- isNumber ,
13
- isString
14
- } from '@intlify/shared'
7
+ import { assign , generateCodeFrame , isEmptyObject , isNumber , isString } from '@intlify/shared'
15
8
import { createFilter } from '@rollup/pluginutils'
16
9
import createDebug from 'debug'
17
10
import fg from 'fast-glob'
18
11
import { promises as fs } from 'node:fs'
19
12
import { parse as parsePath } from 'node:path'
20
- import { normalize } from 'pathe'
21
13
import { parse } from 'vue/compiler-sfc'
22
14
import { checkVuePlugin , error , getVitePlugin , raiseError , resolveNamespace , warn } from '../utils'
23
15
import { getVueCompiler , parseVueRequest } from '../vue'
@@ -83,30 +75,18 @@ export function resourcePlugin(
83
75
function resolveIncludeExclude ( ) {
84
76
const customBlockInclude =
85
77
meta . framework === 'vite' ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK
86
- if ( isArray ( include ) ) {
87
- return [ [ ...include , customBlockInclude ] , exclude ]
88
- } else if ( isString ( include ) ) {
89
- return [ [ include , customBlockInclude ] , exclude ]
90
- } else {
91
- return [ [ RE_RESOURCE_FORMAT , customBlockInclude ] , exclude ]
92
- }
78
+ return include
79
+ ? [ [ ...include , customBlockInclude ] , exclude ]
80
+ : [ [ RE_RESOURCE_FORMAT , customBlockInclude ] , exclude ]
93
81
}
94
82
95
83
function resolveIncludeExcludeForLegacy ( ) {
96
84
const customBlockInclude =
97
85
meta . framework === 'vite' ? RE_SFC_I18N_CUSTOM_BLOCK : RE_SFC_I18N_WEBPACK_CUSTOM_BLOCK
98
- let _include : string | ( string | RegExp ) [ ] | undefined = undefined
99
- let _exclude : string | ( string | RegExp ) [ ] | undefined = undefined
100
- if ( include ) {
101
- if ( isArray ( include ) ) {
102
- _include = [ ...include . map ( item => normalize ( item ) ) , customBlockInclude ]
103
- } else if ( isString ( include ) ) {
104
- _include = [ normalize ( include ) , customBlockInclude ]
105
- }
106
- } else {
107
- _exclude = '**/**'
108
- }
109
- return [ _include , _exclude ]
86
+ // prettier-ignore
87
+ return include
88
+ ? [ [ ...include , customBlockInclude ] , undefined ]
89
+ : [ undefined , [ '**/**' ] ]
110
90
}
111
91
112
92
let _filter : ReturnType < typeof createFilter > | null = null
@@ -337,8 +317,7 @@ export function resourcePlugin(
337
317
debug ( 'load' , id )
338
318
if ( INTLIFY_BUNDLE_IMPORT_ID === getVirtualId ( id , meta . framework ) && include ) {
339
319
let resourcePaths = [ ] as string [ ]
340
- const includePaths = isArray ( include ) ? include : [ include ]
341
- for ( const inc of includePaths ) {
320
+ for ( const inc of include ) {
342
321
resourcePaths = [ ...resourcePaths , ...( await fg ( inc ) ) ]
343
322
}
344
323
resourcePaths = resourcePaths . filter ( ( el , pos ) => resourcePaths . indexOf ( el ) === pos )
0 commit comments