Packages in lively.next - LivelyKernel/lively.next GitHub Wiki
Packages
Background
- JS doesn't know about packages but node invented it some time
- a package is installable and is something you can actually ship
- lively adopted having packages since it is a nicer way of handeling code
- we group modules into packages so you can load the package and get all the modules out
package.json
is a dictionary that has a lot of information about the modules and the structure of the modules
- it defines how the packages looks like
- whereas
index.js
knows how to export which modules
Creating a package it self
- open a browser
- click the
+
sign at the top of the browser
- choose
Create Package
- enter a name and click ok
Making your package saveable
- write in the
index.js
what should actually be exported
export {name} from ./name-of-module-file.js
- also you can copy some
package.json
code for example:
{
"name": "packagename",
"version": "somenumber",
"lively": {
"isObjectPackage": true
},
"dependencies": {},
"devDependencies": {},
"main": "index.js"
}
- if
isObjectPackage
is set to true
the package gets also serialized while false says that it can be found on the server
- lively first looks whether packages are core packages or whether they are thirdparty packages
- therefore it looks the packages up in
lively.installer/packages-config.json
- just insert your package name there
- it is important to write the package name there while the repourl is not used at the moment
- now you only need write
import {name} from '[packagename]'
in all of your code
- AND the world can be saved and no package information is missing!! :+1: