Skip to content

Commit 12f0207

Browse files
authored
Merge pull request #57 from fawaz-ahmed/transpile-package
transpile package
2 parents 5c040f8 + 2c811aa commit 12f0207

File tree

10 files changed

+47
-25
lines changed

10 files changed

+47
-25
lines changed

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15+
1516
- uses: actions/setup-node@v1
1617
with:
17-
node-version: 12
18+
node-version: 14.17.6
1819
registry-url: https://registry.npmjs.org/
20+
21+
- name: Install
22+
run: npm install
23+
24+
- name: Build
25+
run: npm run build
26+
1927
- run: npm publish --access public
2028
env:
2129
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dist
1010
# Dependency directory
1111
node_modules
1212
yarn.lock
13+
package-lock.json
1314

1415
.DS_*
1516

.npmignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ node_modules
99
tmp
1010

1111
# Examples (If applicable to your project)
12-
examples
12+
example/
13+
.github/
14+
.gitignore
15+
babel.config.js
16+
yarn.lock
17+
package-lock.json

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#### Please :star: it, thanks :thumbsup:
44
# react-native-read-more
5-
React native library to show text in a condensed way and expand when needed. Can be used with native or expo on all platforms.
5+
React native library to show text in a condensed way and expand when needed. Can be used with native or expo on all platforms. Supports TS/JS both.
66

77
![Example](example/seemore.gif)
88

@@ -98,25 +98,17 @@ yarn android
9898
# Why another library ?
9999
This module will calculate where to position `See more` and `See less` within the same paragraph instead of occupying another line. It is a drop-in replacement for `Text` component and you can control when to apply the see more functionality by configuring the `numberOfLines` prop. Moreover, you can also pass your own custom implementation of `Text` component like `ParsedText` ([sample code](https://github.com/fawaz-ahmed/react-native-read-more/issues/37#issuecomment-1047029209)) etc.
100100

101+
## Testing with Jest
102+
Make sure to add `jest.useFakeTimers();` to your test file.
103+
See [Stackoverflow post](https://stackoverflow.com/questions/50793885/referenceerror-you-are-trying-to-import-a-file-after-the-jest-environment-has) and [jest timer mocks](https://jestjs.io/docs/timer-mocks)
104+
101105
## Seeing issues or any feedback or feature suggest ?
102106
Create an [issue](https://github.com/fawaz-ahmed/react-native-read-more/issues) with github.
103107

104108
## Troubleshooting
105109
- If you observe `See more` shown always in android, pass prop `allowFontScaling={false}`, refer to this [issue](https://github.com/fawaz-ahmed/react-native-read-more/issues/17)
106110
- If you have any nested components other than `Text`, refer to this [issue](https://github.com/fawaz-ahmed/react-native-read-more/issues/52)
107111

108-
### jest - running unit tests
109-
This package is not transpiled. So inorder for your test cases to work, this package should be transpiled by babel. For this you need to add this path `!node_modules/@fawazahmed/react-native-read-more/` under `transformIgnorePatterns` option provided by `jest`. In your `package.json` you will see this `jest` config:
110-
```
111-
"jest": {
112-
"preset": "react-native",
113-
"transformIgnorePatterns": [
114-
"!node_modules/@fawazahmed/react-native-read-more/" // add this line
115-
]
116-
}
117-
```
118-
refer to jest docs [here](https://jestjs.io/docs/en/tutorial-react-native#transformignorepatterns-customization) and github [issue](https://github.com/fawaz-ahmed/react-native-read-more/issues/19)
119-
120112
### Known issues
121113
`Android only` if `numberOfLines` with a value of `1` is passed down as a prop, text in android devices will overlap at the end of line. This is an issue in `react-native` where text from other lines concatenates into the first one even if we add `\n` to the first line, where the lines returned from `onTextLayout` indicates a different response.
122114
To overcome this issue, use `numberOfLines` greater than `1`.

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset']
3+
};

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {SafeAreaView, StyleSheet, View} from 'react-native';
3-
import ReadMore from './src/ReadMore';
3+
import ReadMore from './src';
44

55
const App = () => {
66
return (

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
COPY_PHASE_STRIP = NO;
562562
ENABLE_STRICT_OBJC_MSGSEND = YES;
563563
ENABLE_TESTABILITY = YES;
564-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
564+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
565565
GCC_C_LANGUAGE_STANDARD = gnu99;
566566
GCC_DYNAMIC_NO_PIC = NO;
567567
GCC_NO_COMMON_BLOCKS = YES;
@@ -627,7 +627,7 @@
627627
COPY_PHASE_STRIP = YES;
628628
ENABLE_NS_ASSERTIONS = NO;
629629
ENABLE_STRICT_OBJC_MSGSEND = YES;
630-
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
630+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
631631
GCC_C_LANGUAGE_STANDARD = gnu99;
632632
GCC_NO_COMMON_BLOCKS = YES;
633633
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

example/src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ReadMore from './ReadMore';
2+
3+
export default ReadMore;

index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@fawazahmed/react-native-read-more",
3-
"version": "2.3.3",
3+
"version": "2.3.4",
44
"description": "A simple react native library to show large blocks of text in a condensed manner with the ability to collapse and expand.",
5-
"main": "index.js",
5+
"main": "dist/index.js",
66
"types": "index.d.ts",
77
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"build": "babel example/src/** -d ./dist"
910
},
1011
"repository": {
1112
"type": "git",
@@ -24,7 +25,10 @@
2425
"mobile",
2526
"ios",
2627
"android",
27-
"ui"
28+
"ui",
29+
"javascript",
30+
"typescript",
31+
"inline"
2832
],
2933
"author": {
3034
"name": "Fawaz Ahmed",
@@ -40,5 +44,14 @@
4044
},
4145
"publishConfig": {
4246
"registry": "https://registry.npmjs.org/"
47+
},
48+
"peerDependencies": {
49+
"react": "*",
50+
"react-native": "*"
51+
},
52+
"devDependencies": {
53+
"@babel/cli": "^7.17.6",
54+
"@babel/core": "^7.17.5",
55+
"metro-react-native-babel-preset": "^0.68.0"
4356
}
4457
}

0 commit comments

Comments
 (0)