I need some help with the correct set up for using a node_modules in fuse. I am trying to use apollo-client. I understand not all node modules work. I’m expecting for it to fail with some error message if it doesnt work. Right now, i cant get the build to find the module. I have tried various versions from the .unoproj docs to no avail.
This is the .unoproj
{
"RootNamespace":"",
"Packages": [
"Fuse",
"FuseJS"
],
"Includes": [
"*",
"node_modules/apollo-client/*/.js:Bundle",
"Assets/*.png:Bundle"
]
}
this is where i am trying to call the module. This the inifinite scroll example from Fusetools Playground repo(mostly)
<App>
<iOS.StatusBarConfig Style="Light" />
<JavaScript>
var Observable = require("FuseJS/Observable");
var places = Observable();
var apolloClient = require('/node_modules/apollo-client/index.js');
var ApolloClient = apolloClient.default;
var networkInterface = ApolloClient.createNetworkInterface('http://localhost:8080/graphql');
var gql = require('./node_modules/graphql-tag/index.js')
var client = new ApolloClient({
networkInterface
})
// GraphQL query
var getPlaces = gql`
query allPlaces {
places(first: 10) {
name
city
}
}
`;
var test = client({query: getPlaces});
console.log(test);
test();
// client({query: getPlaces});
// query(getPlaces);
// function loadMore() {
// for (var i = 0; i < 30; i++) {
// friends.add({
// name: "Generic friend " + friends.length,
// avatar: "Assets/avatar" + (Math.floor(Math.random()*4)+1) + ".png"
// })
// }
// if (friends.length > 60) {
// friends.removeRange(0, 30);
// }
// }
// loadMore();
// module.exports = { friends, loadMore };
module.exports = { places };
</JavaScript>
<DockPanel>
<DockPanel Dock="Top" Color="#18f">
<StatusBarBackground Dock="Top" />
<Panel Height="48">
<Text Color="White" FontSize="20" Alignment="Center">Friends</Text>
</Panel>
</DockPanel>
<ScrollView LayoutMode="PreserveVisual">
<StackPanel>
<Each Items="{hero}">
<Panel>
<Deferred>
<DockPanel>
<Image Width="64" Margin="16,4,32,4" File="{avatar}" Dock="Left" />
<Text Value="{hero.name}" Alignment="CenterLeft"/>
</DockPanel>
</Deferred>
</Panel>
</Each>
</StackPanel>
<Scrolled To="End" Within="300">
<Callback Handler="{loadMore}" />
</Scrolled>
</ScrollView>
</DockPanel>
</App>
Various errors from trying different configurations of the above. Thanks for any guidance.
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/index.js
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/index.js');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/index.js
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>
LOG: Error: JavaScript error in MainView.ux line 7: Name: Fuse.Scripting.Error
Error message: require(): module not found: /node_modules/apollo-client/index.js
File name: MainView.ux
Line number: 7
Source line: var apolloClient = require('/node_modules/apollo-client/index.js');
JS stack trace: [Uno code]
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.String id) <0x17abedf8 + 0x000db> in <filename unknown>:0
at Fuse.Scripting.ScriptModule+RequireContext.Require (System.Object[] args) <0x17abec48 + 0x0007b> in <filename unknown>:0
at Fuse.Scripting.V8.Marshaller+CallbackWrapper.Call (Fuse.Scripting.V8.Simple.UniqueValueVector args) <0x17abcfd0 + 0x00059> in <filename unknown>:0
[JavaScript code]
Error: require(): module not found: /node_modules/apollo-client/index.js
at (Error Handler):1:49
at null._tempMethod (MainView.ux:7:22)
in Fuse.Reactive.JavaScript</usr/local/share/uno/Packages/Fuse.Reactive/0.38.6/$.uno:1389>