Files
notesnook/apps/mobile/native/metro.config.js

65 lines
2.0 KiB
JavaScript
Raw Normal View History

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2022-08-16 16:48:10 +05:00
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
2022-08-30 16:59:43 +05:00
const nodeModulesPaths = [path.resolve(path.join(__dirname, '../node_modules'))];
const config = {
2022-08-16 16:48:10 +05:00
projectRoot: __dirname,
watchFolders: [
path.join(__dirname, '../app'),
path.join(__dirname, '../share'),
path.join(__dirname, '../node_modules'),
2022-08-29 16:19:17 +05:00
path.join(__dirname, '../e2e'),
2022-08-30 16:59:43 +05:00
path.join(__dirname, "../../../packages"),
]
};
const mergedConfig = mergeConfig(getDefaultConfig(__dirname), config);
mergedConfig.resolver = {
sourceExts: ['jsx', 'js', 'ts', 'tsx', 'cjs', "json"],
nodeModulesPaths,
extraNodeModules: {
"react": path.join(__dirname, "../node_modules/react"),
"react-dom": path.join(__dirname, "../node_modules/react-dom"),
"@notesnook": path.join(__dirname, "../../../packages"),
"@notifee/react-native": path.join(__dirname, "../node_modules/@ammarahmed/notifee-react-native"),
2022-08-16 16:48:10 +05:00
},
resolveRequest: (context, moduleName, platform) => {
2023-12-29 08:53:22 +05:00
if (moduleName === "node:crypto") {
return {
2024-01-02 10:54:44 +05:00
type:"empty"
2023-12-29 08:53:22 +05:00
}
}
2024-09-24 13:14:23 +05:00
if (moduleName === "crypto") {
return {
type:"empty"
}
}
if (moduleName ==='react') {
// Resolve react package from mobile app's node_modules folder always.
return {
filePath: path.resolve(path.join(__dirname, '../node_modules', "react","index.js")),
type: 'sourceFile',
};
}
2023-11-16 08:54:37 +05:00
if (moduleName ==='kysely') {
// Resolve react package from mobile app's node_modules folder always.
return {
filePath: path.resolve(path.join(__dirname, '../node_modules', "kysely","dist", "cjs", "index.js")),
type: 'sourceFile',
};
}
return context.resolveRequest(context, moduleName, platform);
2024-07-27 10:19:43 +05:00
},
2022-08-16 16:48:10 +05:00
};
module.exports = mergedConfig;