Created
February 22, 2024 17:41
-
-
Save naqvitalha/bb6d92687de0c736b80cb6afbf9cba9d to your computer and use it in GitHub Desktop.
Inline Requires true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const exclusionList = require("metro-config/src/defaults/exclusionList"); | |
const escape = require("escape-string-regexp"); | |
const package = require("../package.json"); | |
const modules = Object.keys({ | |
...package.peerDependencies, | |
}); | |
const root = path.resolve(__dirname, ".."); | |
let watchFolders = [root]; | |
watchFolders = watchFolders.concat([path.join(__dirname, "./node_modules")]); | |
watchFolders = watchFolders.concat([path.join(__dirname, "../node_modules")]); | |
module.exports = (() => { | |
const config = { | |
projectRoot: __dirname, | |
transformer: { | |
getTransformOptions: () => ({ | |
transform: { | |
// Set to true | |
inlineRequires: true, | |
}, | |
}), | |
}, | |
resolver: { | |
blockList: exclusionList( | |
modules.map( | |
(m) => | |
new RegExp(`^${escape(path.join(root, "node_modules", m))}\\/.*$`) | |
) | |
), | |
extraNodeModules: modules.reduce((acc, name) => { | |
acc[name] = path.join(__dirname, "node_modules", name); | |
return acc; | |
}, {}), | |
}, | |
watchFolders, | |
}; | |
if (process.env.CI === "true") { | |
config.maxWorkers = 1; | |
} | |
return config; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment