@olenbetong/appframe-vite 6.0.3 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -5,22 +5,7 @@ import { createDevMiddleware, getLoginInfo, getProxyRoutes } from "./devServer.j
5
5
  import { importJson } from "./importJson.js";
6
6
  import { localizeMiddleware } from "./localization.js";
7
7
  import { getLastSession, login } from "./proxy.js";
8
- // type AppframeDevConfig = {
9
- // article: {
10
- // id: string;
11
- // hostname: string;
12
- // };
13
- // deploy: {
14
- // hostname: string;
15
- // };
16
- // build: {
17
- // externals: true;
18
- // };
19
- // proxy?: {
20
- // hostname?: string;
21
- // routes?: string[];
22
- // };
23
- // };
8
+ let command = "build";
24
9
  let interval;
25
10
  let server;
26
11
  let lastHostname;
@@ -45,19 +30,38 @@ export default function appframe() {
45
30
  name: "appframe",
46
31
  resolveId(source) {
47
32
  if (source.startsWith("/file/") || source.startsWith("/lib/")) {
33
+ // In dev mode, resolve to the same ID so the load() hook can return an empty
34
+ // module, preventing noisy pre-transform errors from Vite's HTML crawl.
35
+ // These paths are served via the proxy so browser requests are unaffected.
36
+ // In build mode, return false to mark as external (not bundled).
37
+ if (command === "serve") {
38
+ return source;
39
+ }
48
40
  return false;
49
41
  }
50
42
  return null;
51
43
  },
44
+ load(id) {
45
+ if (id.startsWith("/file/") || id.startsWith("/lib/")) {
46
+ // Return an empty module so Vite's pre-transform crawl succeeds silently.
47
+ // Actual content is served via the proxy when the browser requests these URLs.
48
+ return "";
49
+ }
50
+ return null;
51
+ },
52
52
  async config(currentConfig, env) {
53
- const { command } = env;
53
+ command = env.command;
54
+ // Destructure to exclude rollupOptions — Vite 8 defines it as an enumerable
55
+ // getter alias for rolldownOptions on the build config, so spreading it would
56
+ // produce a config with both keys and trigger a spurious Vite warning.
57
+ const { rollupOptions: _ignored, ...restBuildConfig } = (currentConfig.build ?? {});
54
58
  let config = {
55
59
  ...currentConfig,
56
60
  build: {
57
- ...currentConfig.build,
58
- target: currentConfig.build?.target ?? ["chrome90", "safari14"],
61
+ ...restBuildConfig,
62
+ target: restBuildConfig.target ?? ["chrome90", "safari14"],
59
63
  rolldownOptions: {
60
- ...currentConfig.build?.rolldownOptions,
64
+ ...restBuildConfig.rolldownOptions,
61
65
  output: {
62
66
  assetFileNames: (assetInfo) => {
63
67
  if (assetInfo.name === "style.css")
@@ -46,8 +46,8 @@ export function addStringToCache(text, translation) {
46
46
  stringCache.set(text, translation);
47
47
  debouncedSaveCacheToFile();
48
48
  }
49
- export const localizeMiddleware = async (req, res, next) => {
50
- // @ts-ignore
49
+ export const localizeMiddleware = async (req, res, _next) => {
50
+ // @ts-expect-error - Vite's types don't include the body property, but it is there because we use the bodyParser middleware before this.
51
51
  let text = req.body.text;
52
52
  let { hostname, appframe } = await getLoginInfo();
53
53
  let authCookies = getLastSession(hostname)?.authCookies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -26,15 +26,15 @@
26
26
  "chalk": "^5.4.1",
27
27
  "chokidar": "^5.0.0",
28
28
  "dotenv": "^17.2.3",
29
- "jsdom": "29.0.1",
29
+ "jsdom": "29.0.2",
30
30
  "rollup-plugin-visualizer": "^6.0.5",
31
31
  "@olenbetong/appframe-data": "1.4.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jsdom": "^27.0.0",
35
- "@types/node": "25.5.0",
36
- "typescript": "^5.9.3",
37
- "vite": "8.0.1"
35
+ "@types/node": "25.6.0",
36
+ "typescript": "6.0.2",
37
+ "vite": "8.0.8"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "vite": ">=5.0.0"