xanix 1.0.13 → 1.0.15
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/bin/bundler/buildServer.js +1 -1
- package/dist/bin/bundler/cacheNpmModules.js +5 -31
- package/dist/bin/bundler/generateClientEntries.d.ts +3 -1
- package/dist/bin/bundler/generateClientEntries.js +7 -33
- package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +1 -1
- package/dist/bin/bundler/plugins/XanixReactRefresh.js +2 -2
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.js +4 -6
- package/dist/bin/bundler/plugins/plugins.d.ts +2 -1
- package/dist/bin/bundler/plugins/plugins.js +3 -3
- package/dist/bin/bundler/watchClient.d.ts +1 -0
- package/dist/bin/bundler/watchClient.js +1 -0
- package/dist/bin/bundler/watchServer.js +2 -2
- package/dist/bin/cli/dev.js +4 -1
- package/dist/bin/include/utils.d.ts +1 -0
- package/dist/bin/include/utils.js +3 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +10 -0
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ const BuildServer = async ({ rootEntry, onBuildEnd }) => {
|
|
|
15
15
|
fs.mkdirSync(outdirs.server, {
|
|
16
16
|
recursive: true,
|
|
17
17
|
});
|
|
18
|
-
const entries = await generateClientEntries();
|
|
18
|
+
const entries = await generateClientEntries({ rootEntry });
|
|
19
19
|
await createManifest(entries);
|
|
20
20
|
const input = {
|
|
21
21
|
index: path.resolve(root, rootEntry),
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { rollup } from "rollup";
|
|
3
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
3
|
import { build } from "esbuild";
|
|
5
4
|
import { createRequire } from "node:module";
|
|
6
5
|
import { getClientRuntimeFile } from "../include/utils.js";
|
|
7
|
-
import esbuild from "rollup-plugin-esbuild";
|
|
8
|
-
import url from "@rollup/plugin-url";
|
|
9
|
-
import XanixDocument from "./plugins/XanixDocument/index.js";
|
|
10
6
|
import outdirs from "../../outdirs.js";
|
|
7
|
+
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
11
8
|
const require = createRequire(import.meta.url);
|
|
12
9
|
const GenerateGraph = async (entries) => {
|
|
13
10
|
const collector = new Map();
|
|
@@ -19,33 +16,10 @@ const GenerateGraph = async (entries) => {
|
|
|
19
16
|
const bundle = await rollup({
|
|
20
17
|
input,
|
|
21
18
|
plugins: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
include: [
|
|
27
|
-
"**/*.jpg",
|
|
28
|
-
"**/*.jpeg",
|
|
29
|
-
"**/*.png",
|
|
30
|
-
"**/*.gif",
|
|
31
|
-
"**/*.webp",
|
|
32
|
-
"**/*.svg",
|
|
33
|
-
"**/*.ico",
|
|
34
|
-
"**/*.woff",
|
|
35
|
-
"**/*.woff2",
|
|
36
|
-
"**/*.ttf",
|
|
37
|
-
"**/*.eot",
|
|
38
|
-
"**/*.css",
|
|
39
|
-
],
|
|
40
|
-
limit: 0,
|
|
41
|
-
fileName: "assets/[name]-[hash][extname]",
|
|
42
|
-
emitFiles: false,
|
|
43
|
-
}),
|
|
44
|
-
XanixDocument(),
|
|
45
|
-
esbuild({
|
|
46
|
-
target: "es2022",
|
|
47
|
-
jsx: "automatic",
|
|
48
|
-
tsconfig: false,
|
|
19
|
+
...xanixDefaultPlugins({
|
|
20
|
+
target: "client",
|
|
21
|
+
development: true,
|
|
22
|
+
assetExternal: true,
|
|
49
23
|
}),
|
|
50
24
|
],
|
|
51
25
|
external(id) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type XanixClientEntry } from "../types.js";
|
|
2
|
-
declare const generateClientEntries: (
|
|
2
|
+
declare const generateClientEntries: ({ rootEntry, }: {
|
|
3
|
+
rootEntry: string;
|
|
4
|
+
}) => Promise<XanixClientEntry[]>;
|
|
3
5
|
export default generateClientEntries;
|
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
import { rollup } from "rollup";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { XanixEntryFinder } from "./plugins/XanixEntryFinder/index.js";
|
|
4
|
-
import
|
|
5
|
-
import esbuild from "rollup-plugin-esbuild";
|
|
6
|
-
import XanixTsconfigAlias from "./plugins/XanixTsconfigAlias.js";
|
|
7
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
4
|
+
import { xanixDefaultPlugins } from "./plugins/plugins.js";
|
|
8
5
|
const root = process.cwd();
|
|
9
|
-
const generateClientEntries = async () => {
|
|
6
|
+
const generateClientEntries = async ({ rootEntry, }) => {
|
|
10
7
|
const entries = new Map();
|
|
11
8
|
const bundle = await rollup({
|
|
12
|
-
input: path.resolve(root,
|
|
9
|
+
input: path.resolve(root, rootEntry),
|
|
13
10
|
plugins: [
|
|
14
|
-
XanixTsconfigAlias(),
|
|
15
|
-
nodeResolve({
|
|
16
|
-
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
17
|
-
}),
|
|
18
11
|
XanixEntryFinder({
|
|
19
12
|
entries,
|
|
20
13
|
}),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"**/*.png",
|
|
26
|
-
"**/*.gif",
|
|
27
|
-
"**/*.webp",
|
|
28
|
-
"**/*.svg",
|
|
29
|
-
"**/*.ico",
|
|
30
|
-
"**/*.woff",
|
|
31
|
-
"**/*.woff2",
|
|
32
|
-
"**/*.ttf",
|
|
33
|
-
"**/*.eot",
|
|
34
|
-
"**/*.css",
|
|
35
|
-
],
|
|
36
|
-
limit: 0,
|
|
37
|
-
fileName: "assets/[name]-[hash][extname]",
|
|
38
|
-
emitFiles: true,
|
|
39
|
-
}),
|
|
40
|
-
esbuild({
|
|
41
|
-
target: "es2022",
|
|
42
|
-
jsx: "automatic",
|
|
43
|
-
tsconfig: false,
|
|
14
|
+
...xanixDefaultPlugins({
|
|
15
|
+
target: "server",
|
|
16
|
+
development: true,
|
|
17
|
+
assetExternal: true,
|
|
44
18
|
}),
|
|
45
19
|
],
|
|
46
20
|
external(id) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Plugin } from "rollup";
|
|
2
|
-
export default function xanixReactRefresh(): Plugin;
|
|
2
|
+
export default function xanixReactRefresh(WebSocketPort: number): Plugin;
|
|
@@ -6,7 +6,7 @@ import generate from "@babel/generator";
|
|
|
6
6
|
import * as t from "@babel/types";
|
|
7
7
|
import { getClientRuntimeFile } from "../../include/utils.js";
|
|
8
8
|
const root = process.cwd();
|
|
9
|
-
export default function xanixReactRefresh() {
|
|
9
|
+
export default function xanixReactRefresh(WebSocketPort) {
|
|
10
10
|
return {
|
|
11
11
|
name: "xanix-react-refresh",
|
|
12
12
|
load(id) {
|
|
@@ -22,7 +22,7 @@ ${code}
|
|
|
22
22
|
RefreshRuntime.injectIntoGlobalHook(window);
|
|
23
23
|
window.$RefreshReg$ = RefreshRuntime.register;
|
|
24
24
|
window.$RefreshSig$ = () => (type) => type;
|
|
25
|
-
const ws = new WebSocket("ws://localhost:
|
|
25
|
+
const ws = new WebSocket("ws://localhost:" + ${WebSocketPort});
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
ws.onmessage = async (event) => {
|
|
@@ -12,8 +12,7 @@ export default function xanixTsconfigAlias() {
|
|
|
12
12
|
}
|
|
13
13
|
const result = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
14
14
|
if (result.error) {
|
|
15
|
-
|
|
16
|
-
throw new Error(`[xanix] Failed to read tsconfig.json:\n${message}`);
|
|
15
|
+
throw new Error(`[xanix] Failed to read tsconfig.json:\n${ts.flattenDiagnosticMessageText(result.error.messageText, "\n")}`);
|
|
17
16
|
}
|
|
18
17
|
const config = result.config;
|
|
19
18
|
const compilerOptions = config.compilerOptions ?? {};
|
|
@@ -25,7 +24,6 @@ export default function xanixTsconfigAlias() {
|
|
|
25
24
|
const replacement = replacements?.[0];
|
|
26
25
|
if (!replacement)
|
|
27
26
|
return null;
|
|
28
|
-
// @components/*
|
|
29
27
|
if (find.endsWith("/*")) {
|
|
30
28
|
const findPrefix = find.slice(0, -2);
|
|
31
29
|
const replacementPrefix = replacement.endsWith("/*")
|
|
@@ -33,17 +31,17 @@ export default function xanixTsconfigAlias() {
|
|
|
33
31
|
: replacement;
|
|
34
32
|
return {
|
|
35
33
|
find: new RegExp(`^${escapeRegExp(findPrefix)}/(.+)$`),
|
|
36
|
-
replacement:
|
|
34
|
+
replacement: path.resolve(basePath, replacementPrefix) + "/$1",
|
|
37
35
|
};
|
|
38
36
|
}
|
|
39
|
-
// @foo
|
|
40
37
|
return {
|
|
41
38
|
find,
|
|
42
39
|
replacement: path.resolve(basePath, replacement),
|
|
43
40
|
};
|
|
44
41
|
})
|
|
45
|
-
.filter(
|
|
42
|
+
.filter(Boolean);
|
|
46
43
|
return alias({
|
|
44
|
+
customResolver: undefined,
|
|
47
45
|
entries,
|
|
48
46
|
});
|
|
49
47
|
}
|
|
@@ -4,5 +4,6 @@ export interface XanixRollupOptions {
|
|
|
4
4
|
development?: boolean;
|
|
5
5
|
assetExternal?: boolean;
|
|
6
6
|
onChange?: (entry: string, event?: string) => void;
|
|
7
|
+
WebSocketPort?: number;
|
|
7
8
|
}
|
|
8
|
-
export declare function xanixDefaultPlugins(options
|
|
9
|
+
export declare function xanixDefaultPlugins(options: XanixRollupOptions): Plugin[];
|
|
@@ -11,7 +11,7 @@ import xanixReactRefresh from "./XanixReactRefresh.js";
|
|
|
11
11
|
import XanixEnvPlugin from "./XanixEnv.js";
|
|
12
12
|
import xanixUseDataId from "./xanixUseDataId.js";
|
|
13
13
|
import XanixServerTransform from "./XanixServerTransform.js";
|
|
14
|
-
export function xanixDefaultPlugins(options
|
|
14
|
+
export function xanixDefaultPlugins(options) {
|
|
15
15
|
const target = options.target ?? "client";
|
|
16
16
|
const development = options.development ?? true;
|
|
17
17
|
const isClient = target === "client";
|
|
@@ -23,10 +23,11 @@ export function xanixDefaultPlugins(options = {}) {
|
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
if (development) {
|
|
26
|
-
_plugins.push(xanixReactRefresh());
|
|
26
|
+
_plugins.push(xanixReactRefresh(options.WebSocketPort));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return [
|
|
30
|
+
XanixTsconfigAlias(),
|
|
30
31
|
{
|
|
31
32
|
name: "watch",
|
|
32
33
|
async watchChange(id, change) {
|
|
@@ -53,7 +54,6 @@ export function xanixDefaultPlugins(options = {}) {
|
|
|
53
54
|
fileName: "assets/[name]-[hash][extname]",
|
|
54
55
|
emitFiles: !(options?.assetExternal ?? false),
|
|
55
56
|
}),
|
|
56
|
-
XanixTsconfigAlias(),
|
|
57
57
|
XanixEnvPlugin({
|
|
58
58
|
mode: development ? "development" : "production",
|
|
59
59
|
isClient,
|
|
@@ -3,6 +3,7 @@ import { XanixClientEntry } from "../types.js";
|
|
|
3
3
|
type Option = {
|
|
4
4
|
onChange?: (entry: string, event?: string) => void;
|
|
5
5
|
onBuildEnd?: () => void;
|
|
6
|
+
WebSocketPort: number;
|
|
6
7
|
};
|
|
7
8
|
declare const WatchClient: (entries: XanixClientEntry[], options: Option) => Promise<RollupWatcher>;
|
|
8
9
|
export default WatchClient;
|
|
@@ -16,7 +16,7 @@ const watchServer = async ({ rootEntry, onChange, onBuildEnd, onServerChange, on
|
|
|
16
16
|
fs.mkdirSync(outdirs.server, {
|
|
17
17
|
recursive: true,
|
|
18
18
|
});
|
|
19
|
-
const entries = await generateClientEntries();
|
|
19
|
+
const entries = await generateClientEntries({ rootEntry });
|
|
20
20
|
await createManifest(entries);
|
|
21
21
|
const input = {
|
|
22
22
|
index: path.resolve(root, rootEntry),
|
|
@@ -62,7 +62,7 @@ const watchServer = async ({ rootEntry, onChange, onBuildEnd, onServerChange, on
|
|
|
62
62
|
for (const entry of changedFiles) {
|
|
63
63
|
const isClientEntry = Array.from(manifest.entries.values()).find((e) => e.file === entry);
|
|
64
64
|
if (!isClientEntry) {
|
|
65
|
-
const entries = await generateClientEntries();
|
|
65
|
+
const entries = await generateClientEntries({ rootEntry });
|
|
66
66
|
const isEqual = await entriesEqual(entries);
|
|
67
67
|
if (!isEqual) {
|
|
68
68
|
await createManifest(entries);
|
package/dist/bin/cli/dev.js
CHANGED
|
@@ -7,6 +7,7 @@ import logger from "../include/logger.js";
|
|
|
7
7
|
import { getEntries } from "../include/entry.js";
|
|
8
8
|
import { WebSocketServer } from "ws";
|
|
9
9
|
import outdirs from "../../outdirs.js";
|
|
10
|
+
import { getWebSocketPort } from "../include/utils.js";
|
|
10
11
|
const root = process.cwd();
|
|
11
12
|
let child;
|
|
12
13
|
function start() {
|
|
@@ -20,8 +21,9 @@ function start() {
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
const dev = async (rootEntry) => {
|
|
24
|
+
const WebSocketPort = getWebSocketPort();
|
|
23
25
|
const wss = new WebSocketServer({
|
|
24
|
-
port:
|
|
26
|
+
port: WebSocketPort,
|
|
25
27
|
});
|
|
26
28
|
let sockets = new Set();
|
|
27
29
|
const broadcast = (message) => {
|
|
@@ -51,6 +53,7 @@ const dev = async (rootEntry) => {
|
|
|
51
53
|
let changedFiles = new Set();
|
|
52
54
|
_clientWatcher?.close();
|
|
53
55
|
_clientWatcher = await watchClient(entries, {
|
|
56
|
+
WebSocketPort,
|
|
54
57
|
onChange: (entry) => {
|
|
55
58
|
const _entry = entries.find((e) => e.file === entry);
|
|
56
59
|
let buildFile = _entry
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function uid(value: string, length?: number): string;
|
|
2
2
|
export declare const getClientRuntimeFile: () => string;
|
|
3
3
|
export declare const getClientRuntimeFileName: (mode: "development" | "production") => string;
|
|
4
|
+
export declare function getWebSocketPort(): number;
|
package/dist/theme.d.ts
ADDED
package/dist/theme.js
ADDED