Skip to content

Commit

Permalink
Add Polyfills For Release Build (#32)
Browse files Browse the repository at this point in the history
* podfile

* style

* Start fixing metro config

* Fix build

* Simplify babel setup

* Do not cache babel

* Use crypto shim

* Rename file
  • Loading branch information
hmallen99 authored Jan 9, 2025
1 parent 28035da commit 8498989
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 38 deletions.
55 changes: 32 additions & 23 deletions packages/clientNative/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,43 @@ const packages = [
'network',
'spatial',
'ui',
'xrui'
'xrui',
];

const generateAliases = () => {
// Generate aliases for all packages
return packages.reduce((aliases, pkg) => ({
...aliases,
[`@ir-engine/${pkg}/*`]: path.resolve(rootDir, `packages/${pkg}/src/*`)
}), {});
return packages.reduce(
(aliases, pkg) => ({
...aliases,
[`@ir-engine/${pkg}/*`]: path.resolve(rootDir, `packages/${pkg}/src/*`),
}),
{},
);
};

module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
alias: generateAliases()
},
module.exports = function (api) {
api.cache(false);
return {
presets: ['module:@react-native/babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
alias: generateAliases(),
},
],
[
'module:react-native-dotenv',
{
envName: '@env',
moduleName: '@env',
path: '../../.env.local',
safe: false,
allowUndefined: true,
verbose: false,
},
],
],
["module:react-native-dotenv", {
"envName": "@env",
"moduleName": "@env",
"path": "../../.env.local",
"safe": false,
"allowUndefined": true,
"verbose": false
}]
],
};
};
27 changes: 27 additions & 0 deletions packages/clientNative/emptyPolyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
CPAL-1.0 License
The contents of this file are subject to the Common Public Attribution License
Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/ir-engine/ir-engine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
specific language governing rights and limitations under the License.
The Original Code is Infinite Reality Engine.
The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Infinite Reality Engine team.
All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
Infinite Reality Engine. All Rights Reserved.
*/


