UNPKG

2.87 kBMarkdownView Raw
1# Build Scripts
2This folder holds common build scripts accessed via the various `npm run` commands.
3Codegen is executed when calling `npm install` in order to generate all artifacts needed for the build to pass
4## Bundeling all the code
5
6The bundeling process can be split into several steps:
7
8`npm run build-css`
9This command will compile the css code and create the css file.
10
11`npm run build-prod` and `npm run build-dev`
12These commands will use rollup to bundle the code. This is where the magic happens and uses some files in this folder.
13
14`banner.ts` is used to create a banner at the beginning of the output file
15
16`rollup_plugins.ts` is used to define common plugins for rollup configurations
17
18`rollup_plugin_minify_style_spec.ts` is used to specify the plugin used in style spec bundeling
19
20In the `rollup` folder there are some files that are used as linking files as they link to other files for rollup to pick when bundling.
21
22Rollup is generating 3 files throughout the process of bundling:
23
24`index.ts` a file containing all the code that will run in the main thread.
25
26`shared.ts` a file containing all the code shared between the main and worker code.
27
28`worker.ts` a file containing all the code the will run in the worker threads.
29
30These 3 files are then referenced and used by the `bundle_prelude.js` file. It allows loading the web wroker code automatically in web workers without any extra effort from someone who would like to use the library, i.e. it simply works.
31
32### check-bundle-size.js
33This file is used by CI to make sure the bundle size is kept constant
34
35<hr>
36
37### `npm run codegen`
38The `codegen` command runs the following three scripts, to update the corresponding code files based on the `v8.json` style source, and other data files. Contributers should run this command manually when the underlying style data is modified. The generated code files are then commited to the repo.
39#### generate-struct-arrays.ts
40Generates `data/array_types.ts`, which consists of:
41 - `StructArrayLayout_*` subclasses, one for each underlying memory layout
42 - Named exports mapping each conceptual array type (e.g., `CircleLayoutArray`) to its corresponding `StructArrayLayout` class
43 - Specific named `StructArray` subclasses, when type-specific struct accessors are needed (e.g., `CollisionBoxArray`)
44#### generate-style-code.ts
45Generates the various `style/style_layer/[layer type]_style_layer_properties.ts` code files based on the content of `v8.json`. These files provide the type signatures for the paint and layout properties for each type of style layer.
46#### generate-style-spec.ts
47Generates `style-spec/types.ts` based on the content of `v8.json`. This provides the type signatures for a style specification (sources, layers, etc.).
48<hr>
49
50### Generate Release Nodes
51
52`release-notes.js` Used to generate release notes when releasing a new version
\No newline at end of file