# Building
The build process uses Webpack and Babel, as well as npm tasks
listed in package.json. During this process, the source located in
the hyperformula/src/* directory is transformed into the output files.
The library is developed in TypeScript and the exact configuration options can
be found in hyperformula/tsconfig.json.
This repository is an npm workspace: the engine is the hyperformula package, and
the documentation portal in docs/ installs separately. From the repository root:
npm ci # the engine and its toolchain
npm run docs:install # the documentation portal, only if you are building the docs
The commands below are the engine's own scripts. Run them inside hyperformula/,
or from the repository root with --workspace=hyperformula. The root also
forwards the common ones under the same name, so these work there directly:
build, bundle-all, compile, clean, the test:* scripts except
test:logMemory and test:browser.debug, verify-bundles,
verify:publish-package, verify:typings and typedoc:build-api. The
individual bundle:* and verify:* steps and the benchmarks are not forwarded.
lint and lint:fix run in every package, each with its own configuration.
# Output formats
The build produces the following output formats, all declared as
entry points in package.json:
commonjs/- CommonJS modules (main entry, used by Node.js and bundlers)es/- ES modules (.mjsfiles, used by tree-shaking bundlers)dist/- UMD bundles for direct use in the browsertypings/- TypeScript declaration files (.d.ts)
For UMD versions which reside in CDN:
./dist/hyperformula.js- a full version which does not have dependencies, they need to be added manually./dist/hyperformula.min.js- a minified version which does not have dependencies, they need to be added manually./dist/hyperformula.full.js- a full version with dependencies./dist/hyperformula.full.min.js- a minified version with dependencies
# Build the project
To build the project you can use the following commands:
npm run bundle-all- generates development and production builds, verifies the version. Forwarded from the repository root.
The individual steps are scripts of the hyperformula package, so run them with
--workspace=hyperformula from the root, or from inside hyperformula/:
npm run bundle:es- transpiles files into theimport/exportformat , builds ES6 versionnpm run bundle:cjs- builds CommonJS versionnpm run bundle:development- generates development buildnpm run bundle:production- generates production buildnpm run bundle:languages- builds the languagesnpm run bundle:typings- generates TypeScript typing, only emits ‘.d.ts’ declaration files
We use the Node 22 LTS in the build-chain and recommend this version for building. Note that for using (not building) HyperFormula, a wider range of Node versions is supported.
# Verify the build
verify-bundles, verify:publish-package and verify:typings are forwarded
from the repository root. The individual bundle checks are package scripts, so
run them with --workspace=hyperformula or from inside hyperformula/:
verify-bundles- runs all verify commandsverify:umd- verifies UMD versionverify:umd:min- verifies UMD minified version without dependenciesverify:umd:full- verifies UMD version with dependenciesverify:umd:full.min- verifies minified UMD version with dependenciesverify:cjs- verifies CommonJS version with dependenciesverify:publish-package- checks if npm built the package correctlyverify:typings- verifies TypeScript typings
# Build the documentation
Most likely, you will want to document the code. You can use the following commands to generate the documentation:
npm run docs:build- builds the docsnpm run docs:dev- serves the development version of the docs locally
# Run the tests
TIP
HyperFormula main test suite is maintained outside of this repository. You can find more information here (opens new window).
The tests are done with Jest and Karma. The same test suite should pass in both of them because the library might be used server-side or in a browser, so you have to be sure that both environments are fine.
npm run test- runs the linter and all testsnpm run test:jest- runs unit tests- To run a test suite that matches a word, add a Jest
-tflag. For example:npm run test:jest -- -t 'SUMIF'runs only the tests that match the wordSUMIFwithindescribe()orit(). - To run a specific test suite, pass the file name. For example:
npm run test:jest 'function-sumif.spec.ts'runs only the unit tests from the filefunction-sumif.spec.ts.
- To run a test suite that matches a word, add a Jest
npm run test:browser- runs tests in karma once and closes all open browsers- To run a specific
specfile or a test suite you can add a Karma--specflag. For example:npm run test:browser.debug --workspace=hyperformula -- --spec=matrix.spec.tsrunsmatrix.spec.tsbrowser tests only
- To run a specific
npm run test:browser.debug --workspace=hyperformula- runs test in karma only in Chrome until you exit the process. It watches changes insrcandtestdirectories and rebuilds them automatically. This one is not forwarded from the root.
# Run the linter
You can use the following commands to lint the code, so it meets the required standards. ESLint is used as the tool of choice in this case.
npm run lint- lints the codenpm run lint:fix- automatically fixes lint problems