Build a JavaScript module for WebApp/2. WM2 implicitly uses HTTP/2 and ES Modules.
WM 2 is a module development environment for WebApp/2. It is possible to develop modules based on the use of ES Modules.
In WM 2, write the source code with ES6/ES7 and build bundle.es6.js with npm run bundle command.
And register the source code and bundle.es6.js in npm. Created module is called by an import statement.
The module based on WM 2 is called WM2 module.
Let's make $PATH feel good before installing.
export PATH="./node_modules/.bin:$PATH"Go to the directory of the module to be developed on WM2 and install WM2 package.
npm i -D wm2These are the WM2 Development commands.
npm run lint- run eslintnpm run start- start test servernpm run stop- stop test servernpm run bundle- buildbundle.es6.jsandbundle.es6.mjsnpm run test- testnpm run test:browsernpm run test:nodenpm run test:iosnpm run test:elnpm run watch- Watch changes in "index.js" and "es6/*.js"npm run unwatch
The standard file structure of the WM2 Module is as follows.
- index.js is the code entry point. Write code that cannot fit in index.js in the es6 directory.
- The assets directory is optional.
▾ wm2-example.js/
▾ assets/
▾ es6/
▾ test/
test.js # test code entry point.
browser.html # Browser and iOS Simulator
node.js # Node.js
worker.js # WebWorkers
▾ .conf/
.eslintignore
.eslintrc
.eslintrc.es5.json
.gitignore
.npmignore
.rollup.es5.js
.rollup.es6.js
Dockerfile
index.js # code entry point.
package.json