Skip to content

Commit 253fec4

Browse files
author
Ryan Holinshead
committed
Set Up dev 'watch' for aiconfig-editor declarations HMR
1 parent 0bd50b3 commit 253fec4

File tree

15 files changed

+119
-18
lines changed

15 files changed

+119
-18
lines changed

python/src/aiconfig/editor/client/aiconfig-editor/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"dist"
1818
],
1919
"scripts": {
20-
"build": "npx tsc && vite build",
20+
"build": "yarn clean && vite build",
21+
"dev": "yarn clean && vite build --config vite.config.dev.ts",
2122
"clean": "rm -rf dist",
2223
"lint": "eslint . --max-warnings=0"
2324
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { PROD_CONFIG } from "./vite.config";
2+
import { LibraryOptions, defineConfig } from "vite";
3+
4+
// vite build --watch expects a watch/index.html entrypoing even for library builds.
5+
// But setting 'watch' in build config is an alternate way to watch changes to files,
6+
// so use this dev config for dev builds.
7+
export default defineConfig({
8+
...PROD_CONFIG,
9+
build: {
10+
...PROD_CONFIG.build,
11+
lib: {
12+
...(PROD_CONFIG.build!.lib as LibraryOptions),
13+
formats: ["es"], // LocalEditor only needs uses ES module format
14+
},
15+
watch: {
16+
include: "src/**", // Watches the specified files for changes.
17+
},
18+
},
19+
});
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
import { defineConfig } from "vite";
1+
import { resolve } from "path";
2+
import { UserConfig, defineConfig } from "vite";
23
import dts from "vite-plugin-dts";
34

4-
export default defineConfig({
5+
export const PROD_CONFIG: UserConfig = {
56
build: {
67
lib: {
7-
entry: "./src/index.ts", // Specifies the entry point for building the library.
8+
entry: resolve(__dirname, "/src/index.ts"), // Specifies the entry point for building the library.
89
name: "aiconfig-editor", // Sets the name of the generated library.
910
fileName: (format) => `index.${format}.js`, // Generates the output file name based on the format.
1011
formats: ["cjs", "es"], // Specifies the output formats (CommonJS and ES modules).
1112
},
1213
rollupOptions: {
1314
external: ["react", "react-dom"], // Defines external dependencies for Rollup bundling.
15+
input: resolve(__dirname, "src/index.ts"), // Specifies the entry point for Rollup bundling.
1416
},
1517
sourcemap: true, // Generates source maps for debugging.
1618
emptyOutDir: true, // Clears the output directory before building.
1719
},
1820
plugins: [dts()], // Uses the 'vite-plugin-dts' plugin for generating TypeScript declaration files (d.ts).
19-
});
21+
};
22+
23+
export default defineConfig(PROD_CONFIG);

python/src/aiconfig/editor/client/config-overrides.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,37 @@ const { alias, configPaths } = require("react-app-rewire-alias");
22

33
const aliasMap = configPaths("./tsconfig.paths.json");
44

5-
module.exports = alias(aliasMap);
5+
module.exports = {
6+
webpack: function (config) {
7+
const webpackConfig = alias(aliasMap)(config);
8+
return {
9+
...webpackConfig,
10+
watchOptions: {
11+
...webpackConfig.watchOptions,
12+
followSymlinks: true,
13+
},
14+
resolve: {
15+
...webpackConfig.resolve,
16+
symlinks: false,
17+
},
18+
};
19+
},
20+
devServer: function (configFunction) {
21+
return function (proxy, allowedHost) {
22+
const devConfig = configFunction(proxy, allowedHost);
23+
return {
24+
...devConfig,
25+
watchFiles: {
26+
paths: [
27+
"src/**/*",
28+
"node_modules/aiconfig-editor/**/*",
29+
"node_modules/@lastmileai/aiconfig-editor/**/*",
30+
],
31+
options: {
32+
followSymlinks: true,
33+
},
34+
},
35+
};
36+
};
37+
},
38+
};

python/src/aiconfig/editor/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"start": "react-app-rewired start",
7-
"build": "react-app-rewired build",
7+
"build": "cd aiconfig-editor && yarn clean && yarn build && cd .. && react-app-rewired build",
88
"postbuild": "node postbuild.js",
99
"test": "react-app-rewired test",
1010
"eject": "react-scripts eject",
@@ -24,6 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@datadog/browser-logs": "^5.7.0",
27+
"@lastmileai/aiconfig-editor": "./aiconfig-editor",
2728
"@mantine/core": "^6.0.7",
2829
"aiconfig": "../../../../../typescript",
2930
"aiconfig-editor": "./aiconfig-editor",

python/src/aiconfig/editor/client/src/LocalEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
RunPromptStreamCallback,
77
RunPromptStreamErrorCallback,
88
RunPromptStreamErrorEvent,
9-
} from "aiconfig-editor";
9+
} from "@lastmileai/aiconfig-editor";
1010
import { Flex, Loader, Image, createStyles } from "@mantine/core";
1111
import {
1212
AIConfig,

python/src/aiconfig/editor/client/tsconfig.paths.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"baseUrl": ".",
44
"paths": {
5-
"aiconfig-editor/*": ["aiconfig-editor/src/*"]
5+
"aiconfig-editor/*": ["aiconfig-editor/src/*"],
6+
"@lastmileai/aiconfig-editor/*": ["aiconfig-editor/src/*"]
67
}
78
}
89
}

