google / lovefield

Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.
https://google.github.io/lovefield/
Apache License 2.0
6.81k stars 366 forks source link

Trying to use in Chrome App. Get error: "Uncaught TypeError: Cannot set property 'Error' of undefined" #32

Closed le0pard closed 9 years ago

le0pard commented 9 years ago

Trying to use in Chrome App. Get error: "Uncaught TypeError: Cannot set property 'Error' of undefined".

Screenshot: http://take.ms/NKjho

Tools:

grunt v0.4.5 browserify v10.1.3 lovefield v2.0.50

Example of code:

'use strict';

import lf from 'lovefield';
import logger from '../../utils/logger.js.es6';

class IndexedStorageDB {
  constructor() {
    this.schemaBuilder = lf.schema.create('cloud-database', 1);
    this.schemaBuilder.createTable('accounts').
      addColumn('id', lf.Type.INTEGER).
      addColumn('type', lf.Type.STRING).
      addColumn('title', lf.Type.STRING).
      addColumn('provider_key', lf.Type.STRING).
      addColumn('provider_secret', lf.Type.STRING).
      addColumn('is_default', lf.Type.BOOLEAN).
      addPrimaryKey(['id']).
      addIndex('idxType', ['type'], false, lf.Order.ASC);
  }

  loadAccounts() {
    logger.debug('load accounts');
  }
}

export default IndexedStorageDB;
freshp86 commented 9 years ago

I tried to reproduce this error (in a Chrome App) without success.

1) Does the error still happen if you use lovefield.min.js? 2) At line 4043 in your screenshot, there is a goog.provide('goog.debug.Error') which should be creating the goog.debug namespace, such that this error is not thrown. Is there something in your overall setup that would prevent that call from working correctly (Maybe you have a global COMPILED = true variable somewhere else in your code?)

le0pard commented 9 years ago

Hello @freshp86 .

With "lovefield.min.js" I don't have such error, but code little different:

'use strict';

import lovefield from '../../../../../node_modules/lovefield/dist/lovefield.min.js';
import logger from '../../utils/logger.js.es6';

class IndexedStorageDB {
  constructor() {
    this.schemaBuilder = lovefield.lf.schema.create('cloud-database', 1);
    this.schemaBuilder.createTable('accounts').
      addColumn('id', lovefield.lf.Type.INTEGER).
      addColumn('type', lovefield.lf.Type.STRING).
      addColumn('title', lovefield.lf.Type.STRING).
      addColumn('provider_key', lovefield.lf.Type.STRING).
      addColumn('provider_secret', lovefield.lf.Type.STRING).
      addColumn('is_default', lovefield.lf.Type.BOOLEAN).
      addPrimaryKey(['id']).
      addIndex('idxType', ['type'], false, lovefield.lf.Order.ASC);
  }

  loadAccounts() {
    logger.debug('load accounts');
  }
}

export default IndexedStorageDB;

Thanks!