mirror of
https://github.com/facebook/react.git
synced 2026-02-26 07:45:12 +00:00
* Move build/packages/* to build/node_modules/* This fixes Node resolution in that folder and lets us require() packages in it in Node shell for manual testing. * Link fixtures to packages/node_modules This updates the location and also uses link: instead of file: to avoid Yarn caching the folder contents.
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const {readdirSync, statSync} = require('fs');
|
|
const {join} = require('path');
|
|
const sourceConfig = require('./config.source');
|
|
|
|
// Find all folders in packages/* with package.json
|
|
const packagesRoot = join(__dirname, '..', '..', 'packages');
|
|
const packages = readdirSync(packagesRoot).filter(dir => {
|
|
if (dir.charAt(0) === '.') {
|
|
return false;
|
|
}
|
|
const packagePath = join(packagesRoot, dir, 'package.json');
|
|
return statSync(packagePath).isFile();
|
|
});
|
|
// Create a module map to point React packages to the build output
|
|
const moduleNameMapper = {};
|
|
packages.forEach(name => {
|
|
// Root entry point
|
|
moduleNameMapper[`^${name}$`] = `<rootDir>/build/node_modules/${name}`;
|
|
// Named entry points
|
|
moduleNameMapper[`^${name}/(.*)$`] = `<rootDir>/build/node_modules/${
|
|
name
|
|
}/$1`;
|
|
});
|
|
|
|
module.exports = Object.assign({}, sourceConfig, {
|
|
// Redirect imports to the compiled bundles
|
|
moduleNameMapper,
|
|
// Don't run bundle tests on blacklisted -test.internal.* files
|
|
testPathIgnorePatterns: ['/node_modules/', '-test.internal.js$'],
|
|
// Exclude the build output from transforms
|
|
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build/'],
|
|
});
|