Last active
September 13, 2015 13:05
-
-
Save YarivGilad/3fe267676b4e3d382d38 to your computer and use it in GitHub Desktop.
Testing Node.js v4.0.0 modular ES6 syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------ | |
// app.js | |
//------------ | |
"use strict"; | |
//import fs from 'fs'; // <-- Throws: SyntaxError: Unexpected reserved word ^^^^import | |
//import Project from './lib/Project'; // <-- Throws: SyntaxError: Unexpected reserved word ^^^^import | |
var Project = require('./lib/Project') //<-- works fine | |
var project = new Project("Journal"); | |
console.log(project.start()); // --> logs "Project Journal starting" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------- | |
// ./lib/Project.js | |
//------------------------ | |
"use strict"; | |
class Project { | |
constructor(name) { | |
this.name = name; | |
} | |
start() { | |
return "Project " + this.name + " starting"; | |
} | |
} | |
//export default Project; // <-- Does not work, throws: SyntaxError: Unexpected reserved word ^^^^export | |
module.exports = Project; // <-- Works fine | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment