Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

Parse JS SDK doesn't work after rollup #88

@jgw96

Description

@jgw96

From @alamusi on September 30, 2016 4:33

Short description of the problem:

Parse JS SDK no longer works with RC0

What behavior are you expecting?

Like beta11 and many other beta version, it should work regardless in browsify, webpack, or this new rollup...

Steps to reproduce:

  1. ionic start test blank --v2
  2. npm install --save parse
  3. npm install --save events
  4. add preferBuiltins: false into rollup.config -> plugins -> nodeResolve (to satisfy events dependency)
  5. ionic serve
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';

import { HomePage } from '../pages/home/home';

import Parse from 'parse';

@Component({
  template: `<ion-nav [root]="rootPage"></ion-nav>`
})
export class MyApp {
  rootPage = HomePage;

  constructor(platform: Platform) {
    console.log('Parse initialize started...',Parse);
    Parse.initialize('MY_APP_DEV');
    Parse.serverURL = 'http://localhost:5000/v1';
    console.log('Parse initialize completed...',Parse);
    console.log('Parse config local success ',Parse.Config.current());
    Parse.Config.get().then(config => {
      console.log('Parse config read success ',config);
    },err=>{
      console.error('Parse config read failed ',err);
    });
    let query = new Parse.Query(Parse.User);
    query.find().then(result=>{
      result.forEach(user=>{
        console.log('user ',user);
      });
    });

    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
    });
  }
}

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
chrome console indicates Parse initialization is successful. a config call to backend is successful. then it goes wrong when trying to create a new query object.
After stack tracing all the way back to the exception, the issue was pointing to line 35~37 of /Parse/lib/browser/ParseQuery.js. var _ParseObject got undefined, which really shouldn't...

var _ParseObject = require('./ParseObject');

var _ParseObject2 = _interopRequireDefault(_ParseObject);

This also happened for other class/object, such as Parse.User.logIn() call. Some other var ??? = require('./Parse???'); still got "undefined".

