Created
August 9, 2017 15:39
-
-
Save johnsi15/95fa5f2f6a0bcd47d59402c755e4e9f7 to your computer and use it in GitHub Desktop.
A esto lo llamo un browserify nativo. Ahora JavaScript se empieza a parecer a lenguajes como Python o Ruby. Llamamos a las funciones desde los propios Scripts, sin tener que importarlos en el HTML, si usamos JavaScript en el navegador.
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
//File: lib/person.js | |
module "person" { | |
export function hello(nombre) { | |
return nombre; | |
} | |
} | |
//También se puede exportar así, según una aclaración de Sergio Daniel Xalambrí | |
// export function hello(nombre) {...}; | |
// o también, si solo es una función la que tiene el módulo: export default function(nombre) {...}; | |
//File: app.js | |
import { hello } from "person"; | |
var app = { | |
foo: function() { | |
hello("Carlos"); | |
} | |
} | |
export app; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tener en cuenta que hoy en día no funcionan de forma normal por los navegadores usar Babel para convertir en E5.