@gtkx/cli 1.0.0-rc.1 → 1.0.0-rc.2
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/dist/builder.d.ts +3 -2
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +2 -1
- package/dist/builder.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -6
- package/dist/cli.js.map +1 -1
- package/dist/codegen/freshness.d.ts +5 -5
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +26 -23
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/report.d.ts +2 -1
- package/dist/codegen/report.d.ts.map +1 -1
- package/dist/codegen/report.js +4 -2
- package/dist/codegen/report.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +8 -8
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +72 -43
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +8 -5
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +26 -6
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/build.d.ts +4 -3
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +2 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/codegen.d.ts +2 -1
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +6 -4
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/dev.d.ts +2 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +2 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs.d.ts +2 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +22 -7
- package/dist/commands/docs.js.map +1 -1
- package/dist/dev/icon-dir.d.ts +2 -1
- package/dist/dev/icon-dir.d.ts.map +1 -1
- package/dist/dev/icon-dir.js +6 -3
- package/dist/dev/icon-dir.js.map +1 -1
- package/dist/dev/refresh-tracker.d.ts +5 -4
- package/dist/dev/refresh-tracker.d.ts.map +1 -1
- package/dist/dev/refresh-tracker.js +6 -5
- package/dist/dev/refresh-tracker.js.map +1 -1
- package/dist/dev/runner-deps.d.ts +2 -1
- package/dist/dev/runner-deps.d.ts.map +1 -1
- package/dist/dev/runner-deps.js +20 -4
- package/dist/dev/runner-deps.js.map +1 -1
- package/dist/dev/runner-main.d.ts +2 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +3 -2
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/runner.d.ts +6 -5
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +69 -38
- package/dist/dev/runner.js.map +1 -1
- package/dist/dev/schema-dir.d.ts +2 -1
- package/dist/dev/schema-dir.d.ts.map +1 -1
- package/dist/dev/schema-dir.js +4 -2
- package/dist/dev/schema-dir.js.map +1 -1
- package/dist/dev/supervisor.d.ts +7 -6
- package/dist/dev/supervisor.d.ts.map +1 -1
- package/dist/dev/supervisor.js +107 -67
- package/dist/dev/supervisor.js.map +1 -1
- package/dist/dev/vite-dev-server.d.ts +3 -3
- package/dist/dev/vite-dev-server.d.ts.map +1 -1
- package/dist/dev/vite-dev-server.js +2 -1
- package/dist/dev/vite-dev-server.js.map +1 -1
- package/dist/internal/banner.d.ts +2 -1
- package/dist/internal/banner.d.ts.map +1 -1
- package/dist/internal/banner.js +2 -1
- package/dist/internal/banner.js.map +1 -1
- package/dist/internal/data-dir.d.ts +3 -2
- package/dist/internal/data-dir.d.ts.map +1 -1
- package/dist/internal/data-dir.js +29 -14
- package/dist/internal/data-dir.js.map +1 -1
- package/dist/internal/entry-arg.d.ts +5 -4
- package/dist/internal/entry-arg.d.ts.map +1 -1
- package/dist/internal/entry-arg.js +10 -7
- package/dist/internal/entry-arg.js.map +1 -1
- package/dist/internal/errors.d.ts +3 -2
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +7 -5
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/list-files.d.ts +3 -2
- package/dist/internal/list-files.d.ts.map +1 -1
- package/dist/internal/list-files.js +5 -3
- package/dist/internal/list-files.js.map +1 -1
- package/dist/internal/resolve-cli-tool.d.ts +2 -1
- package/dist/internal/resolve-cli-tool.d.ts.map +1 -1
- package/dist/internal/resolve-cli-tool.js +17 -10
- package/dist/internal/resolve-cli-tool.js.map +1 -1
- package/dist/internal/staging-dir.d.ts +3 -2
- package/dist/internal/staging-dir.d.ts.map +1 -1
- package/dist/internal/staging-dir.js +3 -2
- package/dist/internal/staging-dir.js.map +1 -1
- package/dist/internal/xdg-data-dirs.d.ts +2 -1
- package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
- package/dist/internal/xdg-data-dirs.js +4 -2
- package/dist/internal/xdg-data-dirs.js.map +1 -1
- package/dist/mcp/client.d.ts +9 -4
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +106 -81
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/handlers.d.ts +3 -2
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +89 -61
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +30 -13
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/serialize-widget.d.ts +3 -3
- package/dist/mcp/serialize-widget.d.ts.map +1 -1
- package/dist/mcp/serialize-widget.js +9 -6
- package/dist/mcp/serialize-widget.js.map +1 -1
- package/dist/mcp/testing-loader.d.ts +3 -4
- package/dist/mcp/testing-loader.d.ts.map +1 -1
- package/dist/mcp/testing-loader.js +43 -21
- package/dist/mcp/testing-loader.js.map +1 -1
- package/dist/mcp/widget-registry.d.ts +3 -2
- package/dist/mcp/widget-registry.d.ts.map +1 -1
- package/dist/mcp/widget-registry.js +4 -3
- package/dist/mcp/widget-registry.js.map +1 -1
- package/dist/refresh-globals.d.ts +2 -0
- package/dist/refresh-globals.d.ts.map +1 -0
- package/dist/refresh-globals.js +8 -0
- package/dist/refresh-globals.js.map +1 -0
- package/dist/refresh-runtime.d.ts +5 -11
- package/dist/refresh-runtime.d.ts.map +1 -1
- package/dist/refresh-runtime.js +16 -14
- package/dist/refresh-runtime.js.map +1 -1
- package/dist/settings/compile.d.ts +2 -1
- package/dist/settings/compile.d.ts.map +1 -1
- package/dist/settings/compile.js +6 -4
- package/dist/settings/compile.js.map +1 -1
- package/dist/settings/parser.d.ts +6 -5
- package/dist/settings/parser.d.ts.map +1 -1
- package/dist/settings/parser.js +26 -22
- package/dist/settings/parser.js.map +1 -1
- package/dist/settings/render.d.ts +3 -2
- package/dist/settings/render.d.ts.map +1 -1
- package/dist/settings/render.js +38 -64
- package/dist/settings/render.js.map +1 -1
- package/dist/settings/schema.d.ts +8 -8
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +61 -43
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-extensions.d.ts +4 -3
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +4 -3
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/built-url.d.ts +2 -1
- package/dist/vite-plugins/built-url.d.ts.map +1 -1
- package/dist/vite-plugins/built-url.js +19 -13
- package/dist/vite-plugins/built-url.js.map +1 -1
- package/dist/vite-plugins/css.d.ts +2 -1
- package/dist/vite-plugins/css.d.ts.map +1 -1
- package/dist/vite-plugins/css.js +23 -15
- package/dist/vite-plugins/css.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts +5 -4
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.js +11 -7
- package/dist/vite-plugins/fast-refresh/refresh-filter.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts +4 -3
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.js +45 -41
- package/dist/vite-plugins/fast-refresh/swc-refresh.js.map +1 -1
- package/dist/vite-plugins/icons.d.ts +2 -1
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js +24 -20
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/index.d.ts +2 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +3 -2
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/native.d.ts +2 -1
- package/dist/vite-plugins/native.d.ts.map +1 -1
- package/dist/vite-plugins/native.js +6 -4
- package/dist/vite-plugins/native.js.map +1 -1
- package/dist/vite-plugins/react-compiler.d.ts +3 -2
- package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
- package/dist/vite-plugins/react-compiler.js +26 -20
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/react-dom-prebundle.d.ts +2 -1
- package/dist/vite-plugins/react-dom-prebundle.d.ts.map +1 -1
- package/dist/vite-plugins/react-dom-prebundle.js +2 -1
- package/dist/vite-plugins/react-dom-prebundle.js.map +1 -1
- package/dist/vite-plugins/resource-init-module.d.ts +2 -1
- package/dist/vite-plugins/resource-init-module.d.ts.map +1 -1
- package/dist/vite-plugins/resource-init-module.js +39 -38
- package/dist/vite-plugins/resource-init-module.js.map +1 -1
- package/dist/vite-plugins/resource-shared.d.ts +7 -5
- package/dist/vite-plugins/resource-shared.d.ts.map +1 -1
- package/dist/vite-plugins/resource-shared.js +17 -10
- package/dist/vite-plugins/resource-shared.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts +3 -2
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +94 -54
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts +2 -1
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +4 -2
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/settings.d.ts +2 -1
- package/dist/vite-plugins/settings.d.ts.map +1 -1
- package/dist/vite-plugins/settings.js +56 -32
- package/dist/vite-plugins/settings.js.map +1 -1
- package/dist/vite-plugins/strip-query.d.ts +3 -0
- package/dist/vite-plugins/strip-query.d.ts.map +1 -0
- package/dist/vite-plugins/strip-query.js +6 -0
- package/dist/vite-plugins/strip-query.js.map +1 -0
- package/dist/vite-plugins/undeclared-library.d.ts +2 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +8 -5
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vite-plugins/virtual-module.d.ts +2 -2
- package/dist/vite-plugins/virtual-module.d.ts.map +1 -1
- package/dist/vite-plugins/virtual-module.js +5 -3
- package/dist/vite-plugins/virtual-module.js.map +1 -1
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +21 -61
- package/package.json +12 -14
- package/src/babel-modules.d.ts +0 -2
- package/src/builder.ts +7 -6
- package/src/cli.ts +26 -6
- package/src/codegen/freshness.ts +38 -25
- package/src/codegen/report.ts +10 -2
- package/src/codegen/run-codegen.ts +135 -60
- package/src/codegen/store-resolver.ts +56 -15
- package/src/commands/build.ts +3 -2
- package/src/commands/codegen.ts +9 -4
- package/src/commands/dev.ts +3 -4
- package/src/commands/docs.ts +36 -7
- package/src/dev/icon-dir.ts +13 -3
- package/src/dev/refresh-tracker.ts +12 -8
- package/src/dev/runner-deps.ts +30 -7
- package/src/dev/runner-main.ts +4 -3
- package/src/dev/runner.ts +100 -41
- package/src/dev/schema-dir.ts +7 -2
- package/src/dev/supervisor.ts +169 -71
- package/src/dev/vite-dev-server.ts +4 -2
- package/src/internal/banner.ts +5 -1
- package/src/internal/data-dir.ts +47 -16
- package/src/internal/entry-arg.ts +16 -8
- package/src/internal/errors.ts +15 -7
- package/src/internal/list-files.ts +10 -4
- package/src/internal/resolve-cli-tool.ts +28 -12
- package/src/internal/staging-dir.ts +5 -2
- package/src/internal/xdg-data-dirs.ts +8 -2
- package/src/mcp/client.ts +143 -85
- package/src/mcp/handlers.ts +126 -69
- package/src/mcp/index.ts +38 -14
- package/src/mcp/serialize-widget.ts +15 -8
- package/src/mcp/testing-loader.ts +64 -23
- package/src/mcp/widget-registry.ts +11 -5
- package/src/refresh-globals.ts +10 -0
- package/src/refresh-runtime.ts +20 -16
- package/src/settings/compile.ts +7 -4
- package/src/settings/parser.ts +69 -30
- package/src/settings/render.ts +66 -66
- package/src/settings/schema.ts +100 -46
- package/src/vite-plugins/asset-extensions.ts +4 -3
- package/src/vite-plugins/built-url.ts +30 -15
- package/src/vite-plugins/css.ts +35 -20
- package/src/vite-plugins/fast-refresh/refresh-filter.ts +18 -10
- package/src/vite-plugins/fast-refresh/swc-refresh.ts +60 -47
- package/src/vite-plugins/icons.ts +40 -24
- package/src/vite-plugins/index.ts +6 -3
- package/src/vite-plugins/native.ts +14 -5
- package/src/vite-plugins/react-compiler.ts +44 -30
- package/src/vite-plugins/react-dom-prebundle.ts +4 -1
- package/src/vite-plugins/resource-init-module.ts +41 -38
- package/src/vite-plugins/resource-shared.ts +27 -14
- package/src/vite-plugins/resources.ts +153 -59
- package/src/vite-plugins/settings-worker-env.ts +7 -2
- package/src/vite-plugins/settings.ts +107 -42
- package/src/vite-plugins/strip-query.ts +7 -0
- package/src/vite-plugins/undeclared-library.ts +21 -12
- package/src/vite-plugins/virtual-module.ts +9 -2
- package/src/vitest-plugin.ts +1 -2
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const renderAssetUrl = (
|
|
4
|
+
filename: string,
|
|
5
|
+
type: string,
|
|
6
|
+
assetBase: string | undefined,
|
|
7
|
+
): { runtime: string } | undefined => {
|
|
8
|
+
if (type !== "asset") {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (assetBase) {
|
|
13
|
+
const executableDir = "require(\"path\").dirname(process.execPath)";
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
runtime:
|
|
17
|
+
`require("path").join(${executableDir},` +
|
|
18
|
+
`${JSON.stringify(assetBase)},${JSON.stringify(filename)})`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const filenameLiteral = JSON.stringify(`./${filename}`);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
runtime: `new URL(${filenameLiteral}, import.meta.url).pathname`,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function gtkxBuiltUrl(assetBase?: string): Plugin {
|
|
4
30
|
return {
|
|
5
31
|
name: "gtkx:built-url",
|
|
6
32
|
apply: "build",
|
|
@@ -13,23 +39,12 @@ export function gtkxBuiltUrl(assetBase?: string): Plugin {
|
|
|
13
39
|
return {
|
|
14
40
|
experimental: {
|
|
15
41
|
renderBuiltUrl(filename, { type }) {
|
|
16
|
-
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (assetBase) {
|
|
21
|
-
return {
|
|
22
|
-
runtime: `require("path").join(require("path").dirname(process.execPath),${JSON.stringify(assetBase)},${JSON.stringify(filename)})`,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const filenameLiteral = JSON.stringify(`./${filename}`);
|
|
27
|
-
return {
|
|
28
|
-
runtime: `new URL(${filenameLiteral}, import.meta.url).pathname`,
|
|
29
|
-
};
|
|
42
|
+
return renderAssetUrl(filename, type, assetBase);
|
|
30
43
|
},
|
|
31
44
|
},
|
|
32
45
|
};
|
|
33
46
|
},
|
|
34
47
|
};
|
|
35
48
|
}
|
|
49
|
+
|
|
50
|
+
export { gtkxBuiltUrl };
|
package/src/vite-plugins/css.ts
CHANGED
|
@@ -1,38 +1,53 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
1
|
import type { Plugin } from "vite";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
3
|
import { createVirtualNamespace } from "./virtual-module.js";
|
|
4
4
|
|
|
5
|
+
type CssResolveContext = Parameters<typeof resolveToVirtual>[0];
|
|
6
|
+
type CssResolveRequest = Parameters<typeof resolveToVirtual>[1];
|
|
7
|
+
|
|
5
8
|
const CSS_RE = /\.css$/i;
|
|
6
9
|
const INJECT_SUFFIX = "?inject";
|
|
7
10
|
const VIRTUAL_PREFIX = "\0gtkx-css:";
|
|
8
11
|
const { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
const resolveCssId = async (ctx: CssResolveContext, request: CssResolveRequest): Promise<string | undefined> => {
|
|
14
|
+
if (!CSS_RE.test(request.source)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const virtualId = await resolveToVirtual(ctx, request);
|
|
19
|
+
|
|
20
|
+
if (virtualId === undefined) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return virtualId + INJECT_SUFFIX;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const loadInjectedCss = (id: string): string | undefined => {
|
|
28
|
+
if (!isVirtual(id) || !id.endsWith(INJECT_SUFFIX)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const filePath = fromVirtualId(id.slice(0, -INJECT_SUFFIX.length));
|
|
33
|
+
const content = readFileSync(filePath, "utf8");
|
|
34
|
+
|
|
35
|
+
return ["import { injectGlobal } from \"@gtkx/css\";", `injectGlobal(${JSON.stringify(content)});`].join("\n");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function gtkxCss(): Plugin {
|
|
11
39
|
return {
|
|
12
40
|
name: "gtkx:css",
|
|
13
41
|
enforce: "pre",
|
|
14
42
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const virtualId = await resolveToVirtual(this, { source, importer, options });
|
|
21
|
-
if (virtualId === undefined) return;
|
|
22
|
-
|
|
23
|
-
return virtualId + INJECT_SUFFIX;
|
|
43
|
+
resolveId(source, importer, options) {
|
|
44
|
+
return resolveCssId(this, { source, importer, options });
|
|
24
45
|
},
|
|
25
46
|
|
|
26
47
|
load(id) {
|
|
27
|
-
|
|
28
|
-
const filePath = fromVirtualId(id.slice(0, -INJECT_SUFFIX.length));
|
|
29
|
-
const content = readFileSync(filePath, "utf-8");
|
|
30
|
-
return [`import { injectGlobal } from "@gtkx/css";`, `injectGlobal(${JSON.stringify(content)});`].join(
|
|
31
|
-
"\n",
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return;
|
|
48
|
+
return loadInjectedCss(id);
|
|
36
49
|
},
|
|
37
50
|
};
|
|
38
51
|
}
|
|
52
|
+
|
|
53
|
+
export { gtkxCss };
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const REFRESH_RUNTIME_SPECIFIER = "@gtkx/cli/refresh-runtime";
|
|
6
|
-
|
|
1
|
+
const REFRESH_REG = "$RefreshReg$";
|
|
2
|
+
const REFRESH_SIG = "$RefreshSig$";
|
|
3
|
+
const REFRESH_RUNTIME_SPECIFIER = "@gtkx/cli/refresh-runtime";
|
|
7
4
|
const REFRESH_INCLUDE = /\.[tj]sx?$/;
|
|
8
5
|
const REFRESH_EXCLUDE = /node_modules|[/\\]dist[/\\]|[/\\]\.gtkx[/\\]/;
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
const shouldTransformForRefresh = (
|
|
11
8
|
id: string,
|
|
12
9
|
transformOptions: { ssr?: boolean | undefined } | undefined,
|
|
13
10
|
): boolean => {
|
|
14
|
-
if (!transformOptions?.ssr)
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
if (!transformOptions?.ssr) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!REFRESH_INCLUDE.test(id)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (REFRESH_EXCLUDE.test(id)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
return true;
|
|
18
24
|
};
|
|
25
|
+
|
|
26
|
+
export { REFRESH_REG, REFRESH_SIG, REFRESH_RUNTIME_SPECIFIER, shouldTransformForRefresh };
|
|
@@ -1,9 +1,55 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { type Options as SwcOptions, transform } from "@swc/core";
|
|
3
1
|
import type { Plugin } from "vite";
|
|
2
|
+
import { type Output, type Options as SwcOptions, transform } from "@swc/core";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { REFRESH_REG, REFRESH_RUNTIME_SPECIFIER, REFRESH_SIG, shouldTransformForRefresh } from "./refresh-filter.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const buildSwcOptions = (id: string): SwcOptions => {
|
|
7
|
+
const isTsx = id.endsWith(".tsx");
|
|
8
|
+
const isTs = id.endsWith(".ts") || isTsx;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
filename: id,
|
|
12
|
+
sourceFileName: id,
|
|
13
|
+
sourceMaps: true,
|
|
14
|
+
jsc: {
|
|
15
|
+
parser: isTs ? { syntax: "typescript", tsx: isTsx } : { syntax: "ecmascript", jsx: true },
|
|
16
|
+
transform: {
|
|
17
|
+
react: {
|
|
18
|
+
runtime: "automatic",
|
|
19
|
+
development: true,
|
|
20
|
+
refresh: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
target: "es2022",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const buildRefreshResult = (result: Output): { code: string; map?: string } =>
|
|
29
|
+
result.map === undefined ? { code: result.code } : { code: result.code, map: result.map };
|
|
30
|
+
|
|
31
|
+
const injectRefreshRegistration = (
|
|
32
|
+
code: string,
|
|
33
|
+
id: string,
|
|
34
|
+
transformOptions: { ssr?: boolean | undefined } | undefined,
|
|
35
|
+
): { code: string; map: null } | undefined => {
|
|
36
|
+
if (!shouldTransformForRefresh(id, transformOptions)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!code.includes(REFRESH_REG) && !code.includes(REFRESH_SIG)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const header = `
|
|
45
|
+
import { createModuleRegistration as __createModuleRegistration__ } from "${REFRESH_RUNTIME_SPECIFIER}";
|
|
46
|
+
const { ${REFRESH_REG}, ${REFRESH_SIG} } = __createModuleRegistration__(${JSON.stringify(id)});
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
return { code: header + code, map: null };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function gtkxSwcRefresh(): Plugin {
|
|
7
53
|
return {
|
|
8
54
|
name: "gtkx:swc-refresh",
|
|
9
55
|
enforce: "pre",
|
|
@@ -14,66 +60,33 @@ export function gtkxSwcRefresh(): Plugin {
|
|
|
14
60
|
return;
|
|
15
61
|
}
|
|
16
62
|
|
|
17
|
-
const
|
|
18
|
-
const isTs = id.endsWith(".ts") || isTsx;
|
|
19
|
-
|
|
20
|
-
const swcOptions: SwcOptions = {
|
|
21
|
-
filename: id,
|
|
22
|
-
sourceFileName: id,
|
|
23
|
-
sourceMaps: true,
|
|
24
|
-
jsc: {
|
|
25
|
-
parser: isTs ? { syntax: "typescript", tsx: isTsx } : { syntax: "ecmascript", jsx: true },
|
|
26
|
-
transform: {
|
|
27
|
-
react: {
|
|
28
|
-
runtime: "automatic",
|
|
29
|
-
development: true,
|
|
30
|
-
refresh: true,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
target: "es2022",
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const result = await transform(code, swcOptions);
|
|
63
|
+
const result = await transform(code, buildSwcOptions(id));
|
|
38
64
|
|
|
39
|
-
return result
|
|
65
|
+
return buildRefreshResult(result);
|
|
40
66
|
},
|
|
41
67
|
};
|
|
42
68
|
}
|
|
43
69
|
|
|
44
|
-
|
|
70
|
+
function gtkxRefreshRuntime(): Plugin {
|
|
45
71
|
return {
|
|
46
72
|
name: "gtkx:refresh-runtime",
|
|
47
73
|
enforce: "post",
|
|
48
74
|
apply: "serve",
|
|
49
75
|
|
|
50
76
|
resolveId(id) {
|
|
51
|
-
if (id !== REFRESH_RUNTIME_SPECIFIER)
|
|
52
|
-
return fileURLToPath(import.meta.resolve(REFRESH_RUNTIME_SPECIFIER));
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
transform(code, id, transformOptions) {
|
|
56
|
-
if (!shouldTransformForRefresh(id, transformOptions)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!code.includes(REFRESH_REG) && !code.includes(REFRESH_SIG)) {
|
|
77
|
+
if (id !== REFRESH_RUNTIME_SPECIFIER) {
|
|
61
78
|
return;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const header = `
|
|
67
|
-
import { createModuleRegistration as __createModuleRegistration__ } from "${REFRESH_RUNTIME_SPECIFIER}";
|
|
68
|
-
const { ${REFRESH_REG}, ${REFRESH_SIG} } = __createModuleRegistration__(${moduleIdJson});
|
|
69
|
-
`;
|
|
81
|
+
return fileURLToPath(import.meta.resolve(REFRESH_RUNTIME_SPECIFIER));
|
|
82
|
+
},
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
map: null,
|
|
74
|
-
};
|
|
84
|
+
transform(code, id, transformOptions) {
|
|
85
|
+
return injectRefreshRegistration(code, id, transformOptions);
|
|
75
86
|
},
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
const gtkxFastRefresh = (): Plugin[] => [gtkxSwcRefresh(), gtkxRefreshRuntime()];
|
|
91
|
+
|
|
92
|
+
export { gtkxSwcRefresh, gtkxRefreshRuntime, gtkxFastRefresh };
|
|
@@ -1,28 +1,49 @@
|
|
|
1
|
+
import type { Plugin, UserConfig } from "vite";
|
|
2
|
+
import { info } from "@gtkx/utils";
|
|
1
3
|
import { readFileSync } from "node:fs";
|
|
2
4
|
import { join } from "node:path";
|
|
3
|
-
import { info } from "@gtkx/utils";
|
|
4
|
-
import type { Plugin, UserConfig } from "vite";
|
|
5
5
|
import { prependBanner } from "../internal/banner.js";
|
|
6
6
|
import { resolveDataDir } from "../internal/data-dir.js";
|
|
7
7
|
import { type ListedFile, listFilesRecursive } from "../internal/list-files.js";
|
|
8
8
|
|
|
9
|
+
type PluginState = {
|
|
10
|
+
iconsDir: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type PluginContext = {
|
|
14
|
+
emitFile: (file: { type: "asset"; fileName: string; source: Buffer }) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
9
17
|
const ICONS_DIR = "icons";
|
|
10
18
|
|
|
11
19
|
const XDG_ENV_BANNER = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
"process.env.XDG_DATA_DIRS = [",
|
|
21
|
+
" decodeURIComponent(new URL(\".\", import.meta.url).pathname),",
|
|
22
|
+
" process.env.XDG_DATA_DIRS || \"/usr/local/share:/usr/share\",",
|
|
23
|
+
"].join(\":\");",
|
|
16
24
|
].join("\n");
|
|
17
25
|
|
|
18
|
-
type PluginState = {
|
|
19
|
-
iconsDir: string | null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
26
|
const findIconFiles = (iconsDir: string | null): ListedFile[] =>
|
|
23
27
|
iconsDir === null ? [] : listFilesRecursive(iconsDir);
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
const resolveIconsDir = (config: UserConfig): string | null => {
|
|
30
|
+
const root = config.root ?? process.cwd();
|
|
31
|
+
const dataDir = resolveDataDir(root);
|
|
32
|
+
|
|
33
|
+
return dataDir === null ? null : join(root, dataDir, ICONS_DIR);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const emitIcons = (ctx: PluginContext, icons: ListedFile[]): void => {
|
|
37
|
+
for (const { absPath, rel } of icons) {
|
|
38
|
+
ctx.emitFile({ type: "asset", fileName: join(ICONS_DIR, rel), source: readFileSync(absPath) });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (icons.length > 0) {
|
|
42
|
+
info(`Copied ${String(icons.length)} icon(s) into ${ICONS_DIR}/`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function gtkxIcons(): Plugin {
|
|
26
47
|
const state: PluginState = {
|
|
27
48
|
iconsDir: null,
|
|
28
49
|
};
|
|
@@ -33,26 +54,21 @@ export function gtkxIcons(): Plugin {
|
|
|
33
54
|
apply: "build",
|
|
34
55
|
|
|
35
56
|
config(config: UserConfig) {
|
|
36
|
-
|
|
37
|
-
const dataDir = resolveDataDir(root);
|
|
38
|
-
state.iconsDir = dataDir === null ? null : join(root, dataDir, ICONS_DIR);
|
|
57
|
+
state.iconsDir = resolveIconsDir(config);
|
|
39
58
|
},
|
|
40
59
|
|
|
41
60
|
outputOptions(options) {
|
|
42
|
-
if (findIconFiles(state.iconsDir).length === 0)
|
|
61
|
+
if (findIconFiles(state.iconsDir).length === 0) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
return prependBanner(options, XDG_ENV_BANNER);
|
|
44
66
|
},
|
|
45
67
|
|
|
46
68
|
buildEnd() {
|
|
47
|
-
|
|
48
|
-
for (const { absPath, rel } of icons) {
|
|
49
|
-
this.emitFile({
|
|
50
|
-
type: "asset",
|
|
51
|
-
fileName: join(ICONS_DIR, rel),
|
|
52
|
-
source: readFileSync(absPath),
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (icons.length > 0) info(`Copied ${icons.length} icon(s) into ${ICONS_DIR}/`);
|
|
69
|
+
emitIcons(this, findIconFiles(state.iconsDir));
|
|
56
70
|
},
|
|
57
71
|
};
|
|
58
72
|
}
|
|
73
|
+
|
|
74
|
+
export { gtkxIcons };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
1
2
|
import { createConfigLoader } from "@gtkx/config/internal";
|
|
2
3
|
import createConfigPlugin from "@gtkx/config/vite-plugin";
|
|
3
|
-
import type { Plugin } from "vite";
|
|
4
4
|
import { gtkxCss } from "./css.js";
|
|
5
5
|
import { gtkxIcons } from "./icons.js";
|
|
6
6
|
import { gtkxReactCompiler } from "./react-compiler.js";
|
|
@@ -8,8 +8,9 @@ import { gtkxResources } from "./resources.js";
|
|
|
8
8
|
import { gtkxSettings } from "./settings.js";
|
|
9
9
|
import { gtkxUndeclaredLibrary } from "./undeclared-library.js";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const loadConfig = createConfigLoader(mode
|
|
11
|
+
const gtkxVitePlugins = (mode?: string): Plugin[] => {
|
|
12
|
+
const loadConfig = createConfigLoader(mode === undefined ? {} : { mode });
|
|
13
|
+
|
|
13
14
|
return [
|
|
14
15
|
createConfigPlugin({ name: "gtkx:config", loadConfig }),
|
|
15
16
|
gtkxUndeclaredLibrary(mode),
|
|
@@ -20,3 +21,5 @@ export const gtkxVitePlugins = (mode?: string): Plugin[] => {
|
|
|
20
21
|
gtkxReactCompiler(loadConfig),
|
|
21
22
|
];
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export { gtkxVitePlugins };
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { arch, platform } from "node:os";
|
|
4
5
|
import { dirname, join } from "node:path";
|
|
5
|
-
import
|
|
6
|
+
import { stripQuery } from "./strip-query.js";
|
|
6
7
|
|
|
7
8
|
const EMITTED_BINDING_SPECIFIER = "./gtkx.node";
|
|
8
9
|
|
|
9
10
|
function resolveBinaryPath(projectRequire: ReturnType<typeof createRequire>, currentArch: string): string {
|
|
10
11
|
const nativeRoot = dirname(projectRequire.resolve("@gtkx/native/package.json"));
|
|
11
12
|
const localBinary = join(nativeRoot, `native.linux-${currentArch}-gnu.node`);
|
|
13
|
+
|
|
12
14
|
return existsSync(localBinary) ? localBinary : projectRequire.resolve(`@gtkx/native-linux-${currentArch}-gnu`);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
function resolvePlatformBinary(projectRequire: ReturnType<typeof createRequire>): Buffer {
|
|
16
18
|
const currentPlatform = platform();
|
|
17
|
-
const currentArch = arch();
|
|
18
19
|
|
|
19
20
|
if (currentPlatform !== "linux") {
|
|
20
21
|
throw new Error(`Unsupported build platform: ${currentPlatform}, only Linux is supported`);
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
const currentArch = arch();
|
|
25
|
+
|
|
23
26
|
if (currentArch !== "x64" && currentArch !== "arm64") {
|
|
24
27
|
throw new Error(`Unsupported build architecture: ${currentArch}, only x64 and arm64 are supported`);
|
|
25
28
|
}
|
|
@@ -29,28 +32,32 @@ function resolvePlatformBinary(projectRequire: ReturnType<typeof createRequire>)
|
|
|
29
32
|
|
|
30
33
|
function rewriteLoader(code: string): string {
|
|
31
34
|
const idents: string[] = [];
|
|
35
|
+
|
|
32
36
|
for (const match of code.matchAll(/export\s*\{\s*([A-Za-z0-9_$]+)\s*\}/g)) {
|
|
33
37
|
const ident = match[1];
|
|
38
|
+
|
|
34
39
|
if (ident) {
|
|
35
40
|
idents.push(ident);
|
|
36
41
|
}
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
const bindings = idents.join(", ");
|
|
39
45
|
|
|
40
46
|
return [
|
|
41
|
-
|
|
47
|
+
"import { createRequire as __gtkxCreateRequire } from \"node:module\";",
|
|
42
48
|
`const __gtkxNative = __gtkxCreateRequire(import.meta.url)(${JSON.stringify(EMITTED_BINDING_SPECIFIER)});`,
|
|
43
49
|
`const { ${bindings} } = __gtkxNative;`,
|
|
44
50
|
`export { ${bindings} };`,
|
|
45
51
|
].join("\n");
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
function gtkxNative(root: string): Plugin {
|
|
49
55
|
const projectRequire = createRequire(join(root, "package.json"));
|
|
50
56
|
let cachedLoaderPath: string | undefined;
|
|
51
57
|
|
|
52
58
|
const loaderPath = (): string => {
|
|
53
59
|
cachedLoaderPath ??= join(dirname(projectRequire.resolve("@gtkx/native/package.json")), "index.js");
|
|
60
|
+
|
|
54
61
|
return cachedLoaderPath;
|
|
55
62
|
};
|
|
56
63
|
|
|
@@ -68,7 +75,9 @@ export function gtkxNative(root: string): Plugin {
|
|
|
68
75
|
},
|
|
69
76
|
|
|
70
77
|
transform(code, id) {
|
|
71
|
-
return id
|
|
78
|
+
return stripQuery(id) === loaderPath() ? rewriteLoader(code) : null;
|
|
72
79
|
},
|
|
73
80
|
};
|
|
74
81
|
}
|
|
82
|
+
|
|
83
|
+
export { gtkxNative };
|
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ResolvedReactCompilerOptions } from "@gtkx/config";
|
|
2
|
+
import type { Plugin, ResolvedConfig, UserConfig } from "vite";
|
|
2
3
|
import { transformAsync } from "@babel/core";
|
|
3
4
|
import babelPresetTypescriptNs from "@babel/preset-typescript";
|
|
4
|
-
import type { ResolvedReactCompilerOptions } from "@gtkx/config";
|
|
5
5
|
import { type ConfigLoader, createConfigLoader } from "@gtkx/config/internal";
|
|
6
6
|
import babelPluginReactCompilerNs from "babel-plugin-react-compiler";
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
type ReactCompilerState = {
|
|
9
|
+
root: string;
|
|
10
|
+
options: ResolvedReactCompilerOptions | null;
|
|
11
|
+
};
|
|
8
12
|
|
|
9
13
|
const babelPresetTypescript = babelPresetTypescriptNs.default ?? babelPresetTypescriptNs;
|
|
10
14
|
const babelPluginReactCompiler = babelPluginReactCompilerNs.default ?? babelPluginReactCompilerNs;
|
|
11
|
-
|
|
12
15
|
const SOURCE_EXTENSION = /\.[jt]sx?$/;
|
|
13
16
|
const TYPESCRIPT_EXTENSION = /\.tsx?$/;
|
|
14
|
-
const TYPE_ONLY_EXTENSION = /\.ts$/;
|
|
15
17
|
const NODE_MODULES = /(?:^|\/)node_modules\//;
|
|
16
18
|
|
|
17
|
-
type ReactCompilerState = {
|
|
18
|
-
root: string;
|
|
19
|
-
options: ResolvedReactCompilerOptions | null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
19
|
const isProjectSource = (root: string, id: string): boolean => {
|
|
23
|
-
if (!SOURCE_EXTENSION.test(id))
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (!SOURCE_EXTENSION.test(id)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (NODE_MODULES.test(id)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (root !== "" && !id.startsWith(`${root}/`)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
return true;
|
|
27
33
|
};
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const compileSource = async (code: string, id: string, options: ResolvedReactCompilerOptions) => {
|
|
36
|
+
const result = await transformAsync(code, {
|
|
37
|
+
filename: id,
|
|
38
|
+
babelrc: false,
|
|
39
|
+
configFile: false,
|
|
40
|
+
sourceMaps: true,
|
|
41
|
+
parserOpts: { plugins: id.endsWith(".ts") ? [] : ["jsx"] },
|
|
42
|
+
presets: TYPESCRIPT_EXTENSION.test(id) ? [babelPresetTypescript] : [],
|
|
43
|
+
plugins: [[babelPluginReactCompiler, options]],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (!result?.code) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
|
|
30
54
|
const state: ReactCompilerState = {
|
|
31
55
|
root: "",
|
|
32
56
|
options: null,
|
|
@@ -37,7 +61,8 @@ export function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader(
|
|
|
37
61
|
enforce: "pre",
|
|
38
62
|
|
|
39
63
|
async config(config: UserConfig) {
|
|
40
|
-
|
|
64
|
+
const resolved = await loadConfig(config.root ?? process.cwd());
|
|
65
|
+
state.options = resolved.reactCompiler;
|
|
41
66
|
},
|
|
42
67
|
|
|
43
68
|
configResolved(config: ResolvedConfig) {
|
|
@@ -46,25 +71,14 @@ export function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader(
|
|
|
46
71
|
|
|
47
72
|
async transform(code, id) {
|
|
48
73
|
const options = state.options;
|
|
49
|
-
if (options === null || !isProjectSource(state.root, id)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
74
|
|
|
53
|
-
|
|
54
|
-
filename: id,
|
|
55
|
-
babelrc: false,
|
|
56
|
-
configFile: false,
|
|
57
|
-
sourceMaps: true,
|
|
58
|
-
parserOpts: { plugins: TYPE_ONLY_EXTENSION.test(id) ? [] : ["jsx"] },
|
|
59
|
-
presets: TYPESCRIPT_EXTENSION.test(id) ? [babelPresetTypescript] : [],
|
|
60
|
-
plugins: [[babelPluginReactCompiler, options]],
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (!result?.code) {
|
|
75
|
+
if (options === null || !isProjectSource(state.root, id)) {
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
return
|
|
79
|
+
return compileSource(code, id, options);
|
|
68
80
|
},
|
|
69
81
|
};
|
|
70
82
|
}
|
|
83
|
+
|
|
84
|
+
export { gtkxReactCompiler };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const gtkxReactDomPrebundle = (): Plugin => ({
|
|
4
4
|
name: "gtkx:react-dom-prebundle",
|
|
5
5
|
enforce: "post",
|
|
6
6
|
config(config) {
|
|
7
7
|
config.optimizeDeps ??= {};
|
|
8
|
+
|
|
8
9
|
if (config.optimizeDeps.include) {
|
|
9
10
|
config.optimizeDeps.include = config.optimizeDeps.include.filter(
|
|
10
11
|
(dep) => dep !== "react-dom" && !dep.startsWith("react-dom/"),
|
|
@@ -12,3 +13,5 @@ export const gtkxReactDomPrebundle = (): Plugin => ({
|
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
});
|
|
16
|
+
|
|
17
|
+
export { gtkxReactDomPrebundle };
|