Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 0 additions & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ jobs:
with:
build-script: 'compile'
omit-unchanged: 'true'
exclude: './packages/react-native-web/dist/cjs/{index.js,**/*.js}'
pattern: './packages/react-native-web/dist/{index.js,**/*.js}'
repo-token: '${{ secrets.GITHUB_TOKEN }}'
40 changes: 21 additions & 19 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
const createConfig = ({ modules }) => {
const plugins = [
['babel-plugin-syntax-hermes-parser', { parseLangTypes: 'flow' }],
'@babel/plugin-transform-flow-strip-types'
].concat(modules ? ['babel-plugin-add-module-exports'] : []);

export default function (api) {
return {
plugins,
plugins: [
['babel-plugin-syntax-hermes-parser', { parseLangTypes: 'flow' }],
'@babel/plugin-transform-flow-strip-types',

...(api.env('test')
? // Jest resolves paths without extensions. The extensions depend on other
// files on disk, which Jest's transform cache does not track.
[]
: // Output is published as "type": "module", which requires fully specified
// import paths (e.g. './View/index.js', 'fbjs/lib/invariant.js')
// Only list packages without an "exports" field in `includePackages`
[
[
'babel-plugin-fully-specified',
{ includePackages: ['fbjs/', 'styleq/'] }
]
])
],
presets: [
['@babel/preset-react', { useSpread: true }],
[
'@babel/preset-env',
{
loose: true,
modules,
modules: false,
targets: {
browsers: ['chrome 96', 'firefox 94', 'safari 15.1', 'ios_saf 15.1']
}
}
]
]
};
};

module.exports = function (api) {
if (api) {
api.cache(true);
}

return process.env.BABEL_ENV === 'commonjs' || process.env.NODE_ENV === 'test'
? createConfig({ modules: 'commonjs' })
: createConfig({ modules: false });
};
}
14 changes: 7 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'use strict';

const babelConfig = require('./babel.config.js');

const shared = {
coveragePathIgnorePatterns: [
'/node_modules/',
Expand All @@ -22,22 +18,26 @@ const shared = {
printBasicPrototype: false
},
transform: {
'\\.[jt]sx?$': ['babel-jest', babelConfig()]
'\\.[jt]sx?$': 'babel-jest'
}
};

module.exports = {
export default {
projects: [
{
...shared,
displayName: 'dom',
setupFiles: [require.resolve('./jest.setup.dom.js')],
setupFiles: [
'<rootDir>/jest.setup.globals.js',
'<rootDir>/jest.setup.dom.js'
],
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/?(*-)+(spec|test).[jt]s?(x)']
},
{
...shared,
displayName: 'node',
setupFiles: ['<rootDir>/jest.setup.globals.js'],
testEnvironment: 'node',
testMatch: ['**/__tests__/**/?(*-)+(spec|test).node.[jt]s?(x)']
}
Expand Down
2 changes: 2 additions & 0 deletions jest.setup.globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Jest does not add the `jest` global when tests run as native ES modules
globalThis.jest = import.meta.jest;
Loading
Loading