Skip to content

Commit

Permalink
refactor(presets): maintain preset codes inside src
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Jul 12, 2024
1 parent 3574d70 commit 8474fc2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 68 deletions.
18 changes: 2 additions & 16 deletions presets/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
import type { TsJestPresets } from '../dist'
import allPresets from '../dist/presets/all-presets'

declare const _default: {
defaults: TsJestPresets;
defaultsLegacy: TsJestPresets;
defaultsESM: TsJestPresets;
defaultsESMLegacy: TsJestPresets;
jsWithTs: TsJestPresets;
jsWithTsLegacy: TsJestPresets;
jsWithTsESM: TsJestPresets;
jsWithTsESMLegacy: TsJestPresets;
jsWithBabel: TsJestPresets;
jsWithBabelLegacy: TsJestPresets;
jsWithBabelESM: TsJestPresets;
jsWithBabelESMLegacy: TsJestPresets;
};
export = _default;
export = allPresets
54 changes: 2 additions & 52 deletions presets/index.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,3 @@
const {
createDefaultPreset,
createDefaultEsmPreset,
createJsWithTsPreset,
createJsWithTsEsmPreset,
createJsWithBabelPreset,
createJsWithBabelEsmPreset,
createDefaultLegacyPreset,
createDefaultEsmLegacyPreset,
createJsWithTsLegacyPreset,
createJsWithTsEsmLegacyPreset,
createJsWithBabelLegacyPreset,
createJsWithBabelEsmLegacyPreset,
} = require('../dist/presets/create-jest-preset')
const allPresets = require('../dist/presets/all-presets')

module.exports = {
get defaults() {
return createDefaultPreset()
},
get defaultsLegacy() {
return createDefaultLegacyPreset()
},
get defaultsESM() {
return createDefaultEsmPreset()
},
get defaultsESMLegacy() {
return createDefaultEsmLegacyPreset()
},
get jsWithTs() {
return createJsWithTsPreset()
},
get jsWithTsLegacy() {
return createJsWithTsLegacyPreset()
},
get jsWithTsESM() {
return createJsWithTsEsmPreset()
},
get jsWithTsESMLegacy() {
return createJsWithTsEsmLegacyPreset()
},
get jsWithBabel() {
return createJsWithBabelPreset()
},
get jsWithBabelLegacy() {
return createJsWithBabelLegacyPreset()
},
get jsWithBabelESM() {
return createJsWithBabelEsmPreset()
},
get jsWithBabelESMLegacy() {
return createJsWithBabelEsmLegacyPreset()
},
}
module.exports = allPresets.default
55 changes: 55 additions & 0 deletions src/presets/all-presets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
createDefaultEsmLegacyPreset,
createDefaultEsmPreset,
createDefaultLegacyPreset,
createDefaultPreset,
createJsWithBabelEsmLegacyPreset,
createJsWithBabelEsmPreset,
createJsWithBabelLegacyPreset,
createJsWithBabelPreset,
createJsWithTsEsmLegacyPreset,
createJsWithTsEsmPreset,
createJsWithTsLegacyPreset,
createJsWithTsPreset,
} from './create-jest-preset'

const allPresets = {
get defaults() {
return createDefaultPreset()
},
get defaultsLegacy() {
return createDefaultLegacyPreset()
},
get defaultsESM() {
return createDefaultEsmPreset()
},
get defaultsESMLegacy() {
return createDefaultEsmLegacyPreset()
},
get jsWithTs() {
return createJsWithTsPreset()
},
get jsWithTsLegacy() {
return createJsWithTsLegacyPreset()
},
get jsWithTsESM() {
return createJsWithTsEsmPreset()
},
get jsWithTsESMLegacy() {
return createJsWithTsEsmLegacyPreset()
},
get jsWithBabel() {
return createJsWithBabelPreset()
},
get jsWithBabelLegacy() {
return createJsWithBabelLegacyPreset()
},
get jsWithBabelESM() {
return createJsWithBabelEsmPreset()
},
get jsWithBabelESMLegacy() {
return createJsWithBabelEsmLegacyPreset()
},
}

export default allPresets

0 comments on commit 8474fc2

Please sign in to comment.