callstack / callstack/haul

iOS 10 Release bundle errors

Open
#733 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.7k
Forks
185
PR merge metrics
No merged PRs in 30d

Description

## Environment
```
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 1.38 GB / 32.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.11.0 - /var/folders/gk/9mp1z229013c3dl7p0wfcf500000gp/T/yarn--1588278802927-0.526041809933842/node
Yarn: 1.19.1 - /var/folders/gk/9mp1z229013c3dl7p0wfcf500000gp/T/yarn--1588278802927-0.526041809933842/yarn
npm: 6.11.3 - ~/.asdf/installs/nodejs/12.11.0/bin/npm
Watchman: 4.1.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 27, 28
Build Tools: 28.0.3
System Images: android-21 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
IDEs:
Xcode: 11.4/11N123k - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
```

```
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@haul-bundler/babel-preset-react-native": "^0.16.0",
"@haul-bundler/cli": "^0.20.0",
"@haul-bundler/preset-0.60": "^0.18.0",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
```
## Description

Related issues #636, #685.

Running release bundle fails on iOS 10 and causes a crash at launch. There are 2 problems:

### Unhandled JS Exception: Unexpected token '...'. Expected a property name.

The spread operator is not being transformed. Fixed by adding

```plugins: ['@babel/plugin-proposal-object-rest-spread'],```

to my `babel.config.js`

### Unhandled JS Exception: Cannot declare a const variable twice: 'e'.

Sometimes it'll be `let` instead of `const`. Fixed by adding `minifyOptions` to `haul.config.js`:

```
import { withPolyfills, makeConfig } from "@haul-bundler/preset-0.60";

export default makeConfig({
bundles: {
index: {
entry: withPolyfills('./index'),
minifyOptions: {
safari10: true,
},
},
},
});
```

However, it also needs a patch as the `minifyOptions` are not being passed thru to `terser-webpack-plugin`:

```
diff --git a/node_modules/@haul-bundler/preset-0.60/build/defaultConfig.js b/node_modules/@haul-bundler/preset-0.60/build/defaultConfig.js
index 76131e9..f913f45 100644
--- a/node_modules/@haul-bundler/preset-0.60/build/defaultConfig.js
+++ b/node_modules/@haul-bundler/preset-0.60/build/defaultConfig.js
@@ -31,6 +31,7 @@ function getDefaultConfig(runtime, env, bundleName, projectConfig) {
assetsDest,
dev,
minify,
+ minifyOptions,
providesModuleNodeModules,
hasteOptions,
maxWorkers,
@@ -163,7 +164,8 @@ function getDefaultConfig(runtime, env, bundleName, projectConfig) {
cache: true,
// Set upper limit on CPU cores, to prevent Out of Memory exception on CIs.
parallel: _isCi.default ? Math.min(_os.default.cpus().length, 8) - 1 : true,
- sourceMap: true
+ sourceMap: true,
+ terserOptions: minifyOptions || {}
})] : [],
namedModules: dev,
concatenateModules: true
```

## Reproducible Demo

Create new project and add haul
```
npx react-native init MyProject --version "0.61.5"
cd MyProject
yarn add --dev @haul-bundler/cli
yarn haul init
```
Open `ios/MyProject.xcworkspace` in Xcode

`Product > Scheme > Edit Scheme` and change Build Configuration to Release

Select a simulator running iOS 10 (e.g. iPad Pro (9.7-inch) -- 10.3.1)

Build and Run (see Description above)

Vanilla React Native supports iOS 10, so I think Haul should also. Thoughts?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.