Skip to content

Commit d73a93f

Browse files
author
Beatriz Rizental
authored
Merge pull request #768 from brizental/1702468-better-packaging
Bug 1702468 - Simplify build config and remove code duplication from final lib
2 parents 2319252 + 295097a commit d73a93f

File tree

13 files changed

+127
-1034
lines changed

13 files changed

+127
-1034
lines changed

benchmarks/package-lock.json

Lines changed: 36 additions & 908 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/size/core.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
// Metrics
6+
import BooleanMetricType from "@mozilla/glean/private/metrics/boolean";
7+
import CounterMetricType from "@mozilla/glean/private/metrics/counter";
8+
import DatetimeMetricType from "@mozilla/glean/private/metrics/datetime";
9+
import EventMetricType from "@mozilla/glean/private/metrics/event";
10+
import LabeledMetricType from "@mozilla/glean/private/metrics/labeled";
11+
import QuantityMetricType from "@mozilla/glean/private/metrics/quantity";
12+
import StringMetricType from "@mozilla/glean/private/metrics/string";
13+
import TextMetricType from "@mozilla/glean/private/metrics/text";
14+
import TimespanMetricType from "@mozilla/glean/private/metrics/timespan";
15+
import UUIDMetricType from "@mozilla/glean/private/metrics/uuid";
16+
import URLMetricType from "@mozilla/glean/private/metrics/url";
17+
// Plugins
18+
import PingEncryptionPlugin from "@mozilla/glean/plugins/encryption";
19+
20+
// We import everything and log it, so that we are sure all imports are used
21+
// and webpack is required to actually include them in the final bundle.
22+
console.log(
23+
JSON.stringify(Glean),
24+
JSON.stringify(BooleanMetricType),
25+
JSON.stringify(CounterMetricType),
26+
JSON.stringify(DatetimeMetricType),
27+
JSON.stringify(EventMetricType),
28+
JSON.stringify(LabeledMetricType),
29+
JSON.stringify(QuantityMetricType),
30+
JSON.stringify(StringMetricType),
31+
JSON.stringify(TextMetricType),
32+
JSON.stringify(TimespanMetricType),
33+
JSON.stringify(UUIDMetricType),
34+
JSON.stringify(URLMetricType),
35+
JSON.stringify(PingEncryptionPlugin),
36+
);

benchmarks/size/webext/max.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,10 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
import "../core.js";
6+
57
import Glean from "@mozilla/glean/webext";
6-
// Metrics
7-
import BooleanMetricType from "@mozilla/glean/webext/private/metrics/boolean";
8-
import CounterMetricType from "@mozilla/glean/webext/private/metrics/counter";
9-
import DatetimeMetricType from "@mozilla/glean/webext/private/metrics/datetime";
10-
import EventMetricType from "@mozilla/glean/webext/private/metrics/event";
11-
import LabeledMetricType from "@mozilla/glean/webext/private/metrics/labeled";
12-
import QuantityMetricType from "@mozilla/glean/webext/private/metrics/quantity";
13-
import StringMetricType from "@mozilla/glean/webext/private/metrics/string";
14-
import TextMetricType from "@mozilla/glean/webext/private/metrics/text";
15-
import TimespanMetricType from "@mozilla/glean/webext/private/metrics/timespan";
16-
import UUIDMetricType from "@mozilla/glean/webext/private/metrics/uuid";
17-
import URLMetricType from "@mozilla/glean/webext/private/metrics/url";
18-
// Plugins
19-
import PingEncryptionPlugin from "@mozilla/glean/webext/plugins/encryption";
208

219
// We import everything and log it, so that we are sure all imports are used
2210
// and webpack is required to actually include them in the final bundle.
23-
console.log(
24-
JSON.stringify(Glean),
25-
JSON.stringify(BooleanMetricType),
26-
JSON.stringify(CounterMetricType),
27-
JSON.stringify(DatetimeMetricType),
28-
JSON.stringify(EventMetricType),
29-
JSON.stringify(LabeledMetricType),
30-
JSON.stringify(QuantityMetricType),
31-
JSON.stringify(StringMetricType),
32-
JSON.stringify(TextMetricType),
33-
JSON.stringify(TimespanMetricType),
34-
JSON.stringify(UUIDMetricType),
35-
JSON.stringify(URLMetricType),
36-
JSON.stringify(PingEncryptionPlugin),
37-
);
11+
console.log(JSON.stringify(Glean));

bin/parser-for-schema-testing.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ npm run cli -- \
2626
# Update metrics import path
2727
FILE=glean/tests/integration/schema/generated/forTesting.ts
2828
run $SED -i.bak -E \
29-
-e 's#@mozilla/glean/webext/private/metrics#../../../../src/core/metrics/types#g' \
29+
-e 's#@mozilla/glean/private/metrics#../../../../src/core/metrics/types#g' \
3030
"${WORKSPACE_ROOT}/${FILE}"
3131
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
3232

3333
# Update ping import path
3434
FILE=glean/tests/integration/schema/generated/pings.ts
3535
run $SED -i.bak -E \
36-
-e 's#@mozilla/glean/webext/private/ping#../../../../src/core/pings/ping_type.js#g' \
36+
-e 's#@mozilla/glean/private/ping#../../../../src/core/pings/ping_type.js#g' \
3737
"${WORKSPACE_ROOT}/${FILE}"
3838
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
3939

glean/package.json

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,32 @@
66
"sideEffects": "false",
77
"exports": {
88
"./package.json": "./package.json",
9-
"./webext": "./dist/webext/index/webext.js",
10-
"./webext/private/metrics/*": "./dist/webext/core/metrics/types/*.js",
11-
"./webext/private/ping": "./dist/webext/core/pings/ping_type.js",
12-
"./webext/plugins/*": "./dist/webext/plugins/*.js",
13-
"./webext/uploader": "./dist/webext/core/upload/uploader.js",
14-
"./node": "./dist/node/index/node.js",
15-
"./node/private/metrics/*": "./dist/node/core/metrics/types/*.js",
16-
"./node/private/ping": "./dist/node/core/pings/ping_type.js",
17-
"./node/plugins/*": "./dist/node/plugins/*.js",
18-
"./node/uploader": "./dist/node/core/upload/uploader.js"
9+
"./private/metrics/*": "./dist/core/metrics/types/*.js",
10+
"./private/ping": "./dist/core/pings/ping_type.js",
11+
"./plugins/*": "./dist/plugins/*.js",
12+
"./uploader": "./dist/core/upload/uploader.js",
13+
"./node": "./dist/index/node.js",
14+
"./webext": "./dist/index/webext.js"
1915
},
2016
"typesVersions": {
2117
"*": {
2218
"webext": [
23-
"./dist/webext/types/index/webext.d.ts"
24-
],
25-
"webext/private/ping": [
26-
"./dist/webext/types/core/pings/ping_type.d.ts"
27-
],
28-
"webext/private/metrics/*": [
29-
"./dist/webext/types/core/metrics/types/*"
30-
],
31-
"webext/plugins/*": [
32-
"./dist/webext/types/plugins/*"
33-
],
34-
"webext/uploader": [
35-
"./dist/webext/types/core/upload/uploader.d.ts"
19+
"./dist/types/index/webext.d.ts"
3620
],
3721
"node": [
38-
"./dist/node/types/index/node.d.ts"
22+
"./dist/types/index/node.d.ts"
3923
],
40-
"node/private/ping": [
41-
"./dist/node/types/core/pings/ping_type.d.ts"
24+
"private/ping": [
25+
"./dist/types/core/pings/ping_type.d.ts"
4226
],
43-
"node/private/metrics/*": [
44-
"./dist/node/types/core/metrics/types/*"
27+
"private/metrics/*": [
28+
"./dist/types/core/metrics/types/*"
4529
],
46-
"node/plugins/*": [
47-
"./dist/node/types/plugins/*"
30+
"plugins/*": [
31+
"./dist/types/plugins/*"
4832
],
49-
"node/uploader": [
50-
"./dist/node/types/core/upload/uploader.d.ts"
33+
"uploader": [
34+
"./dist/types/core/upload/uploader.d.ts"
5135
]
5236
}
5337
},
@@ -74,14 +58,10 @@
7458
"lint:circular-deps": "madge --circular src/ --extensions ts",
7559
"lint:glinter": "npm run cli -- glinter src/metrics.yaml src/pings.yaml --allow-reserved",
7660
"fix": "eslint . --ext .ts,.js,.json --fix",
77-
"build": "run-s build:cli build:webext build:node build:qt",
61+
"build": "rm -rf dist && run-s build:cli build:lib build:types build:qt",
7862
"build:cli": "tsc -p ./tsconfig/cli.json",
79-
"build:webext:lib": "tsc -p ./tsconfig/webext/index.json",
80-
"build:webext:types": "tsc -p ./tsconfig/webext/types.json",
81-
"build:webext": "rm -rf dist/webext && run-s build:webext:lib build:webext:types",
82-
"build:node:lib": "tsc -p ./tsconfig/node/index.json",
83-
"build:node:types": "tsc -p ./tsconfig/node/types.json",
84-
"build:node": "rm -rf dist/node && run-s build:node:lib build:node:types",
63+
"build:lib": "tsc -p ./tsconfig/lib.json",
64+
"build:types": "tsc -p ./tsconfig/types.json",
8565
"build:qt": "rm -rf dist/qt && webpack --config webpack.config.qt.js && ../bin/prepare-qml-module.sh",
8666
"build:docs": "rm -rf dist/docs && typedoc src/ --out dist/docs --tsconfig tsconfig/docs.json --theme minimal",
8767
"build:metrics-docs": "npm run cli -- translate src/metrics.yaml src/pings.yaml -o ../docs/reference/ --format markdown --allow-reserved",

glean/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const LOG_TAG = "CLI";
1919
const VIRTUAL_ENVIRONMENT_DIR = ".venv";
2020

2121
// The version of glean_parser to install from PyPI.
22-
const GLEAN_PARSER_VERSION = "4.1.0";
22+
const GLEAN_PARSER_VERSION = "4.1.1";
2323

2424
// This script runs a given Python module as a "main" module, like
2525
// `python -m module`. However, it first checks that the installed

glean/tsconfig/lib.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./base.json",
3+
"include": [
4+
"../src/core/metrics/types/*.ts",
5+
"../src/plugins/*.ts",
6+
"../src/index/node.ts",
7+
"../src/index/webext.ts"
8+
],
9+
"compilerOptions": {
10+
"target": "ES2018",
11+
"module": "ES6",
12+
"outDir": "../dist/"
13+
}
14+
}

glean/tsconfig/node/index.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

glean/tsconfig/node/types.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

glean/tsconfig/types.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./base.json",
3+
"include": [
4+
"../src/core/metrics/types/*.ts",
5+
"../src/plugins/*.ts",
6+
"../src/index/node.ts",
7+
"../src/index/webext.ts"
8+
],
9+
"compilerOptions": {
10+
"outDir": "../dist/types",
11+
"removeComments": false,
12+
"declaration": true,
13+
"emitDeclarationOnly": true
14+
}
15+
}

0 commit comments

Comments
 (0)