Rewrite of bobril-build to .Net. Mainly for speed reasons. It now replaced original JS version.
yarn global add bobril-build
bb
Github by default has limit of 60 anonymous requests per hour from one IP. So if it fails you have 2 options, wait or provide token to authenticate as yourself. First read [https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/] how to create your token. Token can have just read only rights, you don't need to select any scopes. Then you can either store it into your user profile directory in .github/token.txt file or set environment variable GITHUB_TOKEN.
By default prerelease versions are not used.
In .bbrc file set bbVersion to specific version you need. By setting tsVersion you can override used TypeScript
for compilation. By setting jasmineVersion you can override Jasmine version only allowed values are "2.99" (default)
and "3.3".
{
"bbVersion": "2.10.0",
"tsVersion": "5.2.2",
"jasmineVersion: "3.3"
}
By setting BBVERSION environment variable you can define default version (including prerelease). If you will start
bb2 instead of bb, then BBVERSION override what is in .bbrc or package.json.
bb stores its cache in user_home/.bbcore/tools directory. In Docker it uses /bbcache. You can override it be
defining BBCACHEDIR environmental variable.
docker run -it --rm -v %cd%:/project -v directory_for_persistent_cache:/bbcache -p 8080:8080 bobril/build
- Bobril-build
- Chrome
- Nodejs
- Npm
- Yarn
docker build . -t bobril/build --build-arg VERSION=x.y.z
docker tag bobril/build bobril/build:x.y.z
docker push bobril/build:x.y.z
docker history bobril/build
docker run -it --rm --entrypoint bash bobril/build
| Number | Severity | Message |
|---|---|---|
| -1 | Warn | Local import has wrong casing |
| -2 | Warn | Module import has wrong casing |
| -3 | Error | Missing dependency |
| -5 | Error | First parameter of b.asset must be resolved as constant string |
| -6 | Error | b.sprite cannot have more than 6 parameters |
| -7 | Warn | Problem with translation message |
| -8 | Error | Translation message must be compile time resolvable constant string, use f instead if intended |
| -9 | Error | Hint message must be compile time resolvable constant string |
| -11 | Warn | Fixing local import with two slashes |
| -12 | Warn | Importing module without being in package.json as dependency |
| -13 | Warn | Unused dependency in package.json |
| -14 | Warn | Importing obsolete module: reason |
| -15 | Warn | Cannot resolve import |
| -16 | Error | Syntactic Error |
| -17 | Error | Invalid or unusable svg |
| -18 | Error | File does not exists |
global constants are defined using "defines" object. If DEBUG is not defined is it automatically defined as DEBUG
build-in constant which is true in interactive, test modes and fast build mode. First are expanded all defines, than
result of this expansion is input to envs expansion. In envs you define replacement for process.env object. If
NODE_ENV is not defined is it automatically defined like in example below.
Content must be always JavaScript expression with specially handled build-ins DEBUG, env, file. env is virtually
object with system environment variables. file is virtually object with utf-8 content of all files where property name
is file name relative to project root directory.
"defines": {
"DEBUG": "DEBUG",
"SomeConstant": "\"this is JS \"+\"expression\"",
"FileContent": "file[\"some_file_relative_to_package.json\"]"
},
"envs": {
"NODE_ENV": "DEBUG?\"development\":\"production\"",
"path": "env.Path"
}Default is to update all dependencies to latest version defined by package.json:
{
"dependencies": "upgrade"
}
If you want just install missing dependencies:
{
"dependencies": "install"
}
Or if you want to completely disable this feature:
{
"dependencies": "disabled"
}
Build generates tsconfig.json by default. You can disable this feature by:
{
"tsconfigUpdate": false
}
Install the TypeScript native preview package in your project:
npm install -D @typescript/native-preview@beta
When @typescript/native-preview is listed in devDependencies, bbcore uses its tsgo compiler for typechecking.
Interactive builds keep tsgo --watch running continuously, so typechecking is faster after the first check.
Transpilation from TypeScript to JavaScript still uses the regular TypeScript JavaScript compiler path.
tsrs is a Rust port of TypeScript 7. Enable it in .bbrc:
{
"tsrs": true
}
bbcore then uses tsrs for typechecking (interactive builds keep tsrs --watch running) and transpiles TypeScript to
JavaScript through the tsrs transpileModule API. To use tsrs only for typechecking and keep the existing
transpiler, add "tsrsTranspile": false.
The binary is found through the TSRS_BINARY environment variable, node_modules/@tsrs/<platform>,
node_modules/tsrs or PATH. When none is found, bbcore downloads the tsrs package for your platform from npm into
its tools directory ("tsrsVersion" selects the version, default is the version bbcore was tested with). When tsrs
is not available, for example on Windows or Intel macOS where tsrs has no build yet, or when the download fails,
bbcore logs a warning and falls back to TypeScript 7 (see below) in the version tsrs follows, so results stay the
same. When that is not available either, it falls back to Go TypeScript (tsgo from @typescript/native-preview or
PATH) for typechecking, or to regular TypeScript, and transpiles with regular TypeScript.
TypeScript 7 is a native compiler without typescript.js, so bbcore runs its tsc directly: for typechecking
(interactive builds keep tsc --watch running) and for transpilation through its transpileModule API. Select it by
version in .bbrc:
{
"tsVersion": "7.1.0-beta"
}
bbcore downloads @typescript/typescript-<platform> from npm into its tools directory. A project with typescript
7.1+ in devDependencies uses its installed tsc instead. TypeScript 7.0 is not supported, because its API cannot
transpile. Output gets the same emit changes as described for tsrs above.
bbcore applies the same emit changes to tsrs output as to its patched TypeScript compiler, so bundled JavaScript is the
same as with the regular transpiler. Source maps follow TypeScript 7 and are slightly more detailed, so columns of
build diagnostics can differ. To compare both transpilers for every file, use "validate": "tsrs"; differing files are
written to .bbcore/TsrsInput (regular output) and .bbcore/TsrsWrong (tsrs output).
By default localization is detected from existence of dependency bobril-g11n. You can override it:
{
"localize": true
}
{
"pathToTranslations": "translations/path/like/this"
}
It is relative to project. Default is "translations".
{
"buildOutputDir": "./dist"
}
{
"interactiveDumpsToDist": true
}
It checks only for existence of this interactiveDumpsToDist key, value does not matter for now.
{
"include": [ "**/*" ]
}
{
"exclude": [ "node_modules" ]
}
{
"excludeWatchers": [ "bin", "generated/file.ts" ]
}
Paths are relative to the project root and can point to either directories or files.
{
"files": [ "src/main.ts" ]
}
This list is just appended to generated tsconfig.json files list.
By default it finds all tests in project directory (it always skips node_modules). By defining this, you can limit or
add additional directories where to search.
{
"testDirectories": [ "spec" ]
}
To build and run tests from a single file, pass its absolute path or a path relative to the project directory:
bb test --testFilePath spec/common/scripts.spec.ts --filter "^scripts getSafeVariableName number at the start$"
--testFilePath selects one of the discovered test files before compilation and bundling. Its imports and the
project's normal entry points are still included. The optional --filter further selects tests by name within
that file; on its own, --filter still builds all test files. A path that does not match a discovered test file
is an error. IDE wrappers must forward the test file path to bb test as well as the name filter.
{
"warningsAsErrors": true
}
{
"ignoreDiagnostic": [ -1, -8 ]
}
{
"plugins": {
"bb-assets-generator-plugin": {
"generateSpritesFile": true
}
}
}
{
"obsolete": "Reason why is obsolete and what to use instead"
}
Use this comment in source code with import to ignore this specific import (must be before last import in source file)
// BBIgnoreObsolete: modulea, moduleb
{
"assets": {
"original/source/path/name.ext": "distName.ext",
"node_modules/anymodule/path", "path"
}
}
{
"preserveProjectRoot": true
}
{
"imports": {
"perf_hooks": null
}
}
This allows to override imports. If value is null then import is removed (behaves like it would be empty file). If value is string then import path is replaced by this string.
Useful if your API server does not uses CORS, so proxy requests through bobril-build localhost:8080. It includes support
for WebSockets connections. Url have to start with http:// or https://.
{
"proxyUrl": "http://localhost:3001"
}
By default it will use only Chrome or Chromium to test your code. But because headless Chrome on Windows does hang with some projects you can use use Firefox on Windows by defining this:
{
"headlessBrowserStrategy": "PreferFirefoxOnWindows"
}
Watcher inside Docker cannot use OS notification of filesystem changes. So by default BB inside docker uses polling
implementation with 250ms check frequency. You modify this time in milliseconds by BBWATCHER variable, also without
Docker it forces polling watcher:
set BBWATCHER=1000
set BBBROWSER=C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
Docker on Windows filesystem has limitation in creating links. To workaround this issue create environment variable
BBCoreNoLinks with not empty value so bbcore will add --no-bin-links parameter to yarn command line (Yarn 1 and
npm only, Yarn 2+ does not support it).
It uses same variable like all other dotnet containers DOTNET_RUNNING_IN_CONTAINER.
In ~/.bbcore/.bbcfg you can define global configuration. It is JSON file with following settings.
If you want to disable Windows notifications after build/test finished, you can create this file with following content:
{ "notificationsEnabled": false }