-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate codes to typescript and yarn to pnpm #45
base: rewrite-media-styles
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,48 @@ | ||
name: CI | ||
on: push | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '15' | ||
- name: Install modules | ||
run: yarn | ||
node-version: '16' | ||
|
||
- uses: pnpm/action-setup@v2 | ||
name: Install pnpm | ||
id: pnpm-install | ||
with: | ||
version: 7 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
|
||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Lint | ||
run: yarn lint | ||
run: npm run lint | ||
|
||
- name: Test | ||
run: yarn test --ci --coverage --maxWorkers=2 | ||
run: npm run test --ci --coverage --maxWorkers=2 | ||
|
||
- name: Build | ||
run: yarn build | ||
run: npm run build |
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const esmModules = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? We don't use any of these libs in the internals of the library. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is recommended configuration introduced by expo. https://docs.expo.dev/guides/testing-with-jest/#configuration If we use pnpm, the module resolution system is a bit different from npm and it caches the modules in node_modules/.pnpm, so need manually setting at least, '@react-native/' namespace. See react-native preset. It's not high possibility to use another native-library, but it's ready for testing with third party libraries. If you don't need them, I remove them except for first react-native configuration (first array element configuration is |
||
'((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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little hesitant about switching to SWC since the current babel based setup works quite well and the time it takes to execute all the tests is only like 5 seconds so it doesn't take that long any way 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Temzasse But, you don't feel pain to follow up this tool, I'll remove it. |
||
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'], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 run lint:lib & npm run 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", | ||
|
@@ -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", | ||
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, they aren't. |
||
"ts-node": "^10.9.1", | ||
"typescript": "4.7.3" | ||
}, | ||
"peerDependencies": { | ||
|
@@ -85,19 +90,9 @@ | |
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn lint" | ||
"pre-commit": "npm run 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", | ||
|
@@ -125,9 +120,6 @@ | |
"tabWidth": 2, | ||
"trailingComma": "es5" | ||
}, | ||
"np": { | ||
"yarn": true | ||
}, | ||
"keywords": [ | ||
"android", | ||
"ios", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed to fix even number versioning for LTS, because odd number versioning of node is experimental and generally for development.
https://nodesource.com/blog/understanding-how-node-js-release-lines-work/