You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.
Right now, hopr-chat works as a simple CommonJS (.cjs) application, that is first compiled into JavaScript from TypeScript, and then executed using Node.js v12.x. As we are looking to deliver hopr-chat as a standalone binary that can be used in multiple operating systems like Windows, we need to bundle all our node dependencies with binary bundling tooling like electron-builder, nexe or pkg. Unfortunately, as hopr-core (and hence hopr-chat) relies in very specific libraries that require low-level APIs (e.g. wrtc), it would be easier to first ensure we only bundle what is needed to ensure only external dependencies are needed and then passing those to binary bundlers.
Task Description
Create an aegir, rollup or similar setup to bundle hopr-chat after being compiled into JavaScript. The process can be two fold (e.g. first compile, then bundle) or into a single step using adequate plugins (e.g. compiling and bundling at the same time).
Create a new branch that provides the aforementioned setup and test it by running node bundled.js while removing all other compiled dependencies generated, as to ensure all code needed by hopr-chat has been included in bundled.js.
Definition of Complete
The task is considered completed when a task inside package.json called build:bundle is able to compile TypeScript and bundle the result into a single-entry point file.
Testing Criteria
The compiled bundled can be executed using node and rely in no other external files.
The filed underwent a tree-shaking process to ensure only needed dependencies were included.
Notes
Previous work has been done to allow this. A sample rollup configuration used is below, but bear in mind it might not be complete or is lacking. babel (and thus .babelrc) was used to do the compilation of TypeScript, but some external dependencies are still causing issues. In particular, ganache-core, used for testing is being embedded and breaking the build. Tickets on hoprnet/hopr-core-ethereum#63 and hoprnet/hopr-testing#1 are meant to solve this problem.
rollup.config.js
import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import alias from "@rollup/plugin-alias";
import path from "path";
export default {
input: "index.ts",
external: ["wrtc", "ganache-core", "web3-core"],
output: {
name: "HOPRChat",
file: "hopr-chat.js",
format: "cjs",
},
plugins: [
alias({
"package.json": path.join(__dirname, "package.json")
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
}),
commonjs(),
babel({
exclude: './node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx']
}),
json()
],
};
Pushing this one as currently our node-bin setup is working. We'll eventually figure an alternative whenever we go for a different transport that isn't wrtc. Pushing from sprint.
Introduction
Right now,
hopr-chat
works as a simple CommonJS (.cjs
) application, that is first compiled into JavaScript from TypeScript, and then executed using Node.jsv12.x
. As we are looking to deliverhopr-chat
as a standalone binary that can be used in multiple operating systems like Windows, we need to bundle all ournode
dependencies with binary bundling tooling likeelectron-builder
,nexe
orpkg
. Unfortunately, ashopr-core
(and hencehopr-chat
) relies in very specific libraries that require low-level APIs (e.g.wrtc
), it would be easier to first ensure we only bundle what is needed to ensure only external dependencies are needed and then passing those to binary bundlers.Task Description
aegir
,rollup
or similar setup to bundlehopr-chat
after being compiled into JavaScript. The process can be two fold (e.g. first compile, then bundle) or into a single step using adequate plugins (e.g. compiling and bundling at the same time).node bundled.js
while removing all other compiled dependencies generated, as to ensure all code needed byhopr-chat
has been included inbundled.js
.Definition of Complete
The task is considered completed when a task inside
package.json
calledbuild:bundle
is able to compile TypeScript and bundle the result into a single-entry point file.Testing Criteria
node
and rely in no other external files.Notes
Previous work has been done to allow this. A sample
rollup
configuration used is below, but bear in mind it might not be complete or is lacking.babel
(and thus.babelrc
) was used to do the compilation of TypeScript, but some external dependencies are still causing issues. In particular,ganache-core
, used for testing is being embedded and breaking the build. Tickets on hoprnet/hopr-core-ethereum#63 and hoprnet/hopr-testing#1 are meant to solve this problem.rollup.config.js
.babelrc
The text was updated successfully, but these errors were encountered: