@cmmn/tools 2.2.3 → 3.0.0-alpha-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/.swcrc +20 -0
- package/dist/bundle/index.js +913 -0
- package/dist/bundle/test.js +32 -0
- package/dist/esm/bin.js +9 -0
- package/dist/esm/bin.js.map +1 -0
- package/dist/esm/bundlers/createBundler.js +9 -0
- package/dist/esm/bundlers/createBundler.js.map +1 -0
- package/dist/esm/bundlers/plugins/minify.js +34 -0
- package/dist/esm/bundlers/plugins/minify.js.map +1 -0
- package/dist/esm/bundlers/plugins/wasm.js +43 -0
- package/dist/esm/bundlers/plugins/wasm.js.map +1 -0
- package/dist/esm/bundlers/rolldown-bundler.js +153 -0
- package/dist/esm/bundlers/rolldown-bundler.js.map +1 -0
- package/dist/esm/bundlers/types.js +3 -0
- package/dist/esm/bundlers/types.js.map +1 -0
- package/dist/esm/bundlers/vite.builder.js +117 -0
- package/dist/esm/bundlers/vite.builder.js.map +1 -0
- package/dist/esm/bundlers/vite.bundler.js +56 -0
- package/dist/esm/bundlers/vite.bundler.js.map +1 -0
- package/dist/esm/commands/bundle.js +102 -0
- package/dist/esm/commands/bundle.js.map +1 -0
- package/dist/esm/commands/cert.js +26 -0
- package/dist/esm/commands/cert.js.map +1 -0
- package/dist/esm/commands/ci.js +14 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/clean.js +18 -0
- package/dist/esm/commands/clean.js.map +1 -0
- package/dist/esm/commands/compile.js +60 -0
- package/dist/esm/commands/compile.js.map +1 -0
- package/dist/esm/commands/deploy.js +61 -0
- package/dist/esm/commands/deploy.js.map +1 -0
- package/dist/esm/commands/dev.js +37 -0
- package/dist/esm/commands/dev.js.map +1 -0
- package/dist/esm/commands/format.js +44 -0
- package/dist/esm/commands/format.js.map +1 -0
- package/dist/esm/commands/gen.js +36 -0
- package/dist/esm/commands/gen.js.map +1 -0
- package/dist/esm/commands/host.js +21 -0
- package/dist/esm/commands/host.js.map +1 -0
- package/dist/esm/commands/index.js +12 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/commands/lint.js +45 -0
- package/dist/esm/commands/lint.js.map +1 -0
- package/dist/esm/commands/nginx.js +62 -0
- package/dist/esm/commands/nginx.js.map +1 -0
- package/dist/esm/commands/publish.js +37 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/typings.js +66 -0
- package/dist/esm/commands/typings.js.map +1 -0
- package/dist/esm/commands/version.js +34 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/dev-server/asset-collection.js +18 -0
- package/dist/esm/dev-server/asset-collection.js.map +1 -0
- package/dist/esm/dev-server/bundle.json.builder.js +47 -0
- package/dist/esm/dev-server/bundle.json.builder.js.map +1 -0
- package/dist/esm/dev-server/dependencyServer.js +96 -0
- package/dist/esm/dev-server/dependencyServer.js.map +1 -0
- package/dist/esm/dev-server/dev-server.js +49 -0
- package/dist/esm/dev-server/dev-server.js.map +1 -0
- package/dist/esm/dev-server/plugins/minify.js +34 -0
- package/dist/esm/dev-server/plugins/minify.js.map +1 -0
- package/dist/esm/dev-server/plugins/wasm.js +30 -0
- package/dist/esm/dev-server/plugins/wasm.js.map +1 -0
- package/dist/esm/dev-server/resolver.js +55 -0
- package/dist/esm/dev-server/resolver.js.map +1 -0
- package/dist/esm/dev-server/rolldown-dependency-builder.js +150 -0
- package/dist/esm/dev-server/rolldown-dependency-builder.js.map +1 -0
- package/dist/esm/dev-server/target-runnner.js +72 -0
- package/dist/esm/dev-server/target-runnner.js.map +1 -0
- package/dist/esm/dev-server/target-web-server.js +78 -0
- package/dist/esm/dev-server/target-web-server.js.map +1 -0
- package/dist/esm/dev-server/targetServer.js +29 -0
- package/dist/esm/dev-server/targetServer.js.map +1 -0
- package/dist/esm/dev-server/vite.builder.js +183 -0
- package/dist/esm/dev-server/vite.builder.js.map +1 -0
- package/dist/esm/dev-server/wasm-resolver.js +25 -0
- package/dist/esm/dev-server/wasm-resolver.js.map +1 -0
- package/dist/esm/helpers/fastify-compress.js +26 -0
- package/dist/esm/helpers/fastify-compress.js.map +1 -0
- package/dist/esm/helpers/flags.js +22 -0
- package/dist/esm/helpers/flags.js.map +1 -0
- package/dist/esm/helpers/getProjects.js +49 -0
- package/dist/esm/helpers/getProjects.js.map +1 -0
- package/dist/esm/helpers/getTSConfig.js +32 -0
- package/dist/esm/helpers/getTSConfig.js.map +1 -0
- package/dist/esm/helpers/target.js +230 -0
- package/dist/esm/helpers/target.js.map +1 -0
- package/dist/esm/helpers/terminal.js +117 -0
- package/dist/esm/helpers/terminal.js.map +1 -0
- package/dist/esm/helpers/ts-resolve-plugin.js +139 -0
- package/dist/esm/helpers/ts-resolve-plugin.js.map +1 -0
- package/dist/esm/helpers/watcher.js +35 -0
- package/dist/esm/helpers/watcher.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/model/bundle.js +75 -0
- package/dist/esm/model/bundle.js.map +1 -0
- package/dist/esm/model/flags.js +27 -0
- package/dist/esm/model/flags.js.map +1 -0
- package/dist/esm/model/monorepo.js +74 -0
- package/dist/esm/model/monorepo.js.map +1 -0
- package/dist/esm/model/pack.js +134 -0
- package/dist/esm/model/pack.js.map +1 -0
- package/dist/esm/model/resolver.js +100 -0
- package/dist/esm/model/resolver.js.map +1 -0
- package/dist/esm/model/target.js +111 -0
- package/dist/esm/model/target.js.map +1 -0
- package/dist/esm/servers/bundle-server.js +20 -0
- package/dist/esm/servers/bundle-server.js.map +1 -0
- package/dist/esm/servers/dev-server.js +70 -0
- package/dist/esm/servers/dev-server.js.map +1 -0
- package/dist/esm/servers/pack-server.js +20 -0
- package/dist/esm/servers/pack-server.js.map +1 -0
- package/dist/esm/servers/target-runnner.js +80 -0
- package/dist/esm/servers/target-runnner.js.map +1 -0
- package/dist/esm/servers/vite-dev-server.js +61 -0
- package/dist/esm/servers/vite-dev-server.js.map +1 -0
- package/dist/esm/specs/dependency-builder-specs.js +164 -0
- package/dist/esm/specs/dependency-builder-specs.js.map +1 -0
- package/dist/esm/specs/dev-server.specs.js +73 -0
- package/dist/esm/specs/dev-server.specs.js.map +1 -0
- package/dist/esm/specs/monorepo.specs.js +35 -0
- package/dist/esm/specs/monorepo.specs.js.map +1 -0
- package/dist/esm/specs/resolver.specs.js +57 -0
- package/dist/esm/specs/resolver.specs.js.map +1 -0
- package/dist/esm/specs/rolldown.specs.js +278 -0
- package/dist/esm/specs/rolldown.specs.js.map +1 -0
- package/dist/esm/specs/target-specs.js +108 -0
- package/dist/esm/specs/target-specs.js.map +1 -0
- package/dist/esm/specs/vite-bundler.specs.js +77 -0
- package/dist/esm/specs/vite-bundler.specs.js.map +1 -0
- package/dist/esm/test/test.js +30 -0
- package/dist/esm/test/test.js.map +1 -0
- package/dist/ts.buildinfo +1 -0
- package/dist/typings/bin.d.ts +2 -0
- package/dist/typings/bundlers/plugins/minify.d.ts +6 -0
- package/dist/typings/bundlers/plugins/wasm.d.ts +5 -0
- package/dist/typings/bundlers/rolldown-bundler.d.ts +18 -0
- package/dist/typings/bundlers/types.d.ts +4 -0
- package/dist/typings/bundlers/vite.builder.d.ts +12 -0
- package/dist/typings/bundlers/vite.bundler.d.ts +9 -0
- package/dist/typings/commands/bundle.d.ts +2 -0
- package/dist/typings/commands/cert.d.ts +1 -0
- package/dist/typings/commands/clean.d.ts +2 -0
- package/dist/typings/commands/compile.d.ts +2 -0
- package/dist/typings/commands/dev.d.ts +2 -0
- package/dist/typings/commands/format.d.ts +5 -0
- package/dist/typings/commands/gen.d.ts +1 -0
- package/dist/typings/commands/host.d.ts +1 -0
- package/dist/typings/commands/index.d.ts +10 -0
- package/dist/typings/commands/lint.d.ts +5 -0
- package/dist/typings/commands/nginx.d.ts +6 -0
- package/dist/typings/commands/publish.d.ts +2 -0
- package/dist/typings/commands/typings.d.ts +4 -0
- package/dist/typings/commands/version.d.ts +1 -0
- package/dist/typings/helpers/fastify-compress.d.ts +6 -0
- package/dist/typings/helpers/getTSConfig.d.ts +11 -0
- package/dist/typings/helpers/terminal.d.ts +22 -0
- package/dist/typings/helpers/watcher.d.ts +7 -0
- package/dist/typings/index.d.ts +4 -0
- package/dist/typings/model/bundle.d.ts +34 -0
- package/dist/typings/model/flags.d.ts +15 -0
- package/dist/typings/model/monorepo.d.ts +18 -0
- package/dist/typings/model/pack.d.ts +45 -0
- package/dist/typings/model/resolver.d.ts +38 -0
- package/dist/typings/model/target.d.ts +27 -0
- package/dist/typings/servers/bundle-server.d.ts +10 -0
- package/dist/typings/servers/dev-server.d.ts +16 -0
- package/dist/typings/servers/pack-server.d.ts +9 -0
- package/dist/typings/servers/target-runnner.d.ts +13 -0
- package/dist/typings/servers/vite-dev-server.d.ts +18 -0
- package/dist/typings/specs/dev-server.specs.d.ts +1 -0
- package/dist/typings/specs/monorepo.specs.d.ts +1 -0
- package/dist/typings/specs/resolver.specs.d.ts +1 -0
- package/dist/typings/specs/rolldown.specs.d.ts +1 -0
- package/dist/typings/specs/target-specs.d.ts +1 -0
- package/dist/typings/specs/vite-bundler.specs.d.ts +1 -0
- package/dist/typings/test/test.d.ts +16 -0
- package/{compile → helpers}/tsconfig.json +12 -9
- package/node/hooks-dev.js +72 -0
- package/node/register-dev.js +3 -0
- package/node/register.js +14 -0
- package/package.json +51 -40
- package/readme.md +2 -2
- package/tsconfig.json +14 -0
- package/LICENSE +0 -21
- package/bin.js +0 -21
- package/bundle/bundle.js +0 -46
- package/bundle/esbuild.config.js +0 -178
- package/bundle/getConfigs.js +0 -62
- package/compile/compile.js +0 -53
- package/compile/ts-resolve-plugin.js +0 -235
- package/compile/typings.d.ts +0 -19
- package/gen/component.ts.tpl +0 -16
- package/gen/gen.js +0 -27
- package/gen/style.less.tpl +0 -3
- package/gen/template.ts.tpl +0 -8
- package/helpers/getTSConfig.js +0 -19
- package/serve/readme.md +0 -8
- package/serve/serve.js +0 -109
- package/spawn/index.js +0 -81
- package/test/index.d.ts +0 -18
- package/test/index.js +0 -16
- package/test/jest.config.js +0 -32
- package/test/pathsToModuleNameMapper.js +0 -46
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { compile } from "./compile.ts";
|
|
2
|
+
export { typings } from "./typings.ts";
|
|
3
|
+
export { gen } from "./gen.js";
|
|
4
|
+
export { bundle } from "./bundle.ts";
|
|
5
|
+
export { dev } from "./dev.ts";
|
|
6
|
+
export { publish } from "./publish.ts";
|
|
7
|
+
export { format } from "./format.js";
|
|
8
|
+
export { lint } from "./lint.js";
|
|
9
|
+
export { version } from "./version.js";
|
|
10
|
+
export { host } from "./host.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function version(flags: any): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FastifyInstance } from "fastify";
|
|
2
|
+
export declare function fastifyCompress(app: FastifyInstance, options?: FastifyCompressOptions): void;
|
|
3
|
+
export type FastifyCompressOptions = {
|
|
4
|
+
encodings: FastifyCompressEncoding[];
|
|
5
|
+
};
|
|
6
|
+
export type FastifyCompressEncoding = 'br' | 'zstd' | 'gzip' | 'deflate';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CompilerOptions } from "typescript";
|
|
2
|
+
export declare function getTSConfig(configPath: string): any;
|
|
3
|
+
export type TypescriptConfig = {
|
|
4
|
+
extends?: string;
|
|
5
|
+
compilerOptions?: CompilerOptions;
|
|
6
|
+
exclude?: string[];
|
|
7
|
+
include?: string[];
|
|
8
|
+
references?: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class Terminal {
|
|
2
|
+
constructor(flags: any, targets: any);
|
|
3
|
+
term: any;
|
|
4
|
+
/**
|
|
5
|
+
* @type {import("../model/flags.ts").Flags}
|
|
6
|
+
*/
|
|
7
|
+
flags: import("../model/flags.ts").Flags;
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("../model/target.js").Target[]}
|
|
10
|
+
*/
|
|
11
|
+
targets: import("../model/target.js").Target[];
|
|
12
|
+
headers: string[];
|
|
13
|
+
startTime: number;
|
|
14
|
+
data: {};
|
|
15
|
+
setData(target: any, data: any): void;
|
|
16
|
+
renderInfo(): void;
|
|
17
|
+
renderTable(): void;
|
|
18
|
+
fit(data: any): any;
|
|
19
|
+
getTime(time: any): string;
|
|
20
|
+
getSize(size: any): string;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Entry, Pack } from "./pack";
|
|
2
|
+
export declare class Bundle {
|
|
3
|
+
private pack;
|
|
4
|
+
private output;
|
|
5
|
+
constructor(pack: Pack, output: Output[]);
|
|
6
|
+
fileNames(): string[];
|
|
7
|
+
get(id: string): string | Uint8Array<ArrayBufferLike>;
|
|
8
|
+
getPublicAsset(id: string): Promise<Buffer<ArrayBufferLike>>;
|
|
9
|
+
getBundleJson(): Promise<BundleJson>;
|
|
10
|
+
private getOutputAsset;
|
|
11
|
+
private getDeps;
|
|
12
|
+
}
|
|
13
|
+
export declare function getHash(data: string | Uint8Array): Promise<string>;
|
|
14
|
+
export type Output = {
|
|
15
|
+
entry?: Entry;
|
|
16
|
+
fileName: string;
|
|
17
|
+
data: string | Uint8Array;
|
|
18
|
+
deps: Array<{
|
|
19
|
+
pack: Pack;
|
|
20
|
+
path: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
export type BundleJson = {
|
|
24
|
+
baseURI: string;
|
|
25
|
+
assets: Asset[];
|
|
26
|
+
};
|
|
27
|
+
export type Asset = {
|
|
28
|
+
path: string;
|
|
29
|
+
regex?: string;
|
|
30
|
+
hash: string;
|
|
31
|
+
size: number;
|
|
32
|
+
optional?: boolean;
|
|
33
|
+
deps: Record<string, string[]>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Flags {
|
|
2
|
+
args?: string[];
|
|
3
|
+
static Current: Flags;
|
|
4
|
+
watch?: boolean;
|
|
5
|
+
minify?: boolean;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
unsafe?: boolean;
|
|
8
|
+
version?: string;
|
|
9
|
+
command?: string;
|
|
10
|
+
production?: boolean;
|
|
11
|
+
deploy?: boolean;
|
|
12
|
+
out: string;
|
|
13
|
+
constructor(args?: string[]);
|
|
14
|
+
get(arg: any): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Pack } from "./pack";
|
|
2
|
+
import { Target } from "./target";
|
|
3
|
+
import { Resolver } from "./resolver";
|
|
4
|
+
import { Flags } from "./flags";
|
|
5
|
+
import { ViteBundler } from "../bundlers/vite.bundler";
|
|
6
|
+
import { RolldownBundler } from "../bundlers/rolldown-bundler";
|
|
7
|
+
export declare class Monorepo {
|
|
8
|
+
readonly root: Target;
|
|
9
|
+
private readonly packsMap;
|
|
10
|
+
readonly flags: Flags;
|
|
11
|
+
static load(flags?: Flags, rootDir?: string): Promise<Monorepo>;
|
|
12
|
+
readonly packs: Pack[];
|
|
13
|
+
private constructor();
|
|
14
|
+
get targets(): Target[];
|
|
15
|
+
get(id: string): Pack;
|
|
16
|
+
readonly resolver: Resolver;
|
|
17
|
+
createBundler(pack: Pack): ViteBundler | RolldownBundler;
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package";
|
|
2
|
+
import { Flags } from "./flags";
|
|
3
|
+
export declare class Pack extends EventTarget {
|
|
4
|
+
readonly rootDir: any;
|
|
5
|
+
readonly packageJson: JSONSchemaForNPMPackageJsonFiles;
|
|
6
|
+
static read(id: string, version?: string, dir?: string): Promise<Pack>;
|
|
7
|
+
getAllDependencies(prod: boolean): Generator<[string, string], void, unknown>;
|
|
8
|
+
deps: Pack[];
|
|
9
|
+
reactions: Pack[];
|
|
10
|
+
constructor(rootDir: any, packageJson: JSONSchemaForNPMPackageJsonFiles);
|
|
11
|
+
init(flags: Flags, packsMap: Map<string, Pack>): void;
|
|
12
|
+
get isServer(): boolean;
|
|
13
|
+
get name(): string;
|
|
14
|
+
term: any;
|
|
15
|
+
log(text: any): void;
|
|
16
|
+
error(text: any): void;
|
|
17
|
+
_entries: Entry[];
|
|
18
|
+
get entries(): Entry[];
|
|
19
|
+
/**
|
|
20
|
+
* @param name relative path inside pack: "", "/index.js", "/bundler"...
|
|
21
|
+
*/
|
|
22
|
+
getEntry(name: string): Entry | undefined;
|
|
23
|
+
protected createEntry(name: string, source: string): Entry;
|
|
24
|
+
getExport(entry: string, file: string): string;
|
|
25
|
+
get publicPath(): string;
|
|
26
|
+
}
|
|
27
|
+
export declare class ChangeEvent extends Event {
|
|
28
|
+
payload: any;
|
|
29
|
+
from: any;
|
|
30
|
+
constructor(payload: any, from: any);
|
|
31
|
+
}
|
|
32
|
+
export declare class FileChangeEvent extends Event {
|
|
33
|
+
files: string[];
|
|
34
|
+
constructor(files: string[]);
|
|
35
|
+
}
|
|
36
|
+
export type Entry = {
|
|
37
|
+
name: string;
|
|
38
|
+
source: string;
|
|
39
|
+
relative: string;
|
|
40
|
+
isHTML: boolean;
|
|
41
|
+
isExcluded: boolean;
|
|
42
|
+
output: string;
|
|
43
|
+
isTypeScript: boolean;
|
|
44
|
+
isJavaScript: boolean;
|
|
45
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Pack } from "./pack";
|
|
2
|
+
import { Flags } from "./flags";
|
|
3
|
+
export declare class Resolver {
|
|
4
|
+
private readonly packs;
|
|
5
|
+
private flags;
|
|
6
|
+
basePath: string;
|
|
7
|
+
constructor(packs: Pack[], flags: Flags);
|
|
8
|
+
/**
|
|
9
|
+
* Resolve id to absolute path
|
|
10
|
+
* @param id - relative path: "react", "react/jsx-runtime.js", "loro-crdt/bundler", "loro-crdt/loro.wasm"...
|
|
11
|
+
* @param importer
|
|
12
|
+
* @param options
|
|
13
|
+
*/
|
|
14
|
+
resolveId: (id: string, importer?: string, options?: any) => {
|
|
15
|
+
external: boolean | "absolute" | "relative";
|
|
16
|
+
id: string;
|
|
17
|
+
path: string;
|
|
18
|
+
entry: import("./pack").Entry;
|
|
19
|
+
pack: Pack;
|
|
20
|
+
};
|
|
21
|
+
resolvePath(path: string, importer?: string, options?: any): {
|
|
22
|
+
pack: Pack;
|
|
23
|
+
path: string;
|
|
24
|
+
};
|
|
25
|
+
private resolveWithProxy;
|
|
26
|
+
resolveInPack(pack: Pack, id: string, importer?: string, options?: any): {
|
|
27
|
+
external: boolean | "absolute" | "relative";
|
|
28
|
+
id: string;
|
|
29
|
+
path: string;
|
|
30
|
+
entry: import("./pack").Entry;
|
|
31
|
+
pack: Pack;
|
|
32
|
+
};
|
|
33
|
+
getPackNames(): string[];
|
|
34
|
+
getPack(id: string): {
|
|
35
|
+
pack: Pack;
|
|
36
|
+
path: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TypescriptConfig } from "../helpers/getTSConfig.js";
|
|
2
|
+
import { Config } from "@swc/core";
|
|
3
|
+
import { Entry, Pack } from "./pack";
|
|
4
|
+
export declare class Target extends Pack {
|
|
5
|
+
readonly publicDir: string;
|
|
6
|
+
get publicPath(): string | undefined;
|
|
7
|
+
_tsConfig: TypescriptConfig;
|
|
8
|
+
get tsConfig(): TypescriptConfig;
|
|
9
|
+
isExcluded(fileName: string, isRelative?: boolean): boolean;
|
|
10
|
+
get swcConfigPath(): string;
|
|
11
|
+
swcConfigBase: any;
|
|
12
|
+
_swcConfig: Config;
|
|
13
|
+
get swcConfig(): Config;
|
|
14
|
+
getPublishPackageJson(): Promise<string>;
|
|
15
|
+
protected createEntry(name: string, source: string): Entry;
|
|
16
|
+
get https(): {
|
|
17
|
+
host: unknown;
|
|
18
|
+
port: unknown;
|
|
19
|
+
cert: string;
|
|
20
|
+
key: string;
|
|
21
|
+
};
|
|
22
|
+
_proxy: any;
|
|
23
|
+
get proxy(): Array<{
|
|
24
|
+
regex: RegExp;
|
|
25
|
+
replace: any;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
+
import { PackServer } from "./pack-server";
|
|
3
|
+
import { IBundler } from "../bundlers/types";
|
|
4
|
+
import { Pack } from "../model/pack";
|
|
5
|
+
export declare class BundleServer extends PackServer {
|
|
6
|
+
private bundler;
|
|
7
|
+
constructor(pack: Pack, bundler: IBundler);
|
|
8
|
+
private bundleRequest;
|
|
9
|
+
protected handle(request: FastifyRequest, reply: FastifyReply): Promise<string | Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Target } from "../model/target";
|
|
2
|
+
import { FastifyInstance, FastifyRequest } from "fastify";
|
|
3
|
+
import { Monorepo } from "../model/monorepo";
|
|
4
|
+
import { Pack } from "../model/pack";
|
|
5
|
+
import { PackServer } from "./pack-server";
|
|
6
|
+
export declare class DevServer {
|
|
7
|
+
private monorepo;
|
|
8
|
+
rootTarget: Target;
|
|
9
|
+
targetServers: Map<Pack, PackServer>;
|
|
10
|
+
get resolver(): import("../model/resolver").Resolver;
|
|
11
|
+
private createServer;
|
|
12
|
+
get isBundler(): boolean;
|
|
13
|
+
constructor(monorepo: Monorepo);
|
|
14
|
+
rewriteUrl: (req: FastifyRequest) => string;
|
|
15
|
+
register(app: FastifyInstance): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
+
import { Pack } from "../model/pack";
|
|
3
|
+
export declare abstract class PackServer {
|
|
4
|
+
protected pack: Pack;
|
|
5
|
+
constructor(pack: Pack);
|
|
6
|
+
protected abstract handle(req: FastifyRequest, reply: FastifyReply): Promise<unknown>;
|
|
7
|
+
register(app: FastifyInstance): Promise<void>;
|
|
8
|
+
getMimeType(path: string): any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Watcher } from "../helpers/watcher.js";
|
|
2
|
+
import { PackServer } from "./pack-server";
|
|
3
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
4
|
+
export declare class TargetRunner extends PackServer {
|
|
5
|
+
static port: number;
|
|
6
|
+
port: number;
|
|
7
|
+
/** @type {Promise<import('node:child_process').ChildProcess> | undefined} **/
|
|
8
|
+
cp: any;
|
|
9
|
+
watcher: Watcher;
|
|
10
|
+
protected handle(req: FastifyRequest, reply: FastifyReply): Promise<unknown>;
|
|
11
|
+
register(app: FastifyInstance): Promise<void>;
|
|
12
|
+
runServer(): Promise<any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Target } from "../model/target";
|
|
2
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
3
|
+
import { PackServer } from "./pack-server";
|
|
4
|
+
import { Monorepo } from "../model/monorepo";
|
|
5
|
+
export declare class ViteDevelopmentServer extends PackServer {
|
|
6
|
+
private target;
|
|
7
|
+
private monorepo;
|
|
8
|
+
readonly wsPrefix = "/@ws";
|
|
9
|
+
private viteBuilder;
|
|
10
|
+
constructor(target: Target, monorepo: Monorepo);
|
|
11
|
+
protected handle(request: FastifyRequest, reply: FastifyReply): Promise<string | Uint8Array<ArrayBufferLike>>;
|
|
12
|
+
private devServerRequest;
|
|
13
|
+
private createServer;
|
|
14
|
+
/**
|
|
15
|
+
* Emit event on ws and proxies events from dependent dev-servers
|
|
16
|
+
*/
|
|
17
|
+
private enhanceWebSocket;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as t from "node:test";
|
|
2
|
+
import * as assert from "node:assert";
|
|
3
|
+
import { expect } from "expect";
|
|
4
|
+
declare function _suite<TClass extends new (ctx: t.SuiteContext) => (BaseTest | unknown)>(target: TClass, context: ClassDecoratorContext<TClass>): void;
|
|
5
|
+
declare function _test<TClass, TValue extends (this: TClass) => unknown>(method: TValue, context: ClassMethodDecoratorContext<TClass, TValue>): void;
|
|
6
|
+
export declare const test: ((() => typeof _test) & typeof _test);
|
|
7
|
+
export declare const suite: ((() => typeof _suite) & typeof _suite);
|
|
8
|
+
export declare const describe: (() => typeof _suite) & typeof _suite;
|
|
9
|
+
export { assert, expect };
|
|
10
|
+
export { mock, type SuiteContext, type TestContext } from "node:test";
|
|
11
|
+
export type BaseTest = {
|
|
12
|
+
after?(ctx: t.SuiteContext): unknown;
|
|
13
|
+
before?(ctx: t.SuiteContext): unknown;
|
|
14
|
+
afterEach?(ctx: t.TestContext): unknown;
|
|
15
|
+
beforeEach?(ctx: t.TestContext): unknown;
|
|
16
|
+
};
|
|
@@ -3,32 +3,35 @@
|
|
|
3
3
|
"module": "esnext",
|
|
4
4
|
"moduleResolution": "bundler",
|
|
5
5
|
"target": "ESNext",
|
|
6
|
-
"composite":
|
|
6
|
+
"composite": false,
|
|
7
7
|
"sourceMap": false,
|
|
8
8
|
"baseUrl": "./",
|
|
9
|
-
"experimentalDecorators":
|
|
9
|
+
"experimentalDecorators": false,
|
|
10
10
|
"checkJs": false,
|
|
11
|
-
"outDir": "./dist/esm",
|
|
12
11
|
"skipLibCheck": true,
|
|
13
12
|
"incremental": true,
|
|
14
13
|
"disableSolutionSearching": true,
|
|
15
14
|
"assumeChangesOnlyAffectDirectDependencies": true,
|
|
16
15
|
"skipDefaultLibCheck": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
17
|
"allowJs": true,
|
|
18
18
|
"disableReferencedProjectLoad": true,
|
|
19
19
|
"disableSourceOfProjectReferenceRedirect": true,
|
|
20
20
|
"allowSyntheticDefaultImports": true,
|
|
21
|
-
"
|
|
21
|
+
"emitDeclarationOnly": true,
|
|
22
|
+
"declaration": false,
|
|
22
23
|
"noEmitHelpers": true,
|
|
23
|
-
"declarationDir": "./dist/typings",
|
|
24
24
|
"esModuleInterop": true,
|
|
25
25
|
"forceConsistentCasingInFileNames": true,
|
|
26
26
|
"useDefineForClassFields": false,
|
|
27
|
-
"
|
|
27
|
+
"stripInternal": true,
|
|
28
28
|
"lib": [
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
29
|
+
"ES2024",
|
|
30
|
+
"WebWorker"
|
|
31
|
+
],
|
|
32
|
+
"types": [
|
|
33
|
+
"vite/client",
|
|
34
|
+
"node"
|
|
32
35
|
]
|
|
33
36
|
},
|
|
34
37
|
"exclude": [
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {Target} from "../dist/esm/helpers/target";
|
|
2
|
+
import {Flags} from "../dist/esm/helpers/flags";
|
|
3
|
+
import {join} from "node:path";
|
|
4
|
+
import {pathToFileURL} from "node:url";
|
|
5
|
+
|
|
6
|
+
const targets = await Target.readTargets(process.cwd(), new Flags(''));
|
|
7
|
+
const serverUrl = 'http://127.0.0.1:9000';
|
|
8
|
+
const base = '/_/';
|
|
9
|
+
|
|
10
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
11
|
+
if (specifier.startsWith('https://')) {
|
|
12
|
+
if (specifier.startsWith(serverUrl.replace('http://', 'https://'))){
|
|
13
|
+
specifier = specifier.replace('https://', 'http://')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
for (let target of targets) {
|
|
17
|
+
if (specifier.startsWith('https://' + target.https?.host)) {
|
|
18
|
+
specifier = serverUrl + specifier.substring(('https://' + target.https?.host).length);
|
|
19
|
+
console.log('HOST:', specifier, target.https.host);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
context.parentURL = urlToFile(context.parentURL);
|
|
24
|
+
if (specifier.startsWith(serverUrl))
|
|
25
|
+
specifier = specifier.substr(serverUrl.length);
|
|
26
|
+
if (specifier.startsWith('/_/@id/'))
|
|
27
|
+
return nextResolve(specifier.substr('/_/@id/'.length), context, nextResolve);
|
|
28
|
+
if (specifier.startsWith('/_/')) {
|
|
29
|
+
return {
|
|
30
|
+
shortCircuit: true,
|
|
31
|
+
url: serverUrl + base + specifier.substr('/_/'.length)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
for (let target of targets) {
|
|
35
|
+
if (specifier.startsWith(target.packageJson.name)) {
|
|
36
|
+
return {
|
|
37
|
+
shortCircuit: true,
|
|
38
|
+
url: serverUrl + base + specifier
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return nextResolve(specifier, context, nextResolve);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function urlToFile(url) {
|
|
46
|
+
if (!url?.startsWith(serverUrl)) return url;
|
|
47
|
+
const path = url.substr(serverUrl.length + base.length);
|
|
48
|
+
for (let target of targets) {
|
|
49
|
+
if (path.startsWith(target.packageJson.name)) {
|
|
50
|
+
const localPath = path.substr(target.packageJson.name);
|
|
51
|
+
return pathToFileURL(target.getEntry('.' + localPath) ?? join(target.rootDir, localPath));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (path.startsWith('@id/'))
|
|
55
|
+
return path.substr('@id/'.length);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export async function load(url, context, defaultLoad) {
|
|
60
|
+
// For JavaScript to be loaded over the network, we need to fetch and
|
|
61
|
+
// return it.
|
|
62
|
+
if (url.startsWith(serverUrl)) {
|
|
63
|
+
return {
|
|
64
|
+
shortCircuit: true,
|
|
65
|
+
source: await fetch(url).then(x => x.text()),
|
|
66
|
+
format: 'module'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Let Node.js handle all other URLs.
|
|
71
|
+
return defaultLoad(url, context, defaultLoad);
|
|
72
|
+
}
|
package/node/register.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {existsSync, linkSync, rmSync} from "node:fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
process.env.SWCRC = true;
|
|
4
|
+
|
|
5
|
+
const from = path.resolve(import.meta.dirname, "../.swcrc");
|
|
6
|
+
const to = process.cwd() + "/.swcrc";
|
|
7
|
+
const exist = existsSync(to)
|
|
8
|
+
if (!exist) {
|
|
9
|
+
linkSync(from, to);
|
|
10
|
+
process.addListener('beforeExit', () => rmSync(to));
|
|
11
|
+
}
|
|
12
|
+
import { register } from 'node:module';
|
|
13
|
+
import { pathToFileURL } from 'node:url';
|
|
14
|
+
register('@swc-node/register/esm', pathToFileURL('./').toString());
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha-4",
|
|
4
4
|
"description": "Compilation, bundling, code generator, testing.",
|
|
5
|
-
"main": "dist/rollup.config.js",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"repository": {
|
|
8
7
|
"url": "https://github.com/franzzua/cmmn/tree/master/tools"
|
|
@@ -11,54 +10,66 @@
|
|
|
11
10
|
"access": "public"
|
|
12
11
|
},
|
|
13
12
|
"bin": {
|
|
14
|
-
"cmmn": "bin.js"
|
|
13
|
+
"cmmn": "dist/esm/bin.js"
|
|
15
14
|
},
|
|
16
15
|
"exports": {
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
".": {
|
|
17
|
+
"default": "./dist/bundle/index.js",
|
|
18
|
+
"typings": "./dist/typings/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./tsconfig.json": "./helpers/tsconfig.json",
|
|
21
|
+
"./import": "./node/register.js",
|
|
22
|
+
"./import-dev": "./node/register-dev.js",
|
|
23
|
+
"./test": {
|
|
24
|
+
"default": "./dist/bundle/test.js",
|
|
25
|
+
"typings": "./dist/typings/test/test.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./swcrc": "./.swcrc"
|
|
20
28
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"test": [
|
|
24
|
-
"./test/index.d.ts"
|
|
25
|
-
],
|
|
26
|
-
".": [
|
|
27
|
-
"./compile/typings.d.ts"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
29
|
+
"config": {
|
|
30
|
+
"server": true
|
|
30
31
|
},
|
|
31
|
-
"typings": "compile/typings.d.ts",
|
|
32
32
|
"files": [
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"serve/*",
|
|
38
|
-
"plugins/*",
|
|
39
|
-
"spawn/*",
|
|
40
|
-
"test/*",
|
|
41
|
-
"helpers/*"
|
|
33
|
+
"dist",
|
|
34
|
+
"node",
|
|
35
|
+
".swcrc",
|
|
36
|
+
"tsconfig.json"
|
|
42
37
|
],
|
|
43
38
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
39
|
+
"@biomejs/biome": "1.9.4",
|
|
40
|
+
"@fastify/caching": "9.0.3",
|
|
41
|
+
"@fastify/express": "4.0.2",
|
|
42
|
+
"@fastify/http-proxy": "11.3.0",
|
|
43
|
+
"@manypkg/get-packages": "^2.2.2",
|
|
44
|
+
"@rollup/plugin-wasm": "6.2.2",
|
|
45
|
+
"@schemastore/package": "0.0.10",
|
|
46
|
+
"@swc/core": "1.13.5",
|
|
47
|
+
"@swc/helpers": "0.5.17",
|
|
48
|
+
"@swc-node/register": "1.11.1",
|
|
49
|
+
"@types/node": "22.18.9",
|
|
50
|
+
"@yarn-tool/resolve-package": "^2.0.12",
|
|
47
51
|
"@zerollup/ts-helpers": "1.7.18",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
52
|
+
"builtin-modules": "^5.0.0",
|
|
53
|
+
"expect": "^29.7.0",
|
|
54
|
+
"fast-glob": "^3.3.3",
|
|
55
|
+
"fastify": "5.6.1",
|
|
56
|
+
"http-proxy-middleware": "3.0.5",
|
|
57
|
+
"mime-types": "2.1.35",
|
|
58
|
+
"minimatch": "10.0.3",
|
|
59
|
+
"rolldown": "1.0.0-beta.42",
|
|
60
|
+
"terminal-kit": "^3.1.2",
|
|
61
|
+
"throttle-debounce": "5.0.2",
|
|
62
|
+
"typescript": "5.8.3",
|
|
63
|
+
"unplugin": "^2.1.2",
|
|
64
|
+
"unplugin-swc": "^1.5.1",
|
|
65
|
+
"vite": "7.1.9",
|
|
66
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
59
67
|
},
|
|
60
68
|
"author": "",
|
|
61
69
|
"license": "ISC",
|
|
62
70
|
"gitHead": "2755b333808bf97f1d9454601c2a2c9a88e4a021",
|
|
63
|
-
"
|
|
71
|
+
"stableVersion": "3.0.0-alpha-2",
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@swc-node/register": "*"
|
|
74
|
+
}
|
|
64
75
|
}
|