akanjs 2.0.0-rc.1 → 2.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/cli/index.js +27 -3
- package/cli/templates/workspaceRoot/.env.template +2 -8
- package/cli/templates/workspaceRoot/biome.json.template +175 -0
- package/cli/templates/workspaceRoot/bunfig.toml +4 -0
- package/cli/templates/workspaceRoot/package.json.template +1 -0
- package/devkit/frontendBuild/clientEntryDiscovery.ts +6 -2
- package/devkit/transforms/barrelImportsPlugin.ts +20 -1
- package/package.json +1 -1
- package/cli/templates/workspaceRoot/.prettierignore.template +0 -10
- package/cli/templates/workspaceRoot/.prettierrc.json.template +0 -6
- package/cli/templates/workspaceRoot/.swcrc.template +0 -9
- package/cli/templates/workspaceRoot/README.md.template +0 -37
package/cli/index.js
CHANGED
|
@@ -12957,7 +12957,7 @@ var resolveNodePackageExport = async (workspaceRoot, specifier) => {
|
|
|
12957
12957
|
const pkgDir = path13.dirname(pkgJsonPath);
|
|
12958
12958
|
const pkgJson = JSON.parse(await Bun.file(pkgJsonPath).text());
|
|
12959
12959
|
const subpath = specifier === packageName ? "." : `.${specifier.slice(packageName.length)}`;
|
|
12960
|
-
const exported =
|
|
12960
|
+
const exported = resolvePackageExport(pkgJson.exports, subpath);
|
|
12961
12961
|
const rel = exported ?? (subpath === "." ? pkgJson.module ?? pkgJson.main ?? "index.js" : null);
|
|
12962
12962
|
if (!rel || !rel.startsWith("."))
|
|
12963
12963
|
return null;
|
|
@@ -12990,6 +12990,27 @@ var resolveExportValue = (value) => {
|
|
|
12990
12990
|
}
|
|
12991
12991
|
return null;
|
|
12992
12992
|
};
|
|
12993
|
+
var resolvePackageExport = (exportsMap, subpath) => {
|
|
12994
|
+
if (!exportsMap)
|
|
12995
|
+
return null;
|
|
12996
|
+
const exact = resolveExportValue(exportsMap[subpath]);
|
|
12997
|
+
if (exact)
|
|
12998
|
+
return exact;
|
|
12999
|
+
for (const [key, value] of Object.entries(exportsMap)) {
|
|
13000
|
+
const starIdx = key.indexOf("*");
|
|
13001
|
+
if (starIdx === -1)
|
|
13002
|
+
continue;
|
|
13003
|
+
const prefix = key.slice(0, starIdx);
|
|
13004
|
+
const suffix = key.slice(starIdx + 1);
|
|
13005
|
+
if (!subpath.startsWith(prefix) || !subpath.endsWith(suffix))
|
|
13006
|
+
continue;
|
|
13007
|
+
const wildcard = subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
13008
|
+
const resolved = resolveExportValue(value);
|
|
13009
|
+
if (resolved)
|
|
13010
|
+
return resolved.replace("*", wildcard);
|
|
13011
|
+
}
|
|
13012
|
+
return null;
|
|
13013
|
+
};
|
|
12993
13014
|
var getPackageName = (specifier) => {
|
|
12994
13015
|
const parts = specifier.split("/");
|
|
12995
13016
|
if (!parts[0])
|
|
@@ -13183,7 +13204,10 @@ var loaderFor = (absPath) => {
|
|
|
13183
13204
|
|
|
13184
13205
|
var USE_CLIENT_RE = /^\s*(?:\/\*[\s\S]*?\*\/\s*|\/\/[^\n]*\n\s*)*["']use client["']/;
|
|
13185
13206
|
var SOURCE_EXTS2 = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
13207
|
+
var NODE_MODULES_RE2 = /[\\/]node_modules[\\/]/;
|
|
13208
|
+
var AKANJS_NODE_MODULE_RE2 = /[\\/]node_modules[\\/]akanjs[\\/]/;
|
|
13186
13209
|
var NON_SOURCE_EXT_RE2 = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav)$/i;
|
|
13210
|
+
var shouldSkipNodeModule = (absPath) => NODE_MODULES_RE2.test(absPath) && !AKANJS_NODE_MODULE_RE2.test(absPath);
|
|
13187
13211
|
|
|
13188
13212
|
class GraphClientEntryDiscovery {
|
|
13189
13213
|
#akanConfig;
|
|
@@ -13320,7 +13344,7 @@ class GraphClientEntryDiscovery {
|
|
|
13320
13344
|
const cached = this.#reachableEntriesCache.get(absPath);
|
|
13321
13345
|
if (cached)
|
|
13322
13346
|
return new Set(cached);
|
|
13323
|
-
if (visiting.has(absPath) || absPath
|
|
13347
|
+
if (visiting.has(absPath) || shouldSkipNodeModule(absPath))
|
|
13324
13348
|
return new Set;
|
|
13325
13349
|
visiting.add(absPath);
|
|
13326
13350
|
const entries = new Set;
|
|
@@ -13343,7 +13367,7 @@ class GraphClientEntryDiscovery {
|
|
|
13343
13367
|
const resolved = await this.#resolveSpecifier(spec, importerDir);
|
|
13344
13368
|
if (!resolved)
|
|
13345
13369
|
continue;
|
|
13346
|
-
if (resolved
|
|
13370
|
+
if (shouldSkipNodeModule(resolved))
|
|
13347
13371
|
continue;
|
|
13348
13372
|
for (const entry of await this.#discoverFromFile(resolved, visiting))
|
|
13349
13373
|
entries.add(entry);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# organization configuration, no need to change
|
|
2
2
|
AKAN_PUBLIC_REPO_NAME=<%= repoName %>
|
|
3
|
+
|
|
4
|
+
# serve domain, it changes the domain of the server.
|
|
3
5
|
AKAN_PUBLIC_SERVE_DOMAIN="<%= serveDomain %>"
|
|
4
6
|
|
|
5
7
|
# development branch, debug, develop, main, etc. mainly it changes databases.
|
|
@@ -7,14 +9,6 @@ AKAN_PUBLIC_ENV=local
|
|
|
7
9
|
|
|
8
10
|
# local, cloud, edge it changes the connection point of the clients.
|
|
9
11
|
AKAN_PUBLIC_OPERATION_MODE=local
|
|
10
|
-
# hybrid app specific config, will be depreciated in the future
|
|
11
|
-
APP_OPERATION_MODE=local
|
|
12
|
-
|
|
13
|
-
# backend service mode, federation, batch, all
|
|
14
|
-
SERVER_MODE=federation
|
|
15
|
-
|
|
16
|
-
# analyze the bundle size
|
|
17
|
-
ANALYZE=false
|
|
18
12
|
|
|
19
13
|
# log level, debug, info, warn, error
|
|
20
14
|
AKAN_PUBLIC_LOG_LEVEL=debug
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": false
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"includes": [
|
|
10
|
+
"**/*.ts",
|
|
11
|
+
"**/*.tsx",
|
|
12
|
+
"**/*.json",
|
|
13
|
+
"**/*.jsonc",
|
|
14
|
+
"!**/env.client.local.ts",
|
|
15
|
+
"!**/env.client.debug.ts",
|
|
16
|
+
"!**/env.client.develop.ts",
|
|
17
|
+
"!**/env.client.main.ts",
|
|
18
|
+
"!**/env.client.testing.ts",
|
|
19
|
+
"!**/env.server.local.ts",
|
|
20
|
+
"!**/env.server.develop.ts",
|
|
21
|
+
"!**/env.server.main.ts",
|
|
22
|
+
"!**/env.server.testing.ts",
|
|
23
|
+
"!**/env.server.type.ts",
|
|
24
|
+
"!apps/*/lib/cnst.ts",
|
|
25
|
+
"!apps/*/lib/dict.ts",
|
|
26
|
+
"!apps/*/lib/db.ts",
|
|
27
|
+
"!apps/*/lib/srv.ts",
|
|
28
|
+
"!apps/*/lib/st.ts",
|
|
29
|
+
"!apps/*/lib/sig.ts",
|
|
30
|
+
"!apps/*/lib/useClient.ts",
|
|
31
|
+
"!apps/*/lib/useServer.ts",
|
|
32
|
+
"!apps/*/client.ts",
|
|
33
|
+
"!apps/*/server.ts",
|
|
34
|
+
"!apps/*/lib/*/index.tsx",
|
|
35
|
+
"!libs/*/lib/cnst.ts",
|
|
36
|
+
"!libs/*/lib/dict.ts",
|
|
37
|
+
"!libs/*/lib/db.ts",
|
|
38
|
+
"!libs/*/lib/srv.ts",
|
|
39
|
+
"!libs/*/lib/st.ts",
|
|
40
|
+
"!libs/*/lib/sig.ts",
|
|
41
|
+
"!libs/*/lib/useClient.ts",
|
|
42
|
+
"!libs/*/lib/useServer.ts",
|
|
43
|
+
"!libs/*/client.ts",
|
|
44
|
+
"!libs/*/server.ts",
|
|
45
|
+
"!libs/*/index.ts",
|
|
46
|
+
"!libs/*/lib/*/index.tsx",
|
|
47
|
+
"!infra/master/createRecords.ts",
|
|
48
|
+
"!pkgs/contract/env.ts",
|
|
49
|
+
"!!**/node_modules",
|
|
50
|
+
"!!**/dist",
|
|
51
|
+
"!!**/.akan",
|
|
52
|
+
"!!**/dump",
|
|
53
|
+
"!!**/local"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"formatter": {
|
|
57
|
+
"enabled": true,
|
|
58
|
+
"indentStyle": "space",
|
|
59
|
+
"indentWidth": 2,
|
|
60
|
+
"lineWidth": 120
|
|
61
|
+
},
|
|
62
|
+
"linter": {
|
|
63
|
+
"enabled": true,
|
|
64
|
+
"rules": {
|
|
65
|
+
"recommended": true,
|
|
66
|
+
"suspicious": {
|
|
67
|
+
"noConsole": {
|
|
68
|
+
"level": "error",
|
|
69
|
+
"options": {
|
|
70
|
+
"allow": ["assert", "error", "info", "warn"]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"noArrayIndexKey": "off",
|
|
74
|
+
"noShadowRestrictedNames": "off"
|
|
75
|
+
},
|
|
76
|
+
"correctness": {
|
|
77
|
+
"noUnusedFunctionParameters": "off",
|
|
78
|
+
"noUnusedImports": {
|
|
79
|
+
"level": "error",
|
|
80
|
+
"fix": "safe"
|
|
81
|
+
},
|
|
82
|
+
"useParseIntRadix": "off",
|
|
83
|
+
"useExhaustiveDependencies": "off"
|
|
84
|
+
},
|
|
85
|
+
"nursery": {
|
|
86
|
+
"useSortedClasses": {
|
|
87
|
+
"level": "error",
|
|
88
|
+
"fix": "safe",
|
|
89
|
+
"options": {
|
|
90
|
+
"attributes": ["classList"],
|
|
91
|
+
"functions": ["clsx", "cva"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"a11y": "off",
|
|
96
|
+
"complexity": {
|
|
97
|
+
"noStaticOnlyClass": "off"
|
|
98
|
+
},
|
|
99
|
+
"style": {
|
|
100
|
+
"useTemplate": {
|
|
101
|
+
"level": "warn",
|
|
102
|
+
"fix": "safe"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"domains": {
|
|
107
|
+
"project": "recommended",
|
|
108
|
+
"react": "recommended",
|
|
109
|
+
"test": "recommended",
|
|
110
|
+
"types": "all"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"javascript": {
|
|
114
|
+
"parser": {
|
|
115
|
+
"unsafeParameterDecoratorsEnabled": true
|
|
116
|
+
},
|
|
117
|
+
"formatter": {
|
|
118
|
+
"quoteStyle": "double"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"assist": {
|
|
122
|
+
"enabled": true,
|
|
123
|
+
"actions": {
|
|
124
|
+
"source": {
|
|
125
|
+
"organizeImports": "on"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"overrides": [
|
|
130
|
+
{
|
|
131
|
+
"includes": ["**/page/**/*.ts", "**/page/**/*.tsx", "**/*.Unit.tsx", "**/*.View.tsx"],
|
|
132
|
+
"plugins": [
|
|
133
|
+
"./node_modules/akanjs/devkit/lint/no-import-client-functions.grit",
|
|
134
|
+
"./node_modules/akanjs/devkit/lint/no-use-client-in-server.grit"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"includes": ["**/page/**/*.ts", "**/page/**/*.tsx"],
|
|
139
|
+
"plugins": ["./node_modules/akanjs/devkit/lint/non-scalar-props-restricted.grit"]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"includes": ["**/*.constant.ts", "**/*.document.ts", "**/*.service.ts", "**/*.store.ts"],
|
|
143
|
+
"plugins": ["./node_modules/akanjs/devkit/lint/no-js-private-class-method.grit"]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"includes": [
|
|
147
|
+
"**/page/**/*.ts",
|
|
148
|
+
"**/page/**/*.tsx",
|
|
149
|
+
"**/index.ts",
|
|
150
|
+
"**/index.tsx",
|
|
151
|
+
"**/cnst.ts",
|
|
152
|
+
"**/db.ts",
|
|
153
|
+
"**/dict.ts",
|
|
154
|
+
"**/option.ts",
|
|
155
|
+
"**/sig.ts",
|
|
156
|
+
"**/srv.ts",
|
|
157
|
+
"**/st.ts",
|
|
158
|
+
"**/*.constant.ts",
|
|
159
|
+
"**/*.dictionary.ts",
|
|
160
|
+
"**/*.document.ts",
|
|
161
|
+
"**/*.service.ts",
|
|
162
|
+
"**/*.signal.ts",
|
|
163
|
+
"**/*.signal.test.ts",
|
|
164
|
+
"**/*.service.test.ts",
|
|
165
|
+
"**/*.store.ts",
|
|
166
|
+
"**/*.Template.tsx",
|
|
167
|
+
"**/*.Unit.tsx",
|
|
168
|
+
"**/*.Util.tsx",
|
|
169
|
+
"**/*.View.tsx",
|
|
170
|
+
"**/*.Zone.tsx"
|
|
171
|
+
],
|
|
172
|
+
"plugins": ["./node_modules/akanjs/devkit/lint/no-import-external-library.grit"]
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
@@ -6,10 +6,14 @@ import type { AkanConfig, ClientEntryDiscovery, ScannedImport } from "./clientBu
|
|
|
6
6
|
|
|
7
7
|
const USE_CLIENT_RE = /^\s*(?:\/\*[\s\S]*?\*\/\s*|\/\/[^\n]*\n\s*)*["']use client["']/;
|
|
8
8
|
const SOURCE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
9
|
+
const NODE_MODULES_RE = /[\\/]node_modules[\\/]/;
|
|
10
|
+
const AKANJS_NODE_MODULE_RE = /[\\/]node_modules[\\/]akanjs[\\/]/;
|
|
9
11
|
|
|
10
12
|
const NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav)$/i;
|
|
11
13
|
type PackageResolver = Awaited<ReturnType<typeof createTsconfigPackageResolver>>;
|
|
12
14
|
|
|
15
|
+
const shouldSkipNodeModule = (absPath: string) => NODE_MODULES_RE.test(absPath) && !AKANJS_NODE_MODULE_RE.test(absPath);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Graph-based `"use client"` discovery, seeded from an explicit file list.
|
|
15
19
|
*
|
|
@@ -156,7 +160,7 @@ export class GraphClientEntryDiscovery implements ClientEntryDiscovery {
|
|
|
156
160
|
const absPath = path.resolve(file);
|
|
157
161
|
const cached = this.#reachableEntriesCache.get(absPath);
|
|
158
162
|
if (cached) return new Set(cached);
|
|
159
|
-
if (visiting.has(absPath) || absPath
|
|
163
|
+
if (visiting.has(absPath) || shouldSkipNodeModule(absPath)) return new Set();
|
|
160
164
|
|
|
161
165
|
visiting.add(absPath);
|
|
162
166
|
const entries = new Set<string>();
|
|
@@ -177,7 +181,7 @@ export class GraphClientEntryDiscovery implements ClientEntryDiscovery {
|
|
|
177
181
|
if (NON_SOURCE_EXT_RE.test(spec)) continue;
|
|
178
182
|
const resolved = await this.#resolveSpecifier(spec, importerDir);
|
|
179
183
|
if (!resolved) continue;
|
|
180
|
-
if (resolved
|
|
184
|
+
if (shouldSkipNodeModule(resolved)) continue;
|
|
181
185
|
for (const entry of await this.#discoverFromFile(resolved, visiting)) entries.add(entry);
|
|
182
186
|
}
|
|
183
187
|
|
|
@@ -188,7 +188,7 @@ const resolveNodePackageExport = async (workspaceRoot: string, specifier: string
|
|
|
188
188
|
main?: string;
|
|
189
189
|
};
|
|
190
190
|
const subpath = specifier === packageName ? "." : `.${specifier.slice(packageName.length)}`;
|
|
191
|
-
const exported =
|
|
191
|
+
const exported = resolvePackageExport(pkgJson.exports, subpath);
|
|
192
192
|
const rel = exported ?? (subpath === "." ? (pkgJson.module ?? pkgJson.main ?? "index.js") : null);
|
|
193
193
|
if (!rel || !rel.startsWith(".")) return null;
|
|
194
194
|
const entryFile = await resolveFileCandidate(path.resolve(pkgDir, rel));
|
|
@@ -217,6 +217,25 @@ const resolveExportValue = (value: ExportValue | undefined): string | null => {
|
|
|
217
217
|
return null;
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
+
const resolvePackageExport = (exportsMap: Record<string, ExportValue> | undefined, subpath: string): string | null => {
|
|
221
|
+
if (!exportsMap) return null;
|
|
222
|
+
const exact = resolveExportValue(exportsMap[subpath]);
|
|
223
|
+
if (exact) return exact;
|
|
224
|
+
|
|
225
|
+
for (const [key, value] of Object.entries(exportsMap)) {
|
|
226
|
+
const starIdx = key.indexOf("*");
|
|
227
|
+
if (starIdx === -1) continue;
|
|
228
|
+
const prefix = key.slice(0, starIdx);
|
|
229
|
+
const suffix = key.slice(starIdx + 1);
|
|
230
|
+
if (!subpath.startsWith(prefix) || !subpath.endsWith(suffix)) continue;
|
|
231
|
+
const wildcard = subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
232
|
+
const resolved = resolveExportValue(value);
|
|
233
|
+
if (resolved) return resolved.replace("*", wildcard);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return null;
|
|
237
|
+
};
|
|
238
|
+
|
|
220
239
|
const getPackageName = (specifier: string): string | null => {
|
|
221
240
|
const parts = specifier.split("/");
|
|
222
241
|
if (!parts[0]) return null;
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
## Get Started
|
|
2
|
-
|
|
3
|
-
Run the code below.
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
bun run downloadEnv # Need to register your public key
|
|
7
|
-
|
|
8
|
-
bun i -g akanjs
|
|
9
|
-
|
|
10
|
-
bun i
|
|
11
|
-
|
|
12
|
-
cat <<EOF >> .env
|
|
13
|
-
# organization configuration, no need to change
|
|
14
|
-
AKAN_PUBLIC_REPO_NAME=<%= repoName %>
|
|
15
|
-
AKAN_PUBLIC_SERVE_DOMAIN="<%= serveDomain %>"
|
|
16
|
-
|
|
17
|
-
# development branch, debug, develop, main, etc. mainly it changes databases.
|
|
18
|
-
AKAN_PUBLIC_ENV=debug
|
|
19
|
-
|
|
20
|
-
# local, cloud, edge it changes the connection point of the clients.
|
|
21
|
-
AKAN_PUBLIC_OPERATION_MODE=local
|
|
22
|
-
# hybrid app specific config, will be depreciated in the future
|
|
23
|
-
APP_OPERATION_MODE=local
|
|
24
|
-
|
|
25
|
-
# backend service mode, federation, batch, all
|
|
26
|
-
SERVER_MODE=federation
|
|
27
|
-
|
|
28
|
-
# analyze the bundle size
|
|
29
|
-
ANALYZE=false
|
|
30
|
-
|
|
31
|
-
# log level, debug, info, warn, error
|
|
32
|
-
AKAN_PUBLIC_LOG_LEVEL=debug
|
|
33
|
-
EOF
|
|
34
|
-
|
|
35
|
-
akan serve-backend <%= appName %>
|
|
36
|
-
# or akan serve-frontend <%= appName %>, etc
|
|
37
|
-
```
|