Skip to content

Commit 5f186a6

Browse files
authored
feat: use webpack to resolve initializeCoreLocation file (#669)
1 parent 1227e01 commit 5f186a6

11 files changed

Lines changed: 31 additions & 42 deletions

File tree

docs/Configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ Usually, the return value of `makeConfig` should be returned as default export w
4040

4141
Decorate the entry file(s) with React Native polyfills. You can specify custom `root` directory and path to `InitializeCore.js` file.
4242

43-
| Name | Type | Description |
44-
| --------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45-
| `entry` | `string` / `string[]` | Entry file(s) path(s) |
46-
| `options` | `{ root?: string; initializeCoreLocation?: string }` | Specify custom path to `InitializeCore.js` file. `root` and `initializeCoreLocation` are joined together using `path.join`. Defaults: `root` - `process.cwd()`, `initializeCoreLocation` - `node_modules/react-native/Libraries/Core/InitializeCore.js`. |
47-
| _returns_ | `string[]` | Entry file(s) with polyfill paths |
43+
| Name | Type | Description |
44+
| --------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
45+
| `entry` | `string` / `string[]` | Entry file(s) path(s) |
46+
| `options` | `{ initializeCoreLocation?: string }` | Specify custom path to `InitializeCore.js` file. Defaults: `initializeCoreLocation` - `react-native/Libraries/Core/InitializeCore.js`. |
47+
| _returns_ | `string[]` | Entry file(s) with polyfill paths |
4848

4949
### Project configuration reference
5050

docs/Recipes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default makeConfig({
165165
bundles: {
166166
index: {
167167
entry: withPolyfills('./index.js', {
168-
initializeCoreLocation: 'node_modules/react-native-windows/Libraries/Core/InitializeCore.js'
168+
initializeCoreLocation: 'react-native-windows/Libraries/Core/InitializeCore.js'
169169
}),
170170
providesModuleNodeModules: ['react-native', 'react-native-windows'],
171171
hasteOptions: { platforms: ['native', 'windows'] },

fixtures/react_native_windows_e2e_app/__tests__/appium.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ test('RNWTestApp renders correctly', async () => {
5858
expect(await getByTestId('app1')).toBeDefined();
5959
expect(await (await getByTestId('app1LoadTime')).text()).toMatch(/Load time: ([1-9]|[0-9]{2}) ms/);
6060

61-
expect(await getByTestId('exchangeRates')).toBeDefined();
61+
expect(await getByTestId('films')).toBeDefined();
6262
});

fixtures/react_native_windows_e2e_app/haul.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default makeConfig({
77
bundles: {
88
index: {
99
entry: withPolyfills('./index.windows.js', {
10-
initializeCoreLocation: 'node_modules/react-native-windows/Libraries/Core/InitializeCore.js'
10+
initializeCoreLocation: 'react-native-windows/Libraries/Core/InitializeCore.js'
1111
}),
1212
providesModuleNodeModules: ['react-native', 'react-native-windows'],
1313
hasteOptions: { platforms: ['native', 'windows'] },

fixtures/react_native_windows_e2e_app/src/ExchangeRates.js renamed to fixtures/react_native_windows_e2e_app/src/Films.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@ import { Text, FlatList } from 'react-native';
33
import { Query } from 'react-apollo';
44
import gql from 'graphql-tag';
55

6-
export default function ExchangeRates() {
6+
export default function Films() {
77
return (
88
<Query
99
query={gql`
1010
{
11-
rates(currency: "USD") {
12-
currency
13-
rate
11+
allFilms {
12+
title
1413
}
1514
}
1615
`}
1716
>
1817
{({ loading, error, data }) => {
1918
if (loading) return <Text>Loading...</Text>;
20-
if (error) return <Text>Error :(</Text>;
19+
if (error) return <Text>Error</Text>;
2120

2221
return (
2322
<FlatList
24-
testID="exchangeRates"
25-
data={data.rates}
26-
keyExtractor={(item) => item.currency}
23+
testID="films"
24+
data={data.allFilms}
25+
keyExtractor={(item) => item.title}
2726
renderItem={({ item }) => (
28-
<Text>{item.currency}: {item.rate}</Text>
27+
<Text>{item.title}</Text>
2928
)}
3029
/>
3130
);

fixtures/react_native_windows_e2e_app/src/app1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component, Suspense } from 'react';
22
import { StyleSheet, Text, View } from 'react-native';
33

4-
const ExchangeRates = React.lazy(() => import('./ExchangeRates'));
4+
const Films = React.lazy(() => import('./Films'));
55

66
export default class App extends Component {
77
render() {
@@ -10,7 +10,7 @@ export default class App extends Component {
1010
<View style={styles.container}>
1111
<Text style={styles.welcome} testID="app1">App 1</Text>
1212
<Text style={styles.body} testID="app1LoadTime">Load time: {loadTime} ms</Text>
13-
<Suspense fallback={<Text>Loading</Text>}><ExchangeRates /></Suspense>
13+
<Suspense fallback={<Text>Loading</Text>}><Films /></Suspense>
1414
</View>
1515
);
1616
}

fixtures/react_native_windows_e2e_app/src/host.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ BundleRegistry.enableLogging();
5555

5656
const cache = new InMemoryCache();
5757
const apolloClient = new ApolloClient({
58-
link: createHttpLink({ uri: "https://48p1r2roz4.sse.codesandbox.io" }),
58+
link: createHttpLink({ uri: "https://swapi.graph.cool/" }),
5959
cache
6060
});
6161

fixtures/react_native_with_haul_0_59x/haul.config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@ export default makeConfig({
44
bundles: {
55
index: {
66
entry: withPolyfills('./index.js'),
7-
transform({ config }) {
8-
return {
9-
...config,
10-
resolve: {
11-
...config.resolve,
12-
alias: {
13-
...config.resolve.alias,
14-
// Force React Native to be resolved in exampleApp_0_59x's node_modules
15-
'react-native': require.resolve('react-native'),
16-
},
17-
},
18-
};
19-
},
207
},
218
},
229
});

packages/haul-cli/src/commands/bundle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ export default function ramBundleCommand(runtime: Runtime) {
106106
compiler.run((err, info) => {
107107
if (err || info.hasErrors()) {
108108
messages.buildFailed(runtime);
109-
reject(err ? err : info.toJson({ errorDetails: true }).errors);
109+
reject(
110+
err
111+
? err
112+
: info.toJson({ errorDetails: true }).errors.join('\n')
113+
);
110114
} else {
111115
resolve(info);
112116
}

packages/haul-cli/src/commands/ramBundle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ export default function ramBundleCommand(runtime: Runtime) {
116116
compiler.run((err, info) => {
117117
if (err || info.hasErrors()) {
118118
messages.buildFailed(runtime);
119-
reject(err ? err : info.toJson({ errorDetails: true }).errors);
119+
reject(
120+
err
121+
? err
122+
: info.toJson({ errorDetails: true }).errors.join('\n')
123+
);
120124
} else {
121125
resolve(info);
122126
}

0 commit comments

Comments
 (0)