Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development pipeline fixes for WDS and HMR #23

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flake.lock

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

3 changes: 1 addition & 2 deletions nh-launcher-applet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dist
out-tsc
node_modules
*.tsbuildinfo
*.happ
*.dna
ui.zip
target
target
35 changes: 18 additions & 17 deletions nh-launcher-applet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"start": "npm run build:happ && cross-env HC_PORT=$(port) ADMIN_PORT=$(port) concurrently \"npm run start:happ\" \"npm run start:ui\"",
"start:ui": "concurrently -k --names tsc,dev-server \"npm run build:watch\" \"wds --config ./web-dev-server.config.mjs\"",
"start:happ": "RUST_LOG=warn WASM_LOG=debug echo \"pass\" | hc s --piped -f=$ADMIN_PORT generate ./workdir/provider_applet-applet.happ --run=$HC_PORT -a provider_applet-applet network mdns",
"build": "rimraf out-tsc && rimraf dist && rimraf tsconfig.tsbuildinfo && tsc && rollup --config rollup.config.js",
"build": "rimraf dist && rimraf tsconfig.tsbuildinfo && tsc && rollup --config rollup.config.js",
"build:watch": "tsc -w --preserveWatchOutput",
"package": "npm run package:ui && hc web-app pack ./workdir",
"package:ui": "rimraf ui.zip && npm run build && cd ./dist && bestzip ../ui.zip index.js icon.png",
Expand All @@ -16,36 +16,37 @@
"dependencies": {
"@holochain-open-dev/profiles": "^0.11.0",
"@holochain/client": "0.12.0",
"@neighbourhoods/nh-launcher-applet": "0.0.10",
"@lit-labs/context": "^0.1.1",
"@neighbourhoods/nh-launcher-applet": "0.0.10",
"@neighbourhoods/provider-applet": "workspace:*",
"@neighbourhoods/provider-component": "workspace:*",
"@neighbourhoods/provider-store": "workspace:*",
"@neighbourhoods/sensemaker-lite-types": "0.4.0",
"@open-wc/scoped-elements": "^2.1.1",
"@scoped-elements/material-web": "^0.0.19",
"lit": "^2.2.0",
"@neighbourhoods/provider-store": "workspace:*",
"@neighbourhoods/provider-component": "workspace:*",
"@neighbourhoods/provider-applet": "workspace:*",
"@neighbourhoods/sensemaker-lite-types": "0.4.0"
"lit": "^2.2.0"
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/preset-env": "^7.15.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "18.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-typescript": "^10.0.1",
"@web/dev-server": "^0.1.21",
"@web/dev-server-rollup": "^0.3.10",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@web/dev-server": "^0.1.35",
"@web/dev-server-esbuild": "^0.3.3",
"@web/dev-server-rollup": "^0.3.21",
"@web/rollup-plugin-import-meta-assets": "^1.0.7",
"babel-plugin-template-html-minifier": "^4.1.0",
"bestzip": "^2.2.0",
"concurrently": "^5.3.0",
"deepmerge": "^4.2.2",
"new-port-cli": "^1.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.56.2",
"rollup": "^3.18.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-workbox": "^6.2.0",
"tslib": "^2.3.1",
"typescript": "^4.5.0"
},
Expand Down
94 changes: 9 additions & 85 deletions nh-launcher-applet/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,12 @@
import path from 'path';
import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import copy from "rollup-plugin-copy";

import babel from "@rollup/plugin-babel";
import { importMetaAssets } from "@web/rollup-plugin-import-meta-assets";
import { terser } from "rollup-plugin-terser";
import typescript from '@rollup/plugin-typescript';
import copy from "rollup-plugin-copy"
import { makeConfig } from '@neighbourhoods/provider-applet/rollup.config'

const production = !process.env.ROLLUP_WATCH;

