Skip to content

Commit

Permalink
feat: migrate typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
tkow committed Dec 31, 2022
1 parent aee4e79 commit 856541c
Show file tree
Hide file tree
Showing 13 changed files with 8,462 additions and 7,852 deletions.
37 changes: 37 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"module": {
"type": "commonjs",
// These are defaults.
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false
},
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": false
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true,
"react": {
"runtime": "automatic",
"useBuiltins": true
}
},
"keepClassNames": true,
"minify": {
"compress": {
"unused": true,
"keep_classnames": true,
"keep_fnames": true,
"keep_fargs": true
}
}
},
"minify": true
}
31 changes: 31 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const esmModules = [
'((jest-)?react-native|@react-native(-community)?)',
'expo(nent)?',
'@expo(nent)/.*?',
'@expo-google-fonts/.*',
'react-navigation',
'@react-navigation/.*',
'@unimodules/.*',
'unimodules',
'sentry-expo',
'native-base',
'react-native-svg',
].join('|');

export default {
preset: 'react-native',
transform: {
'^.+\\.tsx?$': ['@swc/jest'],
// NOTE: For flow in React Native Library.
'^.+\\.jsx?$': ['babel-jest'],
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
'react-native/jest/assetFileTransformer.js'
),
},
modulePathIgnorePatterns: [
'<rootDir>/example/node_modules',
'<rootDir>/lib/',
],
transformIgnorePatterns: [`node_modules/(?!(?:.pnpm/)?(${esmModules}))`],
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
};
36 changes: 16 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
},
"scripts": {
"build": "bob build",
"prepare": "yarn build",
"prepare": "npm run build",
"release": "np --any-branch",
"watch": "npm-watch",
"test": "jest",
"lint": "yarn lint:lib & yarn lint:example",
"lint": "npm lint:lib & npm lint:example",
"lint:lib": "eslint ./src --ext .js --config .eslintrc",
"lint:lib:fix": "eslint ./src --ext .js --config .eslintrc --fix",
"lint:example": "eslint ./example --ext .ts,.tsx --config .eslintrc",
Expand All @@ -48,16 +48,19 @@
"lodash.merge": "4.6.2"
},
"devDependencies": {
"@babel/core": "7.14.8",
"@babel/runtime": "7.14.8",
"@testing-library/jest-native": "4.0.1",
"@testing-library/react-native": "7.2.0",
"@types/jest": "26.0.24",
"@babel/core": "7.20.7",
"@babel/runtime": "7.20.7",
"@swc/core": "^1.3.24",
"@swc/jest": "^0.2.24",
"@testing-library/jest-native": "5.4.0",
"@testing-library/react-native": "11.5.0",
"@types/jest": "29.2.5",
"@types/node": "^18.11.18",
"@types/react": "^18.0.24",
"@types/react-native": "^0.70.6",
"@typescript-eslint/eslint-plugin": "4.6.1",
"@typescript-eslint/parser": "4.6.1",
"babel-jest": "27.0.6",
"babel-jest": "29.3.1",
"eslint": "7.31.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard": "16.0.3",
Expand All @@ -69,14 +72,16 @@
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-standard": "5.0.0",
"husky": "6.0.0",
"jest": "27.0.6",
"jest": "29.3.1",
"metro-react-native-babel-preset": "^0.73.3",
"npm-watch": "^0.11.0",
"prettier": "2.3.2",
"react": "18.0.0",
"react-native": "0.69.6",
"react-native-builder-bob": "0.18.1",
"react-test-renderer": "18.0.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "4.7.3"
},
"peerDependencies": {
Expand All @@ -88,22 +93,13 @@
"pre-commit": "yarn lint"
}
},
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
"<rootDir>/example/node_modules",
"<rootDir>/lib/"
],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
]
},
"react-native-builder-bob": {
"source": "src/internals",
"output": "lib",
"targets": [
"commonjs",
"module"
"module",
"typescript"
]
},
"watch": {
Expand Down
Loading

0 comments on commit 856541c

Please sign in to comment.