Skip to content

Commit

Permalink
[sdk31] Add workaround for projects with babel.config.js + get NCL ru…
Browse files Browse the repository at this point in the history
…nning

Babel:
Metro ignores .babelrc files but it doesn't ignore babel.config.js files when transforming the RN CLI. I submitted a patch upstream but it will go out with a different semver major if it gets merged. This is a local workaround to address the issue.

Metro:
The new version of Metro doesn't support dots in the filenames of the entry files, so we now generate the entry points at `__generated__/AppEntry.js` within each project instead of at `.expo/AppEntry.js`.

NCL:
- Made HTMLImageElement for PIXI demo no longer extend from RN's Image since that broke things and didn't make sense anyway.
- Also updated `victory-native` to "fix" a dependency cycle that no longer works with Metro.

Test plan: Run `expo start` in Home and have it succeed.
  • Loading branch information
ide committed Oct 8, 2018
1 parent e73920b commit deecf8e
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Expo
.expo
__generated__

# macOS
.DS_Store
Expand Down
8 changes: 0 additions & 8 deletions apps/jest-expo-mock-generator/.babelrc

This file was deleted.

7 changes: 7 additions & 0 deletions apps/jest-expo-mock-generator/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['@babel/plugin-transform-runtime'],
};
};
2 changes: 1 addition & 1 deletion apps/jest-expo-mock-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"author": "Expo",
"private": true,
"main": ".expo/AppEntry.js",
"main": "__generated__/AppEntry.js",
"scripts": {
"postinstall": "expo-yarn-workspaces postinstall"
},
Expand Down
3 changes: 0 additions & 3 deletions apps/native-component-list/.babelrc

This file was deleted.

7 changes: 7 additions & 0 deletions apps/native-component-list/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['@babel/plugin-transform-runtime'],
};
};
6 changes: 3 additions & 3 deletions apps/native-component-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A list of the various APIs you can use with the Expo client",
"author": "Expo",
"private": true,
"main": ".expo/AppEntry.js",
"main": "__generated__/AppEntry.js",
"scripts": {
"postinstall": "expo-yarn-workspaces postinstall"
},
Expand All @@ -27,14 +27,14 @@
"react-native-paper": "^2.0.0-alpha.4",
"react-native-platform-touchable": "^1.1.1",
"react-native-svg": "6.2.2",
"react-navigation": "2.6.2",
"react-navigation": "^2.17.0",
"react-navigation-header-buttons": "^1.2.1",
"react-navigation-material-bottom-tabs": "^0.3.0",
"regl": "^1.3.0",
"three": "^0.88.0",
"url": "^0.11.0",
"uuid": "^3.1.0",
"victory-native": "~0.15.0"
"victory-native": "^30.4.0"
},
"devDependencies": {
"expo-yarn-workspaces": "^1.0.0"
Expand Down
3 changes: 1 addition & 2 deletions apps/native-component-list/screens/GL/BeforePIXI.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ window.document.body = new DOMElement('body');
window.location = 'data:'; // <- Not sure about this... or anything for that matter ¯\_(ツ)_/¯
global.userAgent = global.navigator.userAgent = 'iPhone'; // <- This could be made better, but I'm not sure if it'll matter for PIXI

class HTMLImageElement extends Image {
class HTMLImageElement {
constructor(props) {
super();
this.align = 'center';
this.alt = null;
this.border = null;
Expand Down
3 changes: 0 additions & 3 deletions apps/test-suite/.babelrc

This file was deleted.

7 changes: 7 additions & 0 deletions apps/test-suite/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['@babel/plugin-transform-runtime'],
};
};
1 change: 1 addition & 0 deletions home/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['@babel/plugin-transform-runtime'],
};
};
5 changes: 3 additions & 2 deletions home/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@expo/home",
"version": "0.0.0",
"main": ".expo/AppEntry.js",
"main": "__generated__/AppEntry.js",
"private": true,
"description": "The Expo client app",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"react-native": "^0.57.1",
"react-native-deprecated-custom-components": "^0.1.0",
"react-native-infinite-scroll-view": "^0.4.5",
"react-navigation": "^2.16.0",
"react-navigation": "^2.17.0",
"react-navigation-material-bottom-tabs": "^0.3.0",
"react-redux": "^5.0.1",
"react-timer-mixin": "^0.13.3",
Expand All @@ -50,6 +50,7 @@
"url": "^0.11.0"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.1.0",
"expo-yarn-workspaces": "^1.0.0",
"hashids": "^1.1.1",
"jest-expo": "^30.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-yarn-workspaces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Each Expo app in the repository that is intended to work with Yarn workspaces (a

### Define the entry module in the `"main"` field of package.json

The postinstall script determines the location of the generated entry module by looking at the `"main"` field in package.json. In a conventional Expo app, the value of the `"main"` field is `node_modules/expo/AppEntry.js`. In a workspace in the Expo repo, **specify `".expo/AppEntry.js"` as the value of the `"main"` field in package.json.**
The postinstall script determines the location of the generated entry module by looking at the `"main"` field in package.json. In a conventional Expo app, the value of the `"main"` field is `node_modules/expo/AppEntry.js`. In a workspace in the Expo repo, **specify `"__generated__/AppEntry.js"` as the value of the `"main"` field in package.json.**

You can specify other paths too. The `.expo` directory is convenient since it already contains auto-generated files and is .gitignore'd.

Expand Down
Loading

0 comments on commit deecf8e

Please sign in to comment.