Skip to content

Commit

Permalink
feat: remove invalidExts opt
Browse files Browse the repository at this point in the history
  • Loading branch information
eryue0220 committed Aug 22, 2024
1 parent 0a5b06d commit 1f99408
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import { isDevelopment } from './constants'
export function getOptions(options: UnpluginStylexOptions): Required<UnpluginStylexOptions> {
const stylex = options.stylex || ({} as StylexOptions)
const isDev = options.dev || isDevelopment
if(options.invalidExts && options.validExts) {
throw new Error('Only one of invalidExts or validExts may be specified at a time')
}

return {
...options,
dev: isDev,
invalidExts: options.invalidExts ? ['.json', '.html', '.jade', '.json5', ...(options.invalidExts ?? [])] : [],
// .js, .jsx, .mjs, .cjs, .ts, .tsx, .mts, .cts
validExts: options.validExts ?? /\.[mc]?[jt]sx?$/,
stylex: {
Expand Down
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
name: PLUGIN_NAME,

transformInclude(id) {
// TODO: deprecate
const invalidExts = options.invalidExts
const validExts = options.validExts
const extname = path.extname(id)
// for handle vite
const questionMarkIndex = extname.indexOf('?')
const validExtName = questionMarkIndex > -1 ? extname.slice(0, questionMarkIndex) : extname
if (invalidExts.length > 0) {
return !invalidExts.includes(validExtName)
}
return validExts instanceof RegExp ? validExts.test(validExtName) : validExts.includes(validExtName)
},

Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type StylexOptions = {

export type UnpluginStylexOptions = {
// compiler?: string
invalidExts?: string[]
validExts?: RegExp | string[]
dev?: boolean
// enforce?: 'post' | 'pre'
Expand Down

0 comments on commit 1f99408

Please sign in to comment.