Sto facendo esperimenti con ES6 e Im usando gulp per build e babel per traspare in ES5. L’output non viene eseguito nel nodo, solo collegato a un file .htm con un tag. Sto pensando che devo aggiungere
o qualcosa di simile.
Sto cercando di importare / esportare.
////////////////scripts.js import {Circle} from 'shapes'; c = new Circle(4); console.log(c.area()); /////////////////shapes.js export class Circle { circle(radius) { this.radius = radius; } area() { return this.radius * this.radius * Math.PI; } }
L’errore è
Uncaught ReferenceError: require is not defined
Si riferisce a questo (dopo .pipe (babel ()) in gulp)
var _shapes = require('shapes');