Skip to content

Instantly share code, notes, and snippets.

@naqvitalha
Created February 22, 2024 17:41
Show Gist options
  • Save naqvitalha/bb6d92687de0c736b80cb6afbf9cba9d to your computer and use it in GitHub Desktop.
Save naqvitalha/bb6d92687de0c736b80cb6afbf9cba9d to your computer and use it in GitHub Desktop.
Inline Requires true
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