Skip to content

Commit

Permalink
Add library bundle to build
Browse files Browse the repository at this point in the history
Mainly to satisfy my curiosity re: bundle size, which turns out to be ~90kb gzipped
  • Loading branch information
jonathonherbert committed Jan 2, 2025
1 parent 55811e1 commit 4e0b52b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script type="module" src="/src/page.ts"></script>
<h2 id="todos">Todos</h2>
<ul>
<li><input checked type="checkbox" /> Scanning</li>
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "tsc && vite build && vite build --config vite.lib.config.ts",
"test:debug": "bun test --inspect-wait=localhost:6499/vscode",
"preview": "vite preview",
"lint": "eslint ."
Expand Down
4 changes: 4 additions & 0 deletions client/src/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { createCqlInput } from "./cqlInput/CqlInput";
export { CqlClientService } from "./services/CqlService";
export { TypeaheadHelpersCapi } from "./typeahead/typeaheadHelpersCapi";
export { TypeaheadField } from "./lang/typeahead.ts";
File renamed without changes.
18 changes: 18 additions & 0 deletions client/vite.lib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
define: {
"process.platform": '"web"',
},

build: {
minify: true,
lib: {
entry: "src/lib.ts",
name: "Cql",
// the proper extensions will be added
fileName: "cql",
formats: ["es"],
},
},
});

0 comments on commit 4e0b52b

Please sign in to comment.