Skip to main content

What about splitting scripts and dependencies

To organize scripts and dependencies separately, define them in distinct JavaScript files (e.g. scripts.js and dependencies.js).

 project-folder/
├── jko.js
├── scripts.js
└── dependencies.js

Then, import both into jko.js and export them as a single unified default element.

jko.js

import { dependencies } from './dependencies.js'
import { scripts } from './scripts.js'

export default {
dependencies,
scripts
}

Then, install your dependencies:

$ jko install

or, execute your script:

$ jko -c=./unifiedDefinitions.js yourScript arg1 ... argN 

Files may reside at any path within the system.

 project-folder/
├── jko.js
├── some/path/scripts.js
└── another/path/dependencies.js
import { dependencies } from './some/path/dependencies.js'
import { scripts } from './another/path/scripts.js'

export default {
dependencies,
scripts
}
tip

You can also use a file other than jko.js for this purpose, but you'll need to specify it using the --config-file option.

Using json file

If you choose to split definitions in a json file, the $extends and $installs declarative commands are required.

{
"scripts": {
"$extends" : "./another/path/scripts.js",
"$installs" : "./some/path/dependencies.js",
}
}

Was this content valuable?