diff --git a/lib/babel.config.cjs b/babel.config.cjs rename from lib/babel.config.cjs rename to babel.config.cjs --- a/lib/babel.config.cjs +++ b/babel.config.cjs @@ -7,7 +7,6 @@ '@babel/plugin-proposal-nullish-coalescing-operator', ['@babel/plugin-transform-runtime', { useESModules: true }], ], - env: { test: { presets: [ @@ -22,4 +21,5 @@ ], }, }, + babelrcRoots: ['.', 'keyserver', 'web', 'native', 'desktop', 'landing'], }; diff --git a/desktop/babel.config.cjs b/desktop/.babelrc.cjs rename from desktop/babel.config.cjs rename to desktop/.babelrc.cjs diff --git a/keyserver/babel.config.cjs b/keyserver/.babelrc.cjs copy from keyserver/babel.config.cjs copy to keyserver/.babelrc.cjs diff --git a/keyserver/Dockerfile b/keyserver/Dockerfile --- a/keyserver/Dockerfile +++ b/keyserver/Dockerfile @@ -163,7 +163,7 @@ # These are needed for babel-build-comm-config COPY --chown=comm keyserver/src keyserver/src COPY --chown=comm keyserver/bash/source-nvm.sh keyserver/bash/source-nvm.sh -COPY --chown=comm keyserver/babel.config.cjs keyserver/babel.config.cjs +COPY --chown=comm keyserver/.babelrc.cjs keyserver/.babelrc.cjs COPY --chown=comm lib lib/ diff --git a/keyserver/babel.config.cjs b/keyserver/babel.config.cjs --- a/keyserver/babel.config.cjs +++ b/keyserver/babel.config.cjs @@ -1,35 +1,2 @@ -module.exports = { - presets: ['@babel/preset-react', '@babel/preset-flow'], - plugins: [ - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-object-rest-spread', - '@babel/plugin-syntax-dynamic-import', - '@babel/plugin-proposal-optional-chaining', - '@babel/plugin-proposal-nullish-coalescing-operator', - ['@babel/plugin-transform-runtime', { useESModules: true }], - ], - env: { - test: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - node: 'current', - }, - }, - ], - ], - plugins: [ - // Replace the import.meta object in the Jest testing environment. - // This allows Jest to understand import.meta.url in rust-node-addon. - [ - 'babel-plugin-transform-import-meta', - { - replaceWith: '({ url: __filename })', - }, - ], - ], - }, - }, -}; +const config = require('./.babelrc.cjs'); +module.exports = config; diff --git a/keyserver/package.json b/keyserver/package.json --- a/keyserver/package.json +++ b/keyserver/package.json @@ -7,8 +7,8 @@ "main": "dist/keyserver", "scripts": { "clean": "rm -rf dist/ && rm -rf node_modules/ && mkdir dist", - "babel-build-comm-config": ". bash/source-nvm.sh && yarn --silent babel src/lib/utils/comm-config.js --out-dir dist/lib/utils/ --config-file ./babel.config.cjs", - "babel-build": ". bash/source-nvm.sh && yarn --silent babel src/ --out-dir dist/ --config-file ./babel.config.cjs --verbose --ignore 'src/landing/flow-typed','src/landing/node_modules','src/landing/package.json','src/lib/flow-typed','src/lib/node_modules','src/lib/package.json','src/web/flow-typed','src/web/node_modules','src/web/package.json','src/web/dist','src/web/webpack.config.js','src/web/account-bar.react.js','src/web/app.react.js','src/web/calendar','src/web/chat','src/web/flow','src/web/loading-indicator.react.js','src/web/modals','src/web/root.js','src/web/router-history.js','src/web/script.js','src/web/selectors/chat-selectors.js','src/web/selectors/entry-selectors.js','src/web/splash','src/web/vector-utils.js','src/web/vectors.react.js'", + "babel-build-comm-config": ". bash/source-nvm.sh && yarn --silent babel src/lib/utils/comm-config.js --out-dir dist/lib/utils/ --config-file ./.babelrc.cjs", + "babel-build": ". bash/source-nvm.sh && yarn --silent babel src/ --out-dir dist/ --config-file ./.babelrc.cjs --verbose --ignore 'src/landing/flow-typed','src/landing/node_modules','src/landing/package.json','src/lib/flow-typed','src/lib/node_modules','src/lib/package.json','src/web/flow-typed','src/web/node_modules','src/web/package.json','src/web/dist','src/web/webpack.config.js','src/web/account-bar.react.js','src/web/app.react.js','src/web/calendar','src/web/chat','src/web/flow','src/web/loading-indicator.react.js','src/web/modals','src/web/root.js','src/web/router-history.js','src/web/script.js','src/web/selectors/chat-selectors.js','src/web/selectors/entry-selectors.js','src/web/splash','src/web/vector-utils.js','src/web/vectors.react.js'", "rsync": "rsync -rLpmuv --exclude '*/package.json' --exclude '*/node_modules/*' --include '*.json' --include '*.cjs' --include '*.node' --exclude '*.*' src/ dist/", "prod-build": "yarn babel-build && yarn rsync", "prod": "KEYSERVER=true node --trace-warnings --loader=./loader.mjs dist/keyserver", @@ -102,7 +102,7 @@ "/src" ], "transform": { - "\\.js$": "babel-jest" + "\\.js$": ["babel-jest", { "rootMode": "upward" }] }, "transformIgnorePatterns": [ "/node_modules/(?!@babel/runtime)" diff --git a/landing/babel.config.cjs b/landing/.babelrc.cjs rename from landing/babel.config.cjs rename to landing/.babelrc.cjs diff --git a/landing/webpack.config.cjs b/landing/webpack.config.cjs --- a/landing/webpack.config.cjs +++ b/landing/webpack.config.cjs @@ -7,7 +7,7 @@ createNodeServerRenderingConfig, } = require('lib/webpack/shared.cjs'); -const babelConfig = require('./babel.config.cjs'); +const babelConfig = require('./.babelrc.cjs'); const baseBrowserConfig = { entry: { diff --git a/lib/package.json b/lib/package.json --- a/lib/package.json +++ b/lib/package.json @@ -67,7 +67,7 @@ }, "jest": { "transform": { - "\\.js$": "babel-jest" + "\\.js$": ["babel-jest", { "rootMode": "upward" }] }, "transformIgnorePatterns": [ "/node_modules/(?!@babel/runtime)" diff --git a/native/babel.config.cjs b/native/.babelrc.cjs copy from native/babel.config.cjs copy to native/.babelrc.cjs diff --git a/native/babel.config.cjs b/native/babel.config.cjs --- a/native/babel.config.cjs +++ b/native/babel.config.cjs @@ -1,15 +1,2 @@ -module.exports = { - presets: ['module:metro-react-native-babel-preset'], - plugins: [ - 'transform-remove-strict-mode', - '@babel/plugin-proposal-optional-chaining', - '@babel/plugin-proposal-nullish-coalescing-operator', - // react-native-reanimated must be last - 'react-native-reanimated/plugin', - ], - env: { - production: { - plugins: ['transform-remove-console'], - }, - }, -}; +const config = require('./.babelrc.cjs'); +module.exports = config; diff --git a/web/babel.config.cjs b/web/.babelrc.cjs copy from web/babel.config.cjs copy to web/.babelrc.cjs diff --git a/web/babel.config.cjs b/web/babel.config.cjs --- a/web/babel.config.cjs +++ b/web/babel.config.cjs @@ -1,24 +1,2 @@ -module.exports = { - presets: ['@babel/preset-react', '@babel/preset-flow'], - plugins: [ - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-object-rest-spread', - '@babel/plugin-proposal-optional-chaining', - '@babel/plugin-proposal-nullish-coalescing-operator', - ['@babel/plugin-transform-runtime', { useESModules: true }], - ], - env: { - test: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - node: 'current', - }, - }, - ], - ], - }, - }, -}; +const config = require('./.babelrc.cjs'); +module.exports = config; diff --git a/web/package.json b/web/package.json --- a/web/package.json +++ b/web/package.json @@ -104,7 +104,7 @@ "" ], "transform": { - "\\.js$": "babel-jest" + "\\.js$": ["babel-jest", { "rootMode": "upward" }] }, "transformIgnorePatterns": [ "/node_modules/(?!(@babel/runtime|thumbhash))" diff --git a/web/webpack.config.cjs b/web/webpack.config.cjs --- a/web/webpack.config.cjs +++ b/web/webpack.config.cjs @@ -9,7 +9,7 @@ createWebWorkersConfig, } = require('lib/webpack/shared.cjs'); -const babelConfig = require('./babel.config.cjs'); +const babelConfig = require('./.babelrc.cjs'); async function getConfig(configName) { const { getCommConfig } = await import(