From d0786552cd933c236079f465df0df752b091bd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwa=C5=9Bniewski?= Date: Mon, 4 Dec 2023 13:42:02 +0100 Subject: [PATCH] Fix build step for `@callstack/out-of-tree-platforms` (#46) * feat: setup @callstack/out-of-tree-platforms to build properly * feat: add build packages step to `oot-release.js` script * chore: format package.json --- .circleci/verdaccio.yml | 4 ++++ packages/out-of-tree-platforms/.gitignore | 2 ++ packages/out-of-tree-platforms/index.js.flow | 1 + packages/out-of-tree-platforms/package.json | 23 +++++++++++-------- .../out-of-tree-platforms/{ => src}/index.js | 4 +--- scripts/build/config.js | 4 ++++ scripts/oot-release.js | 9 ++++++++ 7 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 packages/out-of-tree-platforms/.gitignore create mode 100644 packages/out-of-tree-platforms/index.js.flow rename packages/out-of-tree-platforms/{ => src}/index.js (92%) diff --git a/.circleci/verdaccio.yml b/.circleci/verdaccio.yml index cec3a220475903..df7d0144092628 100644 --- a/.circleci/verdaccio.yml +++ b/.circleci/verdaccio.yml @@ -19,6 +19,10 @@ packages: '@react-native/*': access: $all publish: $all + proxy: npmjs + '@callstack/*': + access: $all + publish: $all '@*/*': access: $all publish: $authenticated diff --git a/packages/out-of-tree-platforms/.gitignore b/packages/out-of-tree-platforms/.gitignore new file mode 100644 index 00000000000000..ac0720f94136cd --- /dev/null +++ b/packages/out-of-tree-platforms/.gitignore @@ -0,0 +1,2 @@ +# Build output +/dist \ No newline at end of file diff --git a/packages/out-of-tree-platforms/index.js.flow b/packages/out-of-tree-platforms/index.js.flow new file mode 100644 index 00000000000000..8420b1093fdb2f --- /dev/null +++ b/packages/out-of-tree-platforms/index.js.flow @@ -0,0 +1 @@ +export * from './src'; diff --git a/packages/out-of-tree-platforms/package.json b/packages/out-of-tree-platforms/package.json index 3a1d042fdcdafe..648226808be25f 100644 --- a/packages/out-of-tree-platforms/package.json +++ b/packages/out-of-tree-platforms/package.json @@ -2,23 +2,26 @@ "name": "@callstack/out-of-tree-platforms", "version": "0.74.0", "description": "Utils for React Native out of tree platforms.", - "license": "MIT", + "keywords": ["out-of-tree", "react-native"], + "homepage": "https://github.com/callstack/react-native-visionos/tree/HEAD/packages/out-of-tree-platforms#readme", + "bugs": "https://github.com/callstack/react-native-visionos/issues", "repository": { "type": "git", "url": "https://github.com/callstack/react-native-visionos.git", "directory": "packages/out-of-tree-platforms" }, - "homepage": "https://github.com/callstack/react-native-visionos/tree/HEAD/packages/out-of-tree-platforms#readme", - "keywords": [ - "out-of-tree", - "react-native" + "license": "MIT", + "exports": { + ".": "./dist/index.js", + "./package.json": "./package.json" + }, + "files": [ + "dist" ], - "bugs": "https://github.com/facebook/react-native/issues", + "devDependencies": { + "metro-resolver": "^0.80.0" + }, "engines": { "node": ">=18" - }, - "exports": "./index.js", - "devDependencies": { - "metro-resolver": "^0.80.0" } } diff --git a/packages/out-of-tree-platforms/index.js b/packages/out-of-tree-platforms/src/index.js similarity index 92% rename from packages/out-of-tree-platforms/index.js rename to packages/out-of-tree-platforms/src/index.js index d095bafc534da6..a88b678821283b 100644 --- a/packages/out-of-tree-platforms/index.js +++ b/packages/out-of-tree-platforms/src/index.js @@ -18,7 +18,7 @@ type ResolverConfig = { * Creates a custom Metro resolver that maps platform extensions to package names. * To be used in app's `metro.config.js` as `resolver.resolveRequest`. */ -const getPlatformResolver = (config: ResolverConfig): CustomResolver => { +export const getPlatformResolver = (config: ResolverConfig): CustomResolver => { return (context, moduleName, platform) => { // `customResolverOptions` is populated through `?resolver.platformExtension` query params // in the jsBundleURLForBundleRoot method of the react-native/React/Base/RCTBundleURLProvider.mm @@ -42,5 +42,3 @@ const getPlatformResolver = (config: ResolverConfig): CustomResolver => { return context.resolveRequest(context, modifiedModuleName, platform); }; }; - -module.exports = {getPlatformResolver}; diff --git a/scripts/build/config.js b/scripts/build/config.js index a2014995b829d9..dcbe55c73f41f9 100644 --- a/scripts/build/config.js +++ b/scripts/build/config.js @@ -45,6 +45,10 @@ const buildConfig /*: BuildConfig */ = { 'community-cli-plugin': { target: 'node', }, + 'out-of-tree-platforms': { + target: 'node', + emitTypeScriptDefs: true, + }, 'dev-middleware': { target: 'node', emitTypeScriptDefs: true, diff --git a/scripts/oot-release.js b/scripts/oot-release.js index 21e281e78b148e..febf91e07b35d3 100644 --- a/scripts/oot-release.js +++ b/scripts/oot-release.js @@ -9,11 +9,14 @@ const forEachPackage = require('./monorepo/for-each-package'); const {applyPackageVersions, publishPackage} = require('./npm-utils'); const updateTemplatePackage = require('./update-template-package'); +const {execSync} = require('child_process'); const fs = require('fs'); const path = require('path'); const {cat, echo, exit} = require('shelljs'); const yargs = require('yargs'); +const REPO_ROOT = path.resolve(__dirname, '../'); + /** * This script updates core packages to the version of React Native that we are basing on, * updates internal visionOS packages and releases them. @@ -116,6 +119,12 @@ function releaseOOT( }); echo(`Updating template and it's dependencies to ${reactNativeVersion}`); + echo('Building packages...\n'); + execSync('node ./scripts/build/build.js', { + cwd: REPO_ROOT, + stdio: [process.stdin, process.stdout, process.stderr], + }); + // Release visionOS packages only if OTP is passed if (!oneTimePassword) { return;