Parse initialize started... Object {Analytics: Object, Cloud: Object, CoreManager: Object, FacebookUtils: Object, Op: Object…}
app.component.js:23 Parse initialize completed... Object {Analytics: Object, Cloud: Object, CoreManager: Object, FacebookUtils: Object, Op: Object…}
app.component.js:29 Parse config local success ParseConfig {attributes: Object, _escapedAttributes: Object}
error_handler.js:45 EXCEPTION: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instanceof' is not an objectErrorHandler.handleError @ error_handler.js:45(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:47 ORIGINAL EXCEPTION: Right-hand side of 'instanceof' is not an objectErrorHandler.handleError @ error_handler.js:47(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:50 ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:51 TypeError: Right-hand side of 'instanceof' is not an object
at new ParseQuery (ParseQuery.js:134)
at new MyApp (app.component.js:35)
at DebugAppView.View_MyApp_Host0.createInternal (MyApp_Host.ngfactory.js:16)
at DebugAppView.AppView.create (view.js:125)
at DebugAppView.create (view.js:337)
at ComponentFactory.create (component_factory.js:153)
at ViewContainerRef
.createComponent (view_container_ref.js:114)
at IonicApp.ngOnInit (app-root.js:25)
at DebugAppView._View_IonicApp_Host0.detectChangesInternal (IonicApp_Host.ngfactory.js:29)
at DebugAppView.AppView.detectChanges (view.js:272)ErrorHandler.handleError @ error_handler.js:51(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:54 ERROR CONTEXT:ErrorHandler.handleError @ error_handler.js:54(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:55 DebugContext {_view: _View_MyApp_Host0, _nodeIndex: 0, _tplRow: 0, _tplCol: 0}ErrorHandler.handleError @ error_handler.js:55(anonymous function) @ application_ref.js:210t.invoke @ polyfills.js:3onInvoke @ ng_zone_impl.js:43t.invoke @ polyfills.js:3e.run @ polyfills.js:3(anonymous function) @ polyfills.js:3t.invokeTask @ polyfills.js:3onInvokeTask @ ng_zone_impl.js:34t.invokeTask @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
app.component.js:20 Parse initialize started... Object {Analytics: Object, Cloud: Object, CoreManager: Object, FacebookUtils: Object, Op: Object…}
app.component.js:23 Parse initialize completed... Object {Analytics: Object, Cloud: Object, CoreManager: Object, FacebookUtils: Object, Op: Object…}
app.component.js:29 Parse config local success ParseConfig {attributes: Object, _escapedAttributes: Object}
error_handler.js:45 EXCEPTION: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instanceof' is not an objectErrorHandler.handleError @ error_handler.js:45next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:47 ORIGINAL EXCEPTION: Right-hand side of 'instanceof' is not an objectErrorHandler.handleError @ error_handler.js:47next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:50 ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:51 TypeError: Right-hand side of 'instanceof' is not an object
at new ParseQuery (ParseQuery.js:134)
at new MyApp (app.component.js:35)
at DebugAppView.View_MyApp_Host0.createInternal (MyApp_Host.ngfactory.js:16)
at DebugAppView.AppView.create (view.js:125)
at DebugAppView.create (view.js:337)
at ComponentFactory.create (component_factory.js:153)
at ViewContainerRef
.createComponent (view_container_ref.js:114)
at IonicApp.ngOnInit (app-root.js:25)
at DebugAppView._View_IonicApp_Host0.detectChangesInternal (IonicApp_Host.ngfactory.js:29)
at DebugAppView.AppView.detectChanges (view.js:272)ErrorHandler.handleError @ error_handler.js:51next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:54 ERROR CONTEXT:ErrorHandler.handleError @ error_handler.js:54next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
error_handler.js:55 DebugContext {_view: _View_MyApp_Host0, _nodeIndex: 0, _tplRow: 0, _tplCol: 0}ErrorHandler.handleError @ error_handler.js:55next @ application_ref.js:272EventEmitter.subscribe.schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64t.handleError @ polyfills.js:3e.runTask @ polyfills.js:3i @ polyfills.js:3
polyfills.js:3 ViewWrappedError {_nativeError: Error: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instan…, originalError: TypeError: Right-hand side of 'instanceof' is not an object
at new ParseQuery (http://localhost:…, context: DebugContext}o @ polyfills.js:3i @ polyfills.js:3
polyfills.js:3 Unhandled Promise rejection: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instanceof' is not an object ; Zone: ; Task: Promise.then ; Value: ViewWrappedError {_nativeError: Error: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instan…, originalError: TypeError: Right-hand side of 'instanceof' is not an object
at new ParseQuery (http://localhost:…, context: DebugContext} TypeError: Right-hand side of 'instanceof' is not an object
at new ParseQuery (http://localhost:8100/build/main.js:80190:28)
at new MyApp (http://localhost:8100/build/main.js:89882:21)
at DebugAppView.View_MyApp_Host0.createInternal (MyApp_Host.ngfactory.js:16:21)
at DebugAppView.AppView.create (http://localhost:8100/build/main.js:10257:21)
at DebugAppView.create (http://localhost:8100/build/main.js:10469:44)
at ComponentFactory.create (http://localhost:8100/build/main.js:6050:36)
at ViewContainerRef
.createComponent (http://localhost:8100/build/main.js:5361:45)
at IonicApp.ngOnInit (http://localhost:8100/build/main.js:48112:43)
at DebugAppView._View_IonicApp_Host0.detectChangesInternal (IonicApp_Host.ngfactory.js:29:77)
at DebugAppView.AppView.detectChanges (http://localhost:8100/build/main.js:10404:14)o @ polyfills.js:3r @ polyfills.js:3i @ polyfills.js:3
polyfills.js:3 Error: Uncaught (in promise): Error: Error in ./MyApp class MyApp_Host - inline template:0:0 caused by: Right-hand side of 'instanceof' is not an object(…)o @ polyfills.js:3r @ polyfills.js:3i @ polyfills.js:3
app.component.js:31 Parse config read success ParseConfig {attributes: Object, _escapedAttributes: Object}
app.component.js:31 Parse config read success ParseConfig {attributes: Object, _escapedAttributes: Object}

Which Ionic Version? 1.x or 2.x
2.0RC0

Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.3.1

Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 7.3.1 Build version 7D1014

Copied from original issue: ionic-team/ionic-framework#8331

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions