Skip to content

Commit 5fd4561

Browse files
author
Beatriz Rizental
authored
Merge pull request #661 from brizental/1726769-unminified-qt
Bug 1726769 - Include development version in Qt/QML build
2 parents ca0abbc + d2c630c commit 5fd4561

File tree

4 files changed

+69
-64
lines changed

4 files changed

+69
-64
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [#658](https://github.com/mozilla/glean.js/pull/658): Implement rate limiting for ping upload.
1111
* Only up to 15 ping submissions every 60 seconds are now allowed.
1212
* [#658](https://github.com/mozilla/glean.js/pull/658): BUGFIX: Unblock ping uploading jobs after the maximum of upload failures are hit for a given uploading window.
13+
* [#661](https://github.com/mozilla/glean.js/pull/661): Include unminified version of library on Qt/QML builds.
1314

1415
# v0.18.1 (2021-07-22)
1516

glean/package-lock.json

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

glean/src/platform/qt/storage.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,14 @@ class QMLStore implements Store {
180180

181181
async get(index: StorageIndex): Promise<JSONValue | undefined> {
182182
const obj = (await this._getFullResultObject(index)) || {};
183-
return getValueFromNestedObject(obj, index);
183+
try {
184+
return getValueFromNestedObject(obj, index);
185+
} catch(e) {
186+
log(LOG_TAG, [
187+
"Error getting value from database.",
188+
JSON.stringify((e as Error).message)
189+
]);
190+
}
184191
}
185192

186193
async update(

glean/webpack.config.qt.js

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { fileURLToPath } from "url";
99
const __filename = fileURLToPath(import.meta.url);
1010
const __dirname = dirname(__filename);
1111

12-
const OUTPUT = "glean.lib.js";
13-
1412
/**
1513
* Hacky plugin that removes ".js" extensions from imports before resolving.
1614
*
@@ -40,51 +38,77 @@ class TsResolvePlugin {
4038
* and not anywhere else.
4139
*/
4240
class RemoveUseStrictPlugin {
41+
constructor(output) {
42+
this.output = output;
43+
}
44+
4345
apply(compiler) {
4446
compiler.hooks.shouldEmit.tap("RemoveUseStrictPlugin", compilation => {
45-
compilation.assets[OUTPUT]._value = compilation.assets[OUTPUT]._value.replace("\"use strict\";", "");
47+
if (compilation.assets[this.output]._children) {
48+
compilation.assets[this.output]._children[0]._value = compilation.assets[this.output]._children[0]._value.replace("\"use strict\";", "");
49+
} else {
50+
compilation.assets[this.output]._value = compilation.assets[this.output]._value?.replace("\"use strict\";", "");
51+
}
4652
return true;
4753
});
4854
}
4955
}
5056

51-
export default {
52-
entry: "./src/index/qt.ts",
57+
// eslint-disable-next-line
58+
function getBaseConfig(output) {
59+
return {
60+
entry: "./src/index/qt.ts",
61+
module: {
62+
rules: [
63+
{
64+
test: /\.tsx?$/,
65+
loader: "ts-loader",
66+
exclude: /node_modules/,
67+
options: {
68+
onlyCompileBundledFiles: true,
69+
// This path is resolved relative to the entry file, ./src/index/qt.ts
70+
// See: https://github.com/TypeStrong/ts-loader#configfile
71+
configFile: "../../tsconfig/qt.json"
72+
},
73+
},
74+
],
75+
},
76+
resolve: {
77+
modules: ["node_modules"],
78+
extensions: [ ".tsx", ".ts", ".js" ],
79+
plugins: [
80+
new TsResolvePlugin()
81+
]
82+
},
83+
plugins: [
84+
new RemoveUseStrictPlugin(output),
85+
],
86+
output: {
87+
path: path.resolve(__dirname, "dist/qt/org/mozilla/Glean"),
88+
filename: output,
89+
libraryTarget: "var",
90+
library: "Glean",
91+
}
92+
};
93+
}
94+
95+
const productionConfig = {
96+
...getBaseConfig("glean.lib.js"),
5397
mode: "production",
5498
optimization: {
5599
usedExports: true,
56100
providedExports: true,
57101
sideEffects: true,
58102
},
59-
module: {
60-
rules: [
61-
{
62-
test: /\.tsx?$/,
63-
loader: "ts-loader",
64-
exclude: /node_modules/,
65-
options: {
66-
onlyCompileBundledFiles: true,
67-
// This path is resolved relative to the entry file, ./src/index/qt.ts
68-
// See: https://github.com/TypeStrong/ts-loader#configfile
69-
configFile: "../../tsconfig/qt.json"
70-
},
71-
},
72-
],
73-
},
74-
resolve: {
75-
modules: ["node_modules"],
76-
extensions: [ ".tsx", ".ts", ".js" ],
77-
plugins: [
78-
new TsResolvePlugin()
79-
]
80-
},
81-
plugins: [
82-
new RemoveUseStrictPlugin(),
83-
],
84-
output: {
85-
path: path.resolve(__dirname, "dist/qt/org/mozilla/Glean"),
86-
filename: OUTPUT,
87-
libraryTarget: "var",
88-
library: "Glean",
89-
}
90103
};
104+
105+
const developmentConfig = {
106+
...getBaseConfig("glean.dev.js"),
107+
mode: "development",
108+
devtool: false
109+
};
110+
111+
export default [
112+
productionConfig,
113+
developmentConfig
114+
];

0 commit comments

Comments
 (0)