daml/navigator
Moritz Kiefer 7c031f25f7
Upgrade rules_nodejs to version 1.6.0 (#5539)
* Upgrade rules_nodejs to version 1.6.0

closes #5367

This includes the fixes for the issues in jest that we’ve been seeing.

changelog_begin
changelog_end

* Fix eslint rules

* A bit of progress

* Try to add LinkablePackageInfo (doesn’t seem to work yet)

* Add rootDirs

* revert da_ts_library

* da_ts_library: add LinkablePackageInfo info

* Remove react hook workaround

Since rules_nodejs 1.6.0 this fails with the following error:
```
  ● Test suite failed to run

    Configuration error:

    Could not locate module react mapped as:
    /.../execroot/com_github_digital_asset_daml/bazel-out/k8-opt/bin/language-support/ts/daml-react/test.sh.runfiles/com_github_digital_asset_daml/node_modules/react/umd/react.development.js.

    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^react$/": "/.../execroot/com_github_digital_asset_daml/bazel-out/k8-opt/bin/language-support/ts/daml-react/test.sh.runfiles/com_github_digital_asset_daml/node_modules/react/umd/react.development.js"
      },
      "resolver": null
    }

      49 | // like a promis without being one.
      50 | /* eslint-disable @typescript-eslint/no-floating-promises */
    > 51 | var react_1 = __importStar(require("react"));
         |                            ^
      52 | var react_hooks_1 = require("@testing-library/react-hooks");
      53 | var index_1 = __importStar(require("./index"));
      54 | var events_1 = require("events");

      at createNoMappedModuleFoundError (../../../../../../../../../../../node_modules/jest-resolve/build/index.js:501:17)
      at Object.<anonymous> (index.test.js:51:28)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.88s
Ran all test suites within paths "language-support/ts/daml-react/DamlLedger.d.ts", "language-support/ts/daml-react/DamlLedger.js", "language-support/ts/daml-react/context.d.ts", "language-support/ts/daml-react/context.js", "language-support/ts/daml-react/hooks.d.ts", "language-support/ts/daml-react/hooks.js", "language-support/ts/daml-react/index.d.ts", "language-support/ts/daml-react/index.js", "language-support/ts/daml-react/index.test.d.ts", "language-support/ts/daml-react/index.test.js".
=
```

* rootDirs is not needed for tsc

This is only required for ts_project

* Update yarn Bazel packages

* docs/theme add missing dependencies

* Remove unused attribute module_root

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-04-17 12:03:33 +00:00
..
backend allow secure connection from JSON API to ledger (#5555) 2020-04-16 13:12:30 -04:00
docs replace DAML Authors with DA in copyright headers (#5228) 2020-03-27 01:26:10 +01:00
frontend Upgrade rules_nodejs to version 1.6.0 (#5539) 2020-04-17 12:03:33 +00:00
integration-test Use com.daml as root package (#5343) 2020-04-05 19:49:57 +02:00
.gitignore open-sourcing daml 2019-04-04 09:33:38 +01:00
BUILD.bazel replace DAML Authors with DA in copyright headers (#5228) 2020-03-27 01:26:10 +01:00
Makefile Navigator: Remove unused Makefile targets 2019-04-05 12:10:55 +02:00
README.md Remove git-revision from dependency graph (#3365) 2019-11-07 13:29:31 +00:00

Navigator

The Navigator is a web-app that connects to any Digital Asset ledger and allows the user to inspect contracts, create contracts, and exercise choices.

The Navigator can be used in development mode (see below) or packaged into a "fat" JAR that includes the compiled frontend assets for distribution.

Navigator architecture

To learn more about developing the different parts of the Navigator see:

Building Navigator

To build a "fat" JAR of the Navigator that includes the pre-compiled front-end assets, run:

bazel build //navigator/backend:navigator-binary_deploy.jar

This produces a "fat" JAR bazel-bin/navigator/backend/navigator-binary_deploy.jar which can be run with:

java -jar bazel-bin/navigator/backend/navigator-binary_deploy.jar

Notable things in the Navigator build:

backend/src/test/resources/schema.graphql

Manually written, must be consistent with backend/src/main/scala/com/digitalasset/navigator/graphql/GraphQLSchema.scala. Consistency is checked in a test.

frontend/src/**/api/Queries.ts

Generated from backend/src/test/resources/schema.graphql with an external codegen tool. Currently, these files are checked in and updated with make update-graphql-types.

frontend bundled code

Code from frontend/src/**/*.ts*, compiled using TypeScript, and bundled with Webpack. Output includes:

  • bundle-[hash].js: bundled frontend code, name uses content hasing.
  • browsercheck-[hash].js: tiny module for checking browser compatibility, name uses content hasing.
  • Several image and font files, referenced by the above modules. File names use content hashing.
  • index.html: Single page application main entry, references the above modules.

Note: Browsers are instructed never to cache index.html, and indefinitely cache all other files. This is why content hashing is used.

backend binary

Scala binary, compiled as a fat JAR. Code from backend/src/**/*.scala, bundled frontend code is copied to backend/src/main/resources/frontend.

backend version

The version is included as resource files in the Navigator fat jar. This is to reduce rebuild times when the version changes.

frontend development build

For developing frontend code, webpack-dev-server is used. This serves the current frontend code on a separate port, and does:

  • Watch *.ts files for changes
  • Perform incremental builds
  • Send a push notification to the browser, automatically reloading the page when the build is finished.
  • Forward network requests to a different port, where a Navigator backend is expected to run.

This is orders of magnitude faster than what the current Bazel build offers, so it is desirable to keep the webpack-dev-server setup working.

Note, the browser is instructed to cache assets based on the SDK version. During development this is too aggressive and you will need to manually refresh to see updates to the front-end.