stealjs / steal

Gets JavaScript
https://stealjs.com
MIT License
1.37k stars 522 forks source link

Missing filename from error when there are duplicate imports #1487

Closed matthewp closed 5 years ago

matthewp commented 5 years ago
import { DefineMap, DefineList, superModel } from 'can';
import loader from '@loader';

import { DefineMap, DefineList, superModel } from 'can';
import loader from '@loader';

const Item = DefineMap.extend({
  seal: false
}, {
  price: 'number'
});

const ItemsList = DefineList.extend({
  '#': Item,
  has: function(item) {
    return this.indexOf(item) !== -1;
  },

  toggle: function(item) {
    var index = this.indexOf(item);

    if (index !== -1) {
      this.splice(index, 1);
    } else {
      this.push(item);
    }
  }
});

const Order = DefineMap.extend({
  seal: false
}, {
  '_id': {
    type: 'any',
    identity: true
  },
  name: 'string',
  address: 'string',
  phone: 'string',
  restaurant: 'string',

  status: {
    default: 'new'
  },
  items: {
    Default: ItemsList
  },
  get total() {
    let total = 0.0;
    this.items.forEach(item =>
        total += parseFloat(item.price));
    return total.toFixed(2);
  },
  markAs(status) {
    this.status = status;
    this.save();
  }
});

Order.connection = superModel({
  url: loader.serviceBaseURL + '/api/orders',
  Map: Order,
  List: Order.List,
  name: 'order'
});

export default Order;

There's no indication of the file that it's in:

image

m-mujica commented 5 years ago

@matthewp would you use the load.address in the warning? or the load.name? ... I kinda like the load name better, but then, I'm not sure if most Steal.js users know what a fully normalized name means... I think it'll still point them to the actual file tho.

Also, should we concern only for the ES6 modules? What about the other module formats? I'm not sure CJS complains about it? this error is clearly coming from Babel.