[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 03/07: env setup
From: |
gnunet |
Subject: |
[taler-wallet-core] 03/07: env setup |
Date: |
Thu, 01 Jun 2023 17:24:47 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit 23321014824dc3078537ae38dfb986a0f0eeb0ba
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jun 1 09:20:36 2023 -0300
env setup
---
packages/web-util/src/index.build.ts | 64 ++++++++++++++++--------
packages/web-util/src/utils/http-impl.browser.ts | 4 +-
2 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/packages/web-util/src/index.build.ts
b/packages/web-util/src/index.build.ts
index 06961c4b4..ad31afb5c 100644
--- a/packages/web-util/src/index.build.ts
+++ b/packages/web-util/src/index.build.ts
@@ -70,9 +70,13 @@ function copyFilesPlugin(files: Array<string>) {
return {
name: "copy-files",
setup(build: PluginBuild) {
+ if (!files || !files.length) {
+ return;
+ }
const outDir = build.initialOptions.outdir;
- if (outDir === undefined)
+ if (outDir === undefined) {
throw Error("esbuild build options does not specify outdir");
+ }
build.onEnd(() => {
for (const file of files) {
const name = path.parse(file).base;
@@ -143,7 +147,6 @@ function linariaPlugin() {
const defaultEsBuildConfig: esbuild.BuildOptions = {
bundle: true,
- minify: false,
loader: {
".svg": "file",
".inline.svg": "text",
@@ -157,7 +160,6 @@ const defaultEsBuildConfig: esbuild.BuildOptions = {
target: ["es6"],
format: "esm",
platform: "browser",
- sourcemap: true,
jsxFactory: "h",
jsxFragment: "Fragment",
alias: {
@@ -171,6 +173,7 @@ const defaultEsBuildConfig: esbuild.BuildOptions = {
};
export interface BuildParams {
+ type: "development" | "test" | "production";
source: {
assets: string[];
js: string[];
@@ -186,33 +189,54 @@ export function computeConfig(params: BuildParams):
esbuild.BuildOptions {
copyFilesPlugin(params.source.assets),
];
- switch (params.css) {
- case "sass": {
- plugins.push(sassPlugin);
- break;
- }
- case "postcss": {
- plugins.push(postCssPlugin);
- break;
- }
+ if (params.css) {
+ switch (params.css) {
+ case "sass": {
+ plugins.push(sassPlugin);
+ break;
+ }
+ case "postcss": {
+ plugins.push(postCssPlugin);
+ break;
+ }
- case "linaria": {
- if (params.linariaPlugin) {
- plugins.push(params.linariaPlugin());
+ case "linaria": {
+ if (params.linariaPlugin) {
+ plugins.push(params.linariaPlugin());
+ }
+ break;
}
- break;
- }
- default: {
- const cssType: never = params.css;
- throw Error(`not supported: ${cssType}`);
+ default: {
+ const cssType: never = params.css;
+ throw Error(`not supported: ${cssType}`);
+ }
}
}
+ if (!params.type) {
+ throw Error(
+ `missing build type, it should be "test", "development" or "production"`,
+ );
+ }
+
+ if (!params.source.js) {
+ throw Error(`no javascript entry points, nothing to compile?`);
+ }
+ if (!params.destination) {
+ throw Error(`missing destination folder`);
+ }
+
return {
...defaultEsBuildConfig,
entryPoints: params.source.js,
publicPath: params.public,
outdir: params.destination,
+ minify: false, //params.type === "production",
+ sourcemap: true, //params.type !== "production",
+ define: {
+ ...defaultEsBuildConfig.define,
+ "process.env.NODE_ENV": JSON.stringify(params.type),
+ },
plugins,
};
}
diff --git a/packages/web-util/src/utils/http-impl.browser.ts
b/packages/web-util/src/utils/http-impl.browser.ts
index 3bc5bb141..a46e8d63f 100644
--- a/packages/web-util/src/utils/http-impl.browser.ts
+++ b/packages/web-util/src/utils/http-impl.browser.ts
@@ -108,9 +108,9 @@ export class BrowserHttpLib implements HttpRequestLibrary {
}, requestTimeout.d_ms);
}
- for (const headerName in Object.keys(requestHeadersMap)) {
+ Object.keys(requestHeadersMap).forEach((headerName) => {
myRequest.setRequestHeader(headerName, requestHeadersMap[headerName]);
- }
+ });
myRequest.responseType = "arraybuffer";
myRequest.send(myBody);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] branch master updated (2a92ca873 -> e9bdf7f31), gnunet, 2023/06/01
- [taler-wallet-core] 03/07: env setup,
gnunet <=
- [taler-wallet-core] 01/07: better support for linaria and alias, gnunet, 2023/06/01
- [taler-wallet-core] 06/07: make dev build work again, gnunet, 2023/06/01
- [taler-wallet-core] 07/07: assets should have base directory to copy tree, gnunet, 2023/06/01
- [taler-wallet-core] 05/07: move folder to catch up the reload on save, gnunet, 2023/06/01
- [taler-wallet-core] 04/07: using env prop, gnunet, 2023/06/01
- [taler-wallet-core] 02/07: use latest linaria lib, gnunet, 2023/06/01