Compile zimjs locally

I would like to compile and try out zimjs locally:

git clone https://github.com/danzen/zimjs.git
cd zimjs
npm install

From other repositories I knew the command
npm run compile

Missing script: "compile"

How can I compile zimjs locally?

I am not sure... you don't need to clone or compile the ZIM source repository to develop with ZIM locally. ZIM is already pre-packaged and distributed as ES Modules

Depending on how you prefer to work, here are the two standard ways to run ZIM locally. Go to https://zimjs.com/code.html and copy the template. If you want local ZIM and CreateJS files for offline content, you can grab this code as an example https://zimjs.com/offline.zip - there is a video too https://www.youtube.com/watch?v=hJJ9mZu_P38

For bundling with npm, etc.

npm create vite@latest my-ZIM-app -- --template vanilla
cd my-ZIM-app
npm install zimjs

in the main.js file use

import zim from "zimjs";

new Frame(FIT, 1024, 768, light, dark, ready);
function ready() {
   new Circle(100, purple).center().drag();
}

Then

npm run dev

or

npm run build

At the danzen/zimjs GitHub repo: That repository holds the NPM distribution and package definitions rather than an unbundled compiler pipeline, which is why running npm run compile in the cloned repo gave a Missing script error.

There are repositories where the source code is scattered across many files. Hence the thought of compiling. But I've now found the answer: Your source code is located in a single file in node_modules\zimjs\src\ZIM.js. Therefore, no compilation is necessary. And npm run dev/build uses precisely this file.

1 Like