2017-04-10 Simple JavaScript
Simple JavaScript
When I make Simple JavaScript
modules/apps, I just want to make:
package.json
name
description
homepage
version
"devDependencies": {"simple-javascript": ...}
"scripts": {"dev":"simple-javascript dev","build":...,"test":...}
icon.png
icon for the module / application$name.js
- Modern browser code, i.e. assume
async
/await
is available. Userequire
, notimport
, such that it could be loaded in modern browser without preprocessing with reun, if no jsx is used. - Literate source, also used as project documentation.
- Exported symbols/subproperties starting with
TEST
are unit-tests. Throws on error, may returnPromise
. Could be removed by a minifier later on. exports.main
is main entry, if exists
- Modern browser code, i.e. assume
.travis.yml
(if autodeploy of module is needed, –travis setup npm
)
And then, the following files should be autogenerated by yarn build
:
README.md
generated from package.jsonCNAME
generated from package.json – homepage.gitignore
ignoresnode_modules
lib.js
dist.js
bundled src.js to run in webbrowserlib.js
ES2015 version of src.jsindex.html
- has an element with id
app
- load the module, and start executing
exports.main
- load package.json, and shows name/version (and set document title)
- load/shows the icon
- load/shows README.md, converting it to html
- load/shows the source code
- run unit tests, and shows result.
- has an element with id
The repository should be a self-contained bundle, i.e. index.*
is included in the git-repository, and when index.html
is opened in the browser, it just runs, without dependencies on any urls etc.