python/src/aiconfig/editor/client/yarn.lock

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,29 @@
17801780
"@jridgewell/resolve-uri" "^3.1.0"
17811781
"@jridgewell/sourcemap-codec" "^1.4.14"
17821782

1783+
"@lastmileai/aiconfig-editor@./aiconfig-editor":
1784+
version "0.1.4"
1785+
dependencies:
1786+
"@emotion/react" "^11.11.1"
1787+
"@mantine/carousel" "^6.0.7"
1788+
"@mantine/core" "^6.0.7"
1789+
"@mantine/dates" "^6.0.16"
1790+
"@mantine/dropzone" "^6.0.7"
1791+
"@mantine/form" "^6.0.7"
1792+
"@mantine/hooks" "^6.0.7"
1793+
"@mantine/modals" "^6.0.7"
1794+
"@mantine/notifications" "^6.0.7"
1795+
"@mantine/prism" "^6.0.7"
1796+
"@monaco-editor/react" "^4.6.0"
1797+
"@tabler/icons-react" "^2.44.0"
1798+
aiconfig "^1.1.3"
1799+
lodash "^4.17.21"
1800+
node-fetch "^3.3.2"
1801+
react-error-boundary "^4.0.12"
1802+
react-markdown "^8.0.6"
1803+
remark-gfm "^3.0.1"
1804+
uuid "^9.0.1"
1805+
17831806
"@leichtgewicht/ip-codec@^2.0.1":
17841807
version "2.0.4"
17851808
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
@@ -3179,8 +3202,27 @@ aiconfig-editor@./aiconfig-editor:
31793202
remark-gfm "^3.0.1"
31803203
uuid "^9.0.1"
31813204

3182-
aiconfig@../../../../../typescript, aiconfig@^1.1.3:
3205+
aiconfig@../../../../../typescript:
3206+
version "1.1.5"
3207+
dependencies:
3208+
"@google-ai/generativelanguage" "^1.1.0"
3209+
"@huggingface/inference" "^2.6.4"
3210+
axios "^1.5.1"
3211+
google-auth-library "^9.1.0"
3212+
gpt-3-encoder "^1.1.4"
3213+
handlebars "^4.7.8"
3214+
js-yaml "^4.1.0"
3215+
lodash "^4.17.21"
3216+
node-fetch "^3.3.2"
3217+
openai "4.11.1"
3218+
typescript-json-schema "^0.60.0"
3219+
uuid "^9.0.1"
3220+
winston "^3.11.0"
3221+
3222+
aiconfig@^1.1.3:
31833223
version "1.1.5"
3224+
resolved "https://registry.yarnpkg.com/aiconfig/-/aiconfig-1.1.5.tgz#9bc9a608f0b6e4dfda2fefc4da4a97feb0ea45d7"
3225+
integrity sha512-b/UbUE504w+5wc90JhvJd/f0lnolbwkcVcK2VuP2+mv1ryBmNW71AxDanf1v+sh8iuRkhPH7pShkUcvncVUxSA==
31843226
dependencies:
31853227
"@google-ai/generativelanguage" "^1.1.0"
31863228
"@huggingface/inference" "^2.6.4"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"files": {
3-
"main.js": "/static/js/main.19541bdf.js",
3+
"main.js": "/static/js/main.e40a27c0.js",
44
"index.html": "/index.html",
5-
"main.19541bdf.js.map": "/static/js/main.19541bdf.js.map"
5+
"main.e40a27c0.js.map": "/static/js/main.e40a27c0.js.map"
66
},
77
"entrypoints": [
8-
"static/js/main.19541bdf.js"
8+
"static/js/main.e40a27c0.js"
99
]
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.19541bdf.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AIConfig Editor</title><script defer="defer" src="/static/js/main.e40a27c0.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

0 commit comments

Comments
 (0)