changeset 133:8a30f1c9a702

trying to build a runnable dist
author drewp@bigasterisk.com
date Sat, 06 May 2023 14:10:55 -0700
parents 828a64e62e73
children 0b526ab94c84
files package.json tasks.py vite.config.ts
diffstat 3 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/package.json	Sat May 06 14:10:22 2023 -0700
+++ b/package.json	Sat May 06 14:10:55 2023 -0700
@@ -30,6 +30,8 @@
     "sub-events": "^1.9.0"
   },
   "devDependencies": {
+    "@rollup/plugin-commonjs": "^24.1.0",
+    "@rollup/plugin-node-resolve": "^15.0.2",
     "@rollup/plugin-terser": "^0.4.1",
     "@types/jest": "^29.5.1",
     "dependency-cruiser": "^12.12.0",
--- a/tasks.py	Sat May 06 14:10:22 2023 -0700
+++ b/tasks.py	Sat May 06 14:10:55 2023 -0700
@@ -43,19 +43,23 @@
     v = ctx.run('pnpm version minor').stdout.strip()
     ctx.run(f'hg commit --message "release {v}"')
     build(ctx)
+    install_to_bigasterisk_lib(ctx, 'streamed-graph.js',
+                               f'lib/streamed-graph/{v}/')
+    # this fails with ENEEDAUTH:
+    #ctx.run(f'pnpm publish --registry https://bigasterisk.com/js', pty=True)
+
+
+def install_to_bigasterisk_lib(ctx, distFile, libPath):
     filesRoot = '/my/site/homepage/newsrc/files'
-    path = f'lib/streamed-graph/{v}/'
-    outdir = f'{filesRoot}/{path}'
-    name = 'streamed-graph.es.js'
+    outdir = f'{filesRoot}/{libPath}'
     ctx.run(f'mkdir -p {outdir}')
-    ctx.run(f'cp dist/{name} {outdir}')
+    ctx.run(f'cp dist/{distFile} {outdir}')
+    print('rebuild bigasterisk:')
     ctx.run('cd /my/site/homepage; inv build')
     ctx.run(
         "curl -s -o/dev/null -w '%{url_effective} %{http_code} bytes=%{size_download}\n' "
-        + "https://bigasterisk.com/" + path + name,
+        + "https://bigasterisk.com/" + libPath + distFile,
         pty=True)
-    # this fails with ENEEDAUTH:
-    #ctx.run(f'pnpm publish --registry https://bigasterisk.com/js', pty=True)
 
 
 @task
--- a/vite.config.ts	Sat May 06 14:10:22 2023 -0700
+++ b/vite.config.ts	Sat May 06 14:10:55 2023 -0700
@@ -1,5 +1,7 @@
 import { defineConfig, Plugin, UserConfigExport } from "vite";
 import terser from "@rollup/plugin-terser";
+import rollupResolve from "@rollup/plugin-node-resolve";
+import rollupCommonjs from "@rollup/plugin-commonjs";
 
 const config: UserConfigExport = {
   base: "https://bigasterisk.com/reposyncDev/",
@@ -15,14 +17,19 @@
     target: "esnext",
     lib: {
       entry: "src/index.ts",
-      formats: ["es"],
+      formats: ["es", "cjs"],
     },
     rollupOptions: {
       external: /^lit/,
       plugins: [
+        rollupResolve({
+          browser: true,
+          preferBuiltins: false,
+        }),
+        rollupCommonjs(),
         terser({
-          mangle:false,
-          compress:false,
+          mangle: false,
+          compress: false,
           format: {
             semicolons: false,
           },