@intuned/browser-dev 2.2.3-test-build.2 → 2.2.3-test-build.23
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/BROWSER_SCRIPTS_SETUP.md +13 -7
- package/dist/common/script.js +1 -2
- package/package.json +2 -3
package/BROWSER_SCRIPTS_SETUP.md
CHANGED
|
@@ -16,17 +16,18 @@ The `common/browser_scripts.js` file at the root of the monorepo needs to be inc
|
|
|
16
16
|
|
|
17
17
|
The generation happens automatically:
|
|
18
18
|
|
|
19
|
-
### During
|
|
19
|
+
### During Development (prepare hook)
|
|
20
20
|
|
|
21
|
-
When you run `yarn install
|
|
21
|
+
When you run `yarn install` or `npm publish` in the development repo, the `prepare` hook generates `script.ts`:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
yarn install # automatically runs generate-browser-script
|
|
24
|
+
yarn install # automatically runs prepare → generate-browser-script
|
|
25
|
+
npm publish # prepare hook runs before publishing
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
### During Build
|
|
28
29
|
|
|
29
|
-
The build script
|
|
30
|
+
The build script regenerates `script.ts` before compiling:
|
|
30
31
|
|
|
31
32
|
```bash
|
|
32
33
|
yarn build # runs generate-browser-script → tsc → babel
|
|
@@ -40,6 +41,10 @@ You can manually regenerate the file:
|
|
|
40
41
|
yarn generate-browser-script
|
|
41
42
|
```
|
|
42
43
|
|
|
44
|
+
### For Package Consumers
|
|
45
|
+
|
|
46
|
+
When users install your package via npm/yarn, they get the pre-generated `script.ts` that's committed to the repo. The `prepare` hook does NOT run when installing as a dependency (only during development/publishing).
|
|
47
|
+
|
|
43
48
|
## Usage in Code
|
|
44
49
|
|
|
45
50
|
In `ensureBrowserScripts.ts`:
|
|
@@ -65,9 +70,10 @@ async function ensureBrowserScripts(page: Page): Promise<void> {
|
|
|
65
70
|
## Important Notes
|
|
66
71
|
|
|
67
72
|
- **DO NOT** edit `script.ts` manually - it's auto-generated
|
|
68
|
-
- **DO
|
|
69
|
-
- The file is regenerated on every build and
|
|
70
|
-
- If you update `common/browser_scripts.js`, run `yarn generate-browser-script` to update
|
|
73
|
+
- **DO** commit `script.ts` to git - it needs to be in the published package
|
|
74
|
+
- The file is regenerated on every build and during `prepare` (development only)
|
|
75
|
+
- If you update `common/browser_scripts.js`, run `yarn generate-browser-script` to update and commit the changes
|
|
76
|
+
- Package consumers get the pre-generated file, so they don't need the `scripts/` folder
|
|
71
77
|
|
|
72
78
|
## Benefits
|
|
73
79
|
|
package/dist/common/script.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/browser-dev",
|
|
3
|
-
"version": "2.2.3-test-build.
|
|
3
|
+
"version": "2.2.3-test-build.23",
|
|
4
4
|
"description": "runner package for intuned functions",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"typesVersions": {
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"author": "Intuned Team",
|
|
36
36
|
"license": "Elastic-2.0",
|
|
37
37
|
"scripts": {
|
|
38
|
-
"generate-browser-script": "
|
|
39
|
-
"postinstall": "yarn generate-browser-script",
|
|
38
|
+
"generate-browser-script": "bash scripts/generate-browser-script.sh",
|
|
40
39
|
"build": "rm -rf dist && yarn generate-browser-script && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && node scripts/ensure-index-types.js",
|
|
41
40
|
"ensure-types": "node scripts/ensure-index-types.js",
|
|
42
41
|
"test": "vitest run",
|