Skip to content

Commit

Permalink
added moduleResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
OkancanCosar committed Dec 7, 2020
1 parent 2903a2e commit 198091c
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"plugins": [
[
"module-resolver",
{
"root": ["."],
"alias": {
"@assets": "./src/assets"
}
}
]
]
}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Package usage and installation processes that may be required for React-native application.

- Codepush [react-native-code-push handbook](docs/codepush.md)
- Lottie [lottie-react-native handbook](docs/lottie.md)
- Splash Screen [react-native-splash-screen handbook](docs/splash.md)
- Codepush [Handbook](docs/codepush.md) | [Commit](https://github.com/OkancanCosar/react-native-basics-setups/commit/1c534426e49e82207bf37dcf408883905596128)
- Lottie [Handbook](docs/lottie.md) | [Commit](https://github.com/OkancanCosar/react-native-basics-setups/commit/ff5763c903b12032efd6d4e215088c28c01bcaec)
- Splash Screen [Handbook](docs/splash.md) | [Commit](https://github.com/OkancanCosar/react-native-basics-setups/commit/d711e0f5395983844a32cd3de718d39627090f12)
- Module Resolver [Handbook](docs/moduleresolver.md) | [Commit](d711e0f5395983844a32cd3de718d39627090f12)
46 changes: 46 additions & 0 deletions docs/moduleresolver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Module Resolver handbook

[offical babel-plugin-module-resolver](https://yarnpkg.com/package/babel-plugin-module-resolver)

#### Install Module Resolver package in the project

```bash
$ yarn add -D babel-plugin-module-resolver
```

##### 1. Create jsconfig.json for VS Code Configure the path mapping

```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@assets": ["./src/assets"]
}
}
}
```

##### 2. Specify the plugin in your .babelrc with the custom root or alias.

```
{
"plugins": [
[
"module-resolver",
{
"root": ["."],
"alias": {
"@assets": "./src/assets",
}
}
]
]
}
```

### Usage

```js
import { Assets } from "@assets";
```
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@assets": ["./src/assets"]
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"babel-plugin-module-resolver": "^4.0.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/complex/UpdateApp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { StyleSheet, Text, View } from "react-native";

import { Assets } from "../../assets";
import { Assets } from "@assets";
import { Lottie } from "../primitives/Lottie";
import { height } from "../styles/GStyles";

Expand Down
38 changes: 37 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,17 @@ babel-plugin-jest-hoist@^25.5.0:
"@babel/types" "^7.3.3"
"@types/babel__traverse" "^7.0.6"

babel-plugin-module-resolver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-4.0.0.tgz#8f3a3d9d48287dc1d3b0d5595113adabd36a847f"
integrity sha512-3pdEq3PXALilSJ6dnC4wMWr0AZixHRM4utpdpBR9g5QG7B7JwWyukQv7a9hVxkbGFl+nQbrHDqqQOIBtTXTP/Q==
dependencies:
find-babel-config "^1.2.0"
glob "^7.1.6"
pkg-up "^3.1.0"
reselect "^4.0.0"
resolve "^1.13.1"

babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0:
version "7.0.0-beta.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf"
Expand Down Expand Up @@ -3024,6 +3035,14 @@ finalhandler@1.1.2:
statuses "~1.5.0"
unpipe "~1.0.0"

find-babel-config@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.2.0.tgz#a9b7b317eb5b9860cda9d54740a8c8337a2283a2"
integrity sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA==
dependencies:
json5 "^0.5.1"
path-exists "^3.0.0"

find-cache-dir@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7"
Expand Down Expand Up @@ -4402,6 +4421,11 @@ json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=

json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=

json5@^2.1.2:
version "2.1.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43"
Expand Down Expand Up @@ -5578,6 +5602,13 @@ pkg-dir@^4.2.0:
dependencies:
find-up "^4.0.0"

pkg-up@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5"
integrity sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==
dependencies:
find-up "^3.0.0"

plist@3.0.1, plist@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.1.tgz#a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c"
Expand Down Expand Up @@ -6060,6 +6091,11 @@ requires-port@^1.0.0:
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=

reselect@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==

resolve-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d"
Expand Down Expand Up @@ -6092,7 +6128,7 @@ resolve@1.1.7:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

resolve@^1.10.0, resolve@^1.12.0, resolve@^1.15.1, resolve@^1.17.0, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.15.1, resolve@^1.17.0, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
Expand Down

0 comments on commit 198091c

Please sign in to comment.