export default {
input: "dist/nh-launcher-applet/src/index.js",
output: {
format: "es",
dir: "dist",
sourcemap: false,
},
watch: {
clearScreen: false,
},
external: [],
plugins: [
copy({
targets: [{ src: "icon.png", dest: "dist" }],
}),
/** Resolve bare module imports */
nodeResolve({
browser: true,
preferBuiltins: false,
modulePaths: [path.resolve(__dirname, './out-tsc'), path.resolve(__dirname, './dist')],
}),
replace({
"process.env.NODE_ENV": '"production"',
}),
commonjs({}),
/** Minify JS */
typescript({
sourceMap: !production,
inlineSources: !production,
}),
terser(),
/** Bundle assets references via import.meta.url */
importMetaAssets(),
/** Compile JS to a lower language target */
babel({
exclude: /node_modules/,

babelHelpers: "bundled",
presets: [
[
require.resolve("@babel/preset-env"),
{
targets: [
"last 3 Chrome major versions",
"last 3 Firefox major versions",
"last 3 Edge major versions",
"last 3 Safari major versions",
],
modules: false,
bugfixes: true,
},
],
],
plugins: [
[
require.resolve("babel-plugin-template-html-minifier"),
{
modules: {
lit: ["html", { name: "css", encapsulation: "style" }],
},
failOnError: false,
strictCSS: true,
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
],
}),
],
};
export default makeConfig(
"dist/nh-launcher-applet/src/index.js",
production,
[copy({
targets: [{ src: "icon.png", dest: "dist" }],
})],
)
44 changes: 2 additions & 42 deletions nh-launcher-applet/web-dev-server.config.mjs
Original file line number Diff line number Diff line change
@@ -1,43 +1,3 @@
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
import { fromRollup } from "@web/dev-server-rollup";
import rollupReplace from "@rollup/plugin-replace";
import rollupCommonjs from "@rollup/plugin-commonjs";
import { makeConfig } from '@neighbourhoods/provider-applet/web-dev-server.config.mjs'

const replace = fromRollup(rollupReplace);
const commonjs = fromRollup(rollupCommonjs);

/** Use Hot Module replacement by adding --hmr to the start command */
const hmr = process.argv.includes("--hmr");

export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
open: true,
watch: !hmr,
/** Resolve bare module imports */
nodeResolve: {
exportConditions: ["browser", "development"],
browser: true,
preferBuiltins: false,
},

/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto'

/** Set appIndex to enable SPA routing */
appIndex: "./demo/index.html",
rootDir: '../',
clearTerminalOnReload: false,

plugins: [
replace({
"process.env.HC_PORT": JSON.stringify(process.env.HC_PORT),
"process.env.ADMIN_PORT": JSON.stringify(process.env.ADMIN_PORT) || undefined,
delimiters: ["", ""],
}),

commonjs(),
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
],

// See documentation for all available options
});
export default /** @type {import('@web/dev-server').DevServerConfig} */ makeConfig("./demo/index.html", "../")
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
"private": true,
"scripts": {
"start": "AGENTS=2 npm run network",
"network": "hc s clean && npm run build:test-happ && concurrently \"cd ui/ && npm run build:watch\" \"npm run launch:happ\"",
"launch:happ": "RUST_LOG=warn echo \"pass\" | hc launch --piped -n $AGENTS ./workdir/sensemaker-enabled/provider-sensemaker.happ -w --ui-path ui/dist network mdns",
"network": "export UI_PORT=$(port) && npm run build:test-happ && concurrently \"cd ui/ && npm run start $UI_PORT\" \"npm run launch:happ\"",
"launch:happ": "RUST_LOG=warn echo \"pass\" | hc launch --piped -n $AGENTS ./workdir/sensemaker-enabled/provider-sensemaker.happ -w --ui-port $UI_PORT network mdns",
"test": "npm run build:happ && cd tests/ && npm run test",
"start:happ": "concurrently \"RUST_LOG=warn echo \"pass\" | hc s --piped -f=$HC_ADMIN_PORT generate ./workdir/sensemaker-enabled/provider-sensemaker.happ --run=$HC_PORT -a provider network mdns\" \"npm run playground\"",
"package": "npm run build:happ && npm run build:ui && cd nh-launcher-applet/ && npm run package:ui && cd ../ && hc web-app pack workdir",
"build:happ": "npm run build:dnas && hc app pack ./workdir",
"build:test-happ": "npm run build:dnas && hc app pack ./workdir/sensemaker-enabled",
"build:dnas": "npm run build:zomes && hc dna pack ./dnas/provider/workdir",
"build:zomes": "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown",
"build:ui": "cd ui/ && npm run ts-build",
"build:ui": "cd ui/ && npm run build",
"playground": "run-singleton \"holochain-playground\"",
"download-sensemaker": "[ ! -f \"workdir/sensemaker.dna\" ] && curl -L --output workdir/sensemaker.dna https://github.com/neighbour-hoods/sensemaker-lite/releases/download/v0.0.4-alpha/sensemaker.dna; exit 0",
"start:ui": "npm run start -w ui",
Expand All @@ -21,7 +20,7 @@
"clean:build": "nix-shell --run hn-rust-flush",
"clean:downloaded": "npm run clean:downloaded:sensemaker; exit 0",
"clean:downloaded:sensemaker": "rimraf workdir/sensemaker.dna",
"clean:modules": "rimraf ui/node_modules; rimraf nh-launcher-applet/node_modules; rimraf node_modules",
"clean:modules": "rimraf node_modules; for DIR in $(find -type d -iname node_modules); do echo \" Remove $DIR\"; rm -Rf \"$DIR\"; done",
"clean": "npm run clean:downloaded; npm run clean:build; npm run clean:modules"
},
"devDependencies": {
Expand Down
Loading