@tramvai/build 2.6.7 → 2.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,55 +10,82 @@ Library for building `production` ready bundles for packages written in TypeScri
|
|
|
10
10
|
|
|
11
11
|
Install `@tramvai/build` first:
|
|
12
12
|
|
|
13
|
-
```bash
|
|
14
|
-
|
|
13
|
+
```bash npm2yarn
|
|
14
|
+
npm install --save-dev @tramvai/build
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Get started
|
|
18
|
+
|
|
17
19
|
Add necessary fields to `package.json`:
|
|
18
20
|
|
|
19
21
|
```json
|
|
20
22
|
{
|
|
21
23
|
"main": "lib/index.js",
|
|
22
|
-
"
|
|
24
|
+
"module": "lib/index.es.js",
|
|
25
|
+
"typings": "lib/index.d.ts",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"files": [
|
|
28
|
+
"lib"
|
|
29
|
+
]
|
|
23
30
|
}
|
|
24
31
|
```
|
|
25
32
|
|
|
26
33
|
> `"main": "lib/index.js"` based on that field lib calculates entry point for the build and it will be `"src/index.ts"` in this case
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
And to `tsconfig.json`:
|
|
35
|
+
Create `tsconfig.json`:
|
|
31
36
|
|
|
32
37
|
```json
|
|
33
38
|
{
|
|
34
39
|
"compilerOptions": {
|
|
35
40
|
"moduleResolution": "node",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
41
|
+
"module": "ESNext",
|
|
42
|
+
"target": "ES2015",
|
|
43
|
+
"allowJs": true,
|
|
38
44
|
"declaration": true,
|
|
45
|
+
"sourceMap": true,
|
|
39
46
|
"importHelpers": true,
|
|
47
|
+
"resolveJsonModule": true,
|
|
48
|
+
"allowSyntheticDefaultImports": true,
|
|
49
|
+
"esModuleInterop": true,
|
|
40
50
|
"skipLibCheck": true,
|
|
51
|
+
"jsx": "react-jsx",
|
|
41
52
|
"rootDir": "./src",
|
|
42
53
|
"outDir": "./lib",
|
|
43
|
-
"declarationDir": "./lib"
|
|
54
|
+
"declarationDir": "./lib",
|
|
55
|
+
"types": ["node"],
|
|
56
|
+
"lib": [
|
|
57
|
+
"es2015",
|
|
58
|
+
"es2016",
|
|
59
|
+
"es2017",
|
|
60
|
+
"es2018",
|
|
61
|
+
"dom"
|
|
62
|
+
]
|
|
44
63
|
},
|
|
45
|
-
"include": ["./src"]
|
|
64
|
+
"include": ["./src"],
|
|
65
|
+
"exclude": [
|
|
66
|
+
"**/*.spec.ts",
|
|
67
|
+
"**/*.spec.tsx",
|
|
68
|
+
"**/*.test.ts",
|
|
69
|
+
"**/*.test.tsx"
|
|
70
|
+
]
|
|
46
71
|
}
|
|
47
72
|
```
|
|
48
73
|
|
|
49
74
|
Add to `dependencies` library [tslib](https://www.npmjs.com/package/tslib):
|
|
50
75
|
|
|
51
|
-
```bash
|
|
52
|
-
|
|
76
|
+
```bash npm2yarn
|
|
77
|
+
npm install tslib
|
|
53
78
|
```
|
|
54
79
|
|
|
55
80
|
Build package with command `tramvai-build`:
|
|
56
81
|
|
|
57
82
|
```bash
|
|
58
|
-
tramvai-build --forPublish
|
|
83
|
+
tramvai-build --preserveModules --forPublish
|
|
59
84
|
```
|
|
60
85
|
|
|
61
|
-
> with flag `--
|
|
86
|
+
> with flag `--preserveModules` tramvai-build wil preserve file structure of library modules for better tree-shaking
|
|
87
|
+
|
|
88
|
+
> with flag `--forPublish` tramvai-build replaces some fields in `package.json` in order to make built package usable in the end apps, for example `"browser"` field with object value can be updated`
|
|
62
89
|
|
|
63
90
|
## Explanation
|
|
64
91
|
|