New Build System: Rollup

Hello community,

We are moving our manual build system based on Node.js to a module bundler called Rollup.

This will enable us to write JS in the new ES6 module format.

Frappe’s build system was based on the file build.json which contains the input and output mapping of files. The new system based on rollup will also support build.json but it will be deprecated soon.

Here’s the relevant PR: New Build System: Rollup by netchampfaris · Pull Request #5010 · frappe/frappe · GitHub

This also required some changes in bench, which explains the recent issues popping up in bench update. :sweat_smile:

Please help me test the new system by updating your bench and checking out my rollup branch, so that we can release it bug free.

12 Likes

Will this will change the way to include custom js? Actually they are built using build.json

Yes, you can include other JS files using the syntax

import CustomFunction from './custom';

Including files in build.json is not needed.

I hope you meant contributable JS :wink:

yup for sure :grimacing: …doing my best :wink:

Please, try to update documentation also provide examples. :stuck_out_tongue: :slight_smile:
Good luck.

The PR has been merged!

@netchampfaris first thanks for your efforts and shall I change the custom scripts in my instance? I have many custom scripts running with my doctypes. Please advise…

Custom Scripts shouldn’t be affected

1 Like

@netchampfaris I trying to use multi-bench-setup but I am facing some problem

$ sudo bench get-app https://github.com/frappe/erpnext.git
INFO:bench.app:getting app erpnext
INFO:bench.utils:git clone https://github.com/frappe/erpnext.git  --depth 1 --origin upstream
Cloning into 'erpnext'...
remote: Counting objects: 6645, done.
remote: Compressing objects: 100% (5868/5868), done.
remote: Total 6645 (delta 1303), reused 3374 (delta 611), pack-reused 0
Receiving objects: 100% (6645/6645), 182.10 MiB | 2.37 MiB/s, done.
Resolving deltas: 100% (1303/1303), done.
Checking connectivity... done.
('installing', u'erpnext')
INFO:bench.app:installing erpnext
INFO:bench.utils:./env/bin/pip install -q  -e ./apps/erpnext --no-cache-dir

> frappe@ production /home/mohd/new-bench/apps/frappe
> FRAPPE_ENV=production node rollup/build.js

module.js:557
    throw err;
    ^

Error: Cannot find module 'rollup'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/mohd/new-bench/apps/frappe/rollup/build.js:4:16)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frappe@ production: `FRAPPE_ENV=production node rollup/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frappe@ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

You need to run bench setup requirements first

1 Like

From which bench version are we talking? The latest release is 4.1 but with this, I get:

Usage: bench setup [OPTIONS] COMMAND [ARGS]...

Error: No such command "requirements".

Make sure you run the command from the frappe-bench folder. Also, make sure to pull the latest changes of frappe and erpnext.

I have bench 4.1, frappe 10.1.45. I run:

$ bench init /home/frappe/frappe-bench

and then this fails:

$ cd /home/frappe/frappe-bench && bench setup requirements
Usage: bench setup [OPTIONS] COMMAND [ARGS]...

Error: No such command "requirements".

Any suggestions?

@dmorlock

bench setup --requirements

$ bench setup --requirements
Error: no such option: --requirements

You’re sure that I can use the latest bench release 4.1? This release is from 2016: Releases · frappe/bench · GitHub

bench update --requirements

This seems to work. Thank you @shahid!
Is there any reason why there is no recent release for bench?