mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
* Move useSyncExternalStore shim to a nested entrypoint Also renames `useSyncExternalStoreExtra` to `useSyncExternalStoreWithSelector`. - 'use-sync-external-store/shim' -> A shim for `useSyncExternalStore` that works in React 16 and 17 (any release that supports hooks). The module will first check if the built-in React API exists, before falling back to the shim. - 'use-sync-external-store/with-selector' -> An extended version of `useSyncExternalStore` that also supports `selector` and `isEqual` options. It does _not_ shim `use-sync-external-store`; it composes the built-in React API. **Use this if you only support 18+.** - 'use-sync-external-store/shim/with-selector' -> Same API, but it composes `use-sync-external-store/shim` instead. **Use this for compatibility with 16 and 17.** - 'use-sync-external-store' -> Re-exports React's built-in API. Not meant to be used. It will warn and direct users to either the shim or the built-in API. * Upgrade useSyncExternalStore to alpha channel
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
const {readdirSync, statSync} = require('fs');
|
|
const {join} = require('path');
|
|
const baseConfig = require('./config.base');
|
|
|
|
process.env.IS_BUILD = true;
|
|
|
|
const NODE_MODULES_DIR =
|
|
process.env.RELEASE_CHANNEL === 'stable' ? 'oss-stable' : 'oss-experimental';
|
|
|
|
// 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');
|
|
let stat;
|
|
try {
|
|
stat = statSync(packagePath);
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
return stat.isFile();
|
|
});
|
|
|
|
// Create a module map to point React packages to the build output
|
|
const moduleNameMapper = {};
|
|
|
|
// Allow bundle tests to read (but not write!) default feature flags.
|
|
// This lets us determine whether we're running in different modes
|
|
// without making relevant tests internal-only.
|
|
moduleNameMapper[
|
|
'^shared/ReactFeatureFlags'
|
|
] = `<rootDir>/packages/shared/forks/ReactFeatureFlags.readonly`;
|
|
|
|
// Map packages to bundles
|
|
packages.forEach(name => {
|
|
// Root entry point
|
|
moduleNameMapper[`^${name}$`] = `<rootDir>/build/${NODE_MODULES_DIR}/${name}`;
|
|
// Named entry points
|
|
moduleNameMapper[
|
|
`^${name}\/([^\/]+)$`
|
|
] = `<rootDir>/build/${NODE_MODULES_DIR}/${name}/$1`;
|
|
});
|
|
|
|
moduleNameMapper[
|
|
'use-sync-external-store/shim/with-selector'
|
|
] = `<rootDir>/build/${NODE_MODULES_DIR}/use-sync-external-store/shim/with-selector`;
|
|
moduleNameMapper[
|
|
'use-sync-external-store/shim/index.native'
|
|
] = `<rootDir>/build/${NODE_MODULES_DIR}/use-sync-external-store/shim/index.native`;
|
|
|
|
module.exports = Object.assign({}, baseConfig, {
|
|
// Redirect imports to the compiled bundles
|
|
moduleNameMapper,
|
|
modulePathIgnorePatterns: [
|
|
...baseConfig.modulePathIgnorePatterns,
|
|
'packages/react-devtools-extensions',
|
|
'packages/react-devtools-shared',
|
|
],
|
|
// Don't run bundle tests on -test.internal.* files
|
|
testPathIgnorePatterns: ['/node_modules/', '-test.internal.js$'],
|
|
// Exclude the build output from transforms
|
|
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build/'],
|
|
setupFiles: [
|
|
...baseConfig.setupFiles,
|
|
require.resolve('./setupTests.build.js'),
|
|
],
|
|
});
|