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. Use require, not import, 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 return Promise. Could be removed by a minifier later on.
    • exports.main is main entry, if exists
  • .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.json
  • CNAME generated from package.json – homepage
  • .gitignore ignores node_modules lib.js
  • dist.js bundled src.js to run in webbrowser
  • lib.js ES2015 version of src.js
  • index.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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *