Skip to content

Commit

Permalink
Merge pull request #661 from brizental/1726769-unminified-qt
Browse files Browse the repository at this point in the history
Bug 1726769 - Include development version in Qt/QML build
  • Loading branch information
Beatriz Rizental authored Aug 25, 2021
2 parents ca0abbc + d2c630c commit 5fd4561
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 64 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [#658](https://github.com/mozilla/glean.js/pull/658): Implement rate limiting for ping upload.
* Only up to 15 ping submissions every 60 seconds are now allowed.
* [#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.
* [#661](https://github.com/mozilla/glean.js/pull/661): Include unminified version of library on Qt/QML builds.

# v0.18.1 (2021-07-22)

Expand Down
27 changes: 0 additions & 27 deletions glean/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion glean/src/platform/qt/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ class QMLStore implements Store {

async get(index: StorageIndex): Promise<JSONValue | undefined> {
const obj = (await this._getFullResultObject(index)) || {};
return getValueFromNestedObject(obj, index);
try {
return getValueFromNestedObject(obj, index);
} catch(e) {
log(LOG_TAG, [
"Error getting value from database.",
JSON.stringify((e as Error).message)
]);
}
}

async update(
Expand Down
96 changes: 60 additions & 36 deletions glean/webpack.config.qt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const OUTPUT = "glean.lib.js";

/**
* Hacky plugin that removes ".js" extensions from imports before resolving.
*
Expand Down Expand Up @@ -40,51 +38,77 @@ class TsResolvePlugin {
* and not anywhere else.
*/
class RemoveUseStrictPlugin {
constructor(output) {
this.output = output;
}

apply(compiler) {
compiler.hooks.shouldEmit.tap("RemoveUseStrictPlugin", compilation => {
compilation.assets[OUTPUT]._value = compilation.assets[OUTPUT]._value.replace("\"use strict\";", "");
if (compilation.assets[this.output]._children) {
compilation.assets[this.output]._children[0]._value = compilation.assets[this.output]._children[0]._value.replace("\"use strict\";", "");
} else {
compilation.assets[this.output]._value = compilation.assets[this.output]._value?.replace("\"use strict\";", "");
}
return true;
});
}
}

export default {
entry: "./src/index/qt.ts",
// eslint-disable-next-line
function getBaseConfig(output) {
return {
entry: "./src/index/qt.ts",
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
onlyCompileBundledFiles: true,
// This path is resolved relative to the entry file, ./src/index/qt.ts
// See: https://github.com/TypeStrong/ts-loader#configfile
configFile: "../../tsconfig/qt.json"
},
},
],
},
resolve: {
modules: ["node_modules"],
extensions: [ ".tsx", ".ts", ".js" ],
plugins: [
new TsResolvePlugin()
]
},
plugins: [
new RemoveUseStrictPlugin(output),
],
output: {
path: path.resolve(__dirname, "dist/qt/org/mozilla/Glean"),
filename: output,
libraryTarget: "var",
library: "Glean",
}
};
}

const productionConfig = {
...getBaseConfig("glean.lib.js"),
mode: "production",
optimization: {
usedExports: true,
providedExports: true,
sideEffects: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
onlyCompileBundledFiles: true,
// This path is resolved relative to the entry file, ./src/index/qt.ts
// See: https://github.com/TypeStrong/ts-loader#configfile
configFile: "../../tsconfig/qt.json"
},
},
],
},
resolve: {
modules: ["node_modules"],
extensions: [ ".tsx", ".ts", ".js" ],
plugins: [
new TsResolvePlugin()
]
},
plugins: [
new RemoveUseStrictPlugin(),
],
output: {
path: path.resolve(__dirname, "dist/qt/org/mozilla/Glean"),
filename: OUTPUT,
libraryTarget: "var",
library: "Glean",
}
};

const developmentConfig = {
...getBaseConfig("glean.dev.js"),
mode: "development",
devtool: false
};

export default [
productionConfig,
developmentConfig
];

0 comments on commit 5fd4561

Please sign in to comment.