module.exports = {};
67 changes: 62 additions & 5 deletions packages/clientNative/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- DoubleConversion (1.1.6)
- EXConstants (17.0.3):
- ExpoModulesCore
- Expo (52.0.14):
- Expo (52.0.8):
- ExpoModulesCore
- ExpoAsset (11.0.1):
- ExpoModulesCore
Expand All @@ -16,7 +16,7 @@ PODS:
- ReactCommon/turbomodule/core
- ExpoKeepAwake (14.0.1):
- ExpoModulesCore
- ExpoModulesCore (2.1.1):
- ExpoModulesCore (2.0.4):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -101,6 +101,30 @@ PODS:
- nanopb/encode (= 3.30910.0)
- nanopb/decode (3.30910.0)
- nanopb/encode (3.30910.0)
- NitroModules (0.20.1):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-callinvoker
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- OpenSSL-Universal (3.3.2000)
- PromisesObjC (2.4.0)
- PromisesSwift (2.4.0):
- PromisesObjC (= 2.4.0)
Expand Down Expand Up @@ -1362,6 +1386,29 @@ PODS:
- Yoga
- react-native-get-random-values (1.11.0):
- React-Core
- react-native-quick-crypto (0.7.11):
- DoubleConversion
- glog
- hermes-engine
- OpenSSL-Universal
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- React-nativeconfig (0.76.2)
- React-NativeModulesApple (0.76.2):
- glog
Expand Down Expand Up @@ -1655,6 +1702,7 @@ DEPENDENCIES:
- fmt (from `../../../node_modules/react-native/third-party-podspecs/fmt.podspec`)
- glog (from `../../../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- NitroModules (from `../../../node_modules/react-native-nitro-modules`)
- RCT-Folly (from `../../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCT-Folly/Fabric (from `../../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTDeprecation (from `../../../node_modules/react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
Expand Down Expand Up @@ -1688,6 +1736,7 @@ DEPENDENCIES:
- React-microtasksnativemodule (from `../../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
- "react-native-draco (from `../../../node_modules/@callstack/react-native-draco`)"
- react-native-get-random-values (from `../../../node_modules/react-native-get-random-values`)
- react-native-quick-crypto (from `../../../node_modules/react-native-quick-crypto`)
- React-nativeconfig (from `../../../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../../../node_modules/react-native/ReactCommon/reactperflogger`)
Expand Down Expand Up @@ -1732,6 +1781,7 @@ SPEC REPOS:
- GoogleDataTransport
- GoogleUtilities
- nanopb
- OpenSSL-Universal
- PromisesObjC
- PromisesSwift
- SocketRocket
Expand Down Expand Up @@ -1766,6 +1816,8 @@ EXTERNAL SOURCES:
hermes-engine:
:podspec: "../../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
:tag: hermes-2024-11-12-RNv0.76.2-5b4aa20c719830dcf5684832b89a6edb95ac3d64
NitroModules:
:path: "../../../node_modules/react-native-nitro-modules"
RCT-Folly:
:podspec: "../../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTDeprecation:
Expand Down Expand Up @@ -1828,6 +1880,8 @@ EXTERNAL SOURCES:
:path: "../../../node_modules/@callstack/react-native-draco"
react-native-get-random-values:
:path: "../../../node_modules/react-native-get-random-values"
react-native-quick-crypto:
:path: "../../../node_modules/react-native-quick-crypto"
React-nativeconfig:
:path: "../../../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
Expand Down Expand Up @@ -1893,13 +1947,13 @@ SPEC CHECKSUMS:
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
EXConstants: 277129d9a42ba2cf1fad375e7eaa9939005c60be
Expo: f67ed80510d6559419713c2a740767cb03472e97
Expo: 959ac1f7486354ee1d0e1c5332143b4203baf8e9
ExpoAsset: 6f7a8887cbb9fb39fdb0808e7f6f74ba0e1ae9b6
ExpoFileSystem: 83da9dbce2371cc72c3a3ef49e0df54a117310f1
ExpoFont: 12b0217e42ac97029d0f317f0486039a8508cf52
ExpoGL: 9e4ac36b4dfeba548728f835c72fe895364ec3e7
ExpoKeepAwake: 22173f45d767c7d37403fdf48292726901d69ce7
ExpoModulesCore: 91601cfec198cc668e6c112e9b17517f296f0421
ExpoModulesCore: 539ee3e0b90372c6d6605c7e2ba88d8d8b284669
FBLazyVector: bc70dcb22ad30ce734a7cce7210791dc737e230f
Firebase: 7a56fe4f56b5ab81b86a6822f5b8f909ae6fc7e2
FirebaseCore: 93abc05437f8064cd2bc0a53b768fb0bc5a1d006
Expand All @@ -1915,6 +1969,8 @@ SPEC CHECKSUMS:
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
hermes-engine: 3852e37f6158a2fcfad23e31215ed495da3a6a40
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
NitroModules: 51ceb94960a4a40d4fcd90a2815a577d70a05447
OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 84578c8756030547307e4572ab1947de1685c599
Expand Down Expand Up @@ -1948,6 +2004,7 @@ SPEC CHECKSUMS:
React-microtasksnativemodule: cff02bc87f8a1d5b9985c1c92ea8e84e854229d9
react-native-draco: ca7c7ba9364c93a0a19f9197f66790d95abd852f
react-native-get-random-values: d16467cf726c618e9c7a8c3c39c31faa2244bbba
react-native-quick-crypto: 4921fde8af4321dd95df13963a80698c3a8fef34
React-nativeconfig: 7f8cd6cae21f8bb18c53b746c495e72795fc5cb0
React-NativeModulesApple: 3210b7177c11145bb8e0d6f24aae102a221c4ddc
React-perflogger: c8860eaab4fe60d628b27bf0086a372c429fc74f
Expand Down Expand Up @@ -1978,7 +2035,7 @@ SPEC CHECKSUMS:
RNFBApp: 72b96921c64702d51eca9f3ed579c1777efd0d7e
RNFBCrashlytics: 22223ee96beba1130c8906253f5b900f629c2926
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 513b871d622689bd53b51481bbcfb6b8f1a3de5b
Yoga: b31c16dc8150acf90019a65ce2da4b47fab913cb

PODFILE CHECKSUM: 8bbb9ee26c0034dd601d94c137a968f3e9b5c0fe

Expand Down
45 changes: 42 additions & 3 deletions packages/clientNative/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Infinite Reality Engine. All Rights Reserved.

const path = require('path');
const {makeMetroConfig} = require('@rnx-kit/metro-config');
const {getDefaultConfig} = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);
const {sourceExts} = defaultConfig.resolver;

module.exports = makeMetroConfig({
transformer: {
getTransformOptions: async () => ({
Expand Down Expand Up @@ -54,10 +59,44 @@ module.exports = makeMetroConfig({
type: 'sourceFile',
};
}
if (moduleName === 'crypto') {
return context.resolveRequest(
context,
'react-native-quick-crypto',
platform,
);
}
if (
moduleName.startsWith('@ir-engine/editor') ||
moduleName.startsWith('@ir-engine/visual-script')
) {
return {
filePath: path.resolve(__dirname, `./emptyPolyfill.js`),
type: 'sourceFile',
};
}
if (
moduleName.endsWith('.css') ||
moduleName.endsWith('.scss') ||
moduleName.endsWith('.sass') ||
moduleName.endsWith('scss?inline') ||
moduleName.endsWith('svg?react')
) {
return {
filePath: path.resolve(__dirname, './emptyPolyfill.js'),
type: 'sourceFile',
};
}
return context.resolveRequest(context, moduleName, platform);
},
sourceExts: [
...sourceExts,
'scss',
'sass',
'css',
'scss?inline',
'svg?react',
],
},
watchFolders: [
path.resolve(__dirname, '../..'),
],
watchFolders: [path.resolve(__dirname, '../..')],
});
2 changes: 2 additions & 0 deletions packages/clientNative/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"react-native": "0.76.2",
"react-native-dotenv": "^3.4.11",
"react-native-get-random-values": "^1.11.0",
"react-native-nitro-modules": "^0.20.1",
"react-native-quick-crypto": "^0.7.11",
"text-encoding-shim": "^1.0.5"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/engine/src/scene/functions/bvhWorkerPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/ir-engine/ir-engine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.
Software distributed under the License is distributed on an "AS IS" basis,
Expand All @@ -19,7 +19,7 @@ The Original Code is Infinite Reality Engine.
The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Infinite Reality Engine team.
All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
Infinite Reality Engine. All Rights Reserved.
*/

Expand All @@ -35,10 +35,10 @@ const createWorker = () => {
// module workers currently don't work in safari and firefox
return new Worker('/workers/generateBVHAsync.worker.js')
} else {
const path = require('path')
const workerPath = path.resolve(__dirname, './generateBVHAsync.register.js')
console.log({ workerPath })
return new Worker(workerPath, { type: 'module' })
// const path = require('path')
// const workerPath = path.resolve(__dirname, './generateBVHAsync.register.js')
// console.log({ workerPath })
return new Worker('', { type: 'module' })
}
}

Expand Down

0 comments on commit 8498989

Please sign in to comment.