The build script for unlock.min.js needs to do 1 very important thing:
Build the data iframe, by both tree shaking and code splitting so that it is as small as possible, and the cache handler/post office portion is split from the huge blockchain portion. This is accomplished partially by the usage of import().then() inside the data iframe source, and partially by build steps.
It will be built using webpack (not rollup initially).
In addition, the script responds to UNLOCK_ENV. The code could choose to hard-code values for LOCKSMITH_URI and READ_ONLY_PROVIDER but currently is designed to use env variables:
This introduces significantly more complexity, so if it is acceptable, hard-coding will be a better solution.
If we decide to go with the current approach, the script will need to have access to the different values needed for staging and production in CircleCI and ensure we deploy the correct script version to production.
An alternative is to build 3 versions of the script, dev.unlock.min.js, staging.unlock.min.js, and unlock.min.js.
Additionally, the script should be versioned, so initially we will output unlock.1.0.min.js
The build script for unlock.min.js needs to do 1 very important thing:
Build the data iframe, by both tree shaking and code splitting so that it is as small as possible, and the cache handler/post office portion is split from the huge blockchain portion. This is accomplished partially by the usage of
import().then()
inside the data iframe source, and partially by build steps.It will be built using webpack (not rollup initially).
In addition, the script responds to
UNLOCK_ENV
. The code could choose to hard-code values for LOCKSMITH_URI and READ_ONLY_PROVIDER but currently is designed to use env variables:This introduces significantly more complexity, so if it is acceptable, hard-coding will be a better solution.
If we decide to go with the current approach, the script will need to have access to the different values needed for staging and production in CircleCI and ensure we deploy the correct script version to production.
An alternative is to build 3 versions of the script, dev.unlock.min.js, staging.unlock.min.js, and unlock.min.js.
Additionally, the script should be versioned, so initially we will output unlock.1.0.min.js