Skip to content

Commit

Permalink
Merge pull request #40 from deepjoy/issue-39
Browse files Browse the repository at this point in the history
fix: add invalidExts as an option
  • Loading branch information
eryue0220 committed May 18, 2024
2 parents 9702b91 + 163c247 commit e068055
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/core/options.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { StylexOptions, UnpluginStylexOptions } from '@/types'
import { isDevelopment } from './constants'

export function getOptions(options: UnpluginStylexOptions) {
export function getOptions(options: UnpluginStylexOptions): Required<UnpluginStylexOptions> {
const stylex = options.stylex || ({} as StylexOptions)
const isDev = options.dev || isDevelopment

return {
...options,
dev: options.dev || isDev,
invalidExts: ['.json', '.html', '.jade', '.json5', ...(options.invalidExts ?? [])],
stylex: {
filename: stylex.filename || 'stylex.css',
stylexImports: stylex.stylexImports || ['@stylexjs/stylex'],
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>

transformInclude(id) {
// webpack will contain these files, which will occur errors
const invalidExts = ['.json', '.html', '.jade', '.json5']
const invalidExts = options.invalidExts
const extname = path.extname(id)
// for handle vite
const questionMarkIndex = extname.indexOf('?')
Expand Down
7 changes: 4 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type StylexOptions = {
stylexImports?: string[]
classNamePrefix?: string
unstable_moduleResolution?: {
type: 'commonjs' | 'haste'
type: 'commonJS' | 'haste'
rootDir: string
}
babelConfig?: BabelConfig
Expand All @@ -21,9 +21,10 @@ export type StylexOptions = {
}

export type UnpluginStylexOptions = {
compiler?: string
// compiler?: string
invalidExts?: string[]
dev?: boolean
enforce?: 'post' | 'pre'
// enforce?: 'post' | 'pre'
stylex?: StylexOptions
}

Expand Down

0 comments on commit e068055

Please sign in to comment.