From aee1d05fb30462a0269f1c19b18e62f71201a195 Mon Sep 17 00:00:00 2001 From: Sakul Date: Tue, 26 Jan 2021 19:10:09 +0545 Subject: [PATCH] feat: fix module resolver --- js/alias.js | 15 --------- js/babel.config.js | 13 ++++++-- js/tsconfig.json | 79 +--------------------------------------------- 3 files changed, 11 insertions(+), 96 deletions(-) delete mode 100644 js/alias.js diff --git a/js/alias.js b/js/alias.js deleted file mode 100644 index 85d2483574..0000000000 --- a/js/alias.js +++ /dev/null @@ -1,15 +0,0 @@ -const fs = require('fs') -const path = require('path') - -const pkgsRoot = path.join(__dirname, 'packages') -const pkgPrefix = '@berty-tech' - -const pkgs = fs.readdirSync(pkgsRoot) - -module.exports = pkgs.reduce( - (alias, name) => ({ - ...alias, - [path.join(pkgPrefix, name)]: './' + path.relative(__dirname, path.join(pkgsRoot, name)), - }), - {}, -) diff --git a/js/babel.config.js b/js/babel.config.js index 5174f3a06e..ce6740776f 100644 --- a/js/babel.config.js +++ b/js/babel.config.js @@ -1,6 +1,13 @@ -const alias = require('./alias') - module.exports = { presets: ['module:metro-react-native-babel-preset'], - plugins: [['module-resolver', { alias }]], + plugins: [ + [ + 'module-resolver', + { + alias: { + '@berty-tech': './packages/', + }, + }, + ], + ], } diff --git a/js/tsconfig.json b/js/tsconfig.json index ec41b8815c..4a92e8ff64 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -39,84 +39,7 @@ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, "baseUrl": "./" /* Base directory to resolve non-absolute module names. */, "paths": { - "@berty-tech/api": [ - "./packages/api" - ], - "@berty-tech/api/*": [ - "./packages/api/*" - ], - "@berty-tech/assets": [ - "./packages/assets" - ], - "@berty-tech/assets/*": [ - "./packages/assets/*" - ], - "@berty-tech/berty-i18n": [ - "./packages/berty-i18n" - ], - "@berty-tech/berty-i18n/*": [ - "./packages/berty-i18n/*" - ], - "@berty-tech/components": [ - "./packages/components" - ], - "@berty-tech/components/*": [ - "./packages/components/*" - ], - "@berty-tech/config": [ - "./packages/config" - ], - "@berty-tech/config/*": [ - "./packages/config/*" - ], - "@berty-tech/go-bridge": [ - "./packages/go-bridge" - ], - "@berty-tech/go-bridge/*": [ - "./packages/go-bridge/*" - ], - "@berty-tech/grpc-bridge": [ - "./packages/grpc-bridge" - ], - "@berty-tech/grpc-bridge/*": [ - "./packages/grpc-bridge/*" - ], - "@berty-tech/messenger-app": [ - "./packages/messenger-app" - ], - "@berty-tech/messenger-app/*": [ - "./packages/messenger-app/*" - ], - "@berty-tech/music-player": [ - "./packages/music-player" - ], - "@berty-tech/music-player/*": [ - "./packages/music-player/*" - ], - "@berty-tech/navigation": [ - "./packages/navigation" - ], - "@berty-tech/navigation/*": [ - "./packages/navigation/*" - ], - "@berty-tech/store": [ - "./packages/store" - ], - "@berty-tech/store/*": [ - "./packages/store/*" - ], - "@berty-tech/styles": [ - "./packages/styles" - ], - "@berty-tech/styles/*": [ - "./packages/styles/*" - ], - "@berty-tech/web-dev-app": [ - "./packages/web-dev-app" - ], - "@berty-tech/web-dev-app/*": [ - "./packages/web-dev-app/*" - ] + "@berty-tech/*": ["./packages/*"] } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ , // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */