@richapps/ong 0.1.1 → 0.1.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/cli.js CHANGED
@@ -40,6 +40,10 @@ function parseArgs(argv) {
40
40
  else if (arg === '--help' || arg === '-h') {
41
41
  return { command: 'help' };
42
42
  }
43
+ else if (!arg.startsWith('-') && !result.project) {
44
+ // Treat bare positional arg as project (e.g. "ong serve apps/editor")
45
+ result.project = arg;
46
+ }
43
47
  }
44
48
  return result;
45
49
  }
package/dist/config.js CHANGED
@@ -1,6 +1,67 @@
1
1
  import { resolve } from 'node:path';
2
+ import { readFileSync, existsSync } from 'node:fs';
2
3
  import { angular } from '@oxc-angular/vite';
3
4
  import { htmlInjectPlugin, assetCopyPlugin } from './plugins.js';
5
+ /**
6
+ * Reads tsconfig paths and converts them to Vite resolve aliases.
7
+ * Follows tsconfig "extends" chain to find paths from base configs.
8
+ */
9
+ function resolveTsconfigPaths(tsconfig, workspaceRoot) {
10
+ const aliases = [];
11
+ try {
12
+ let configPath = tsconfig;
13
+ let paths;
14
+ let baseUrl = '.';
15
+ // Walk the extends chain to find paths
16
+ while (configPath && !paths) {
17
+ if (!existsSync(configPath))
18
+ break;
19
+ const raw = readFileSync(configPath, 'utf-8');
20
+ // Strip comments (single-line // and multi-line /* */)
21
+ const stripped = raw.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
22
+ const config = JSON.parse(stripped);
23
+ const compilerOptions = config.compilerOptions ?? {};
24
+ if (compilerOptions.paths) {
25
+ paths = compilerOptions.paths;
26
+ baseUrl = compilerOptions.baseUrl ?? '.';
27
+ }
28
+ if (config.extends) {
29
+ configPath = resolve(configPath, '..', config.extends);
30
+ // Add .json if not present
31
+ if (!configPath.endsWith('.json'))
32
+ configPath += '.json';
33
+ }
34
+ else {
35
+ break;
36
+ }
37
+ }
38
+ if (!paths)
39
+ return aliases;
40
+ const baseDir = resolve(workspaceRoot, baseUrl);
41
+ for (const [pattern, targets] of Object.entries(paths)) {
42
+ if (!targets.length)
43
+ continue;
44
+ const target = targets[0];
45
+ if (pattern.endsWith('/*')) {
46
+ // Wildcard mapping: "@scope/lib/*" -> "libs/lib/src/*"
47
+ const prefix = pattern.slice(0, -2);
48
+ const targetDir = resolve(baseDir, target.slice(0, -2));
49
+ aliases.push({ find: new RegExp(`^${escapeRegex(prefix)}/(.*)`), replacement: `${targetDir}/$1` });
50
+ }
51
+ else {
52
+ // Exact mapping: "@scope/lib" -> "libs/lib/src/index.ts"
53
+ aliases.push({ find: pattern, replacement: resolve(baseDir, target) });
54
+ }
55
+ }
56
+ }
57
+ catch {
58
+ // Ignore tsconfig parse errors — fall back to no aliases
59
+ }
60
+ return aliases;
61
+ }
62
+ function escapeRegex(str) {
63
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
64
+ }
4
65
  /**
5
66
  * Creates a Vite InlineConfig from resolved Angular build options.
6
67
  */
@@ -53,6 +114,7 @@ export function createViteConfig(opts) {
53
114
  ...(Object.keys(opts.define).length ? { define: opts.define } : {}),
54
115
  resolve: {
55
116
  preserveSymlinks: opts.preserveSymlinks,
117
+ alias: resolveTsconfigPaths(opts.tsconfig, workspaceRoot),
56
118
  },
57
119
  css: Object.keys(cssPreprocessorOptions).length
58
120
  ? { preprocessorOptions: cssPreprocessorOptions }
@@ -84,6 +146,9 @@ export function createViteConfig(opts) {
84
146
  open: opts.serve.open,
85
147
  host: opts.serve.host ?? false,
86
148
  watch: opts.poll ? { usePolling: true, interval: opts.poll } : undefined,
149
+ fs: {
150
+ allow: [workspaceRoot],
151
+ },
87
152
  },
88
153
  };
89
154
  }
package/dist/plugins.js CHANGED
@@ -43,17 +43,16 @@ export function htmlInjectPlugin(opts) {
43
43
  }
44
44
  // Inject polyfills before the entry point
45
45
  if (opts.polyfills.length) {
46
- const tags = opts.polyfills
46
+ const imports = opts.polyfills
47
47
  .map(p => {
48
- // Bare specifiers (e.g. "zone.js") become imports, paths become src refs
49
- if (p.startsWith('.') || p.startsWith('/')) {
50
- const ref = '/' + relative(viteRoot, resolve(opts.workspaceRoot, p));
51
- return ` <script type="module" src="${ref}"${crossOriginAttr}></script>`;
52
- }
53
- return ` <script type="module">import '${p}';</script>`;
48
+ // Check if it's a file path (relative to workspace root or absolute)
49
+ const resolved = resolve(opts.workspaceRoot, p);
50
+ const isFile = p.startsWith('.') || p.startsWith('/') || existsSync(resolved);
51
+ // Use absolute path for file imports so Vite can resolve them regardless of root
52
+ return isFile ? `import '${resolved}';` : `import '${p}';`;
54
53
  })
55
54
  .join('\n');
56
- result = result.replace('</body>', `${tags}\n</body>`);
55
+ result = result.replace('</body>', ` <script type="module">\n${imports}\n</script>\n</body>`);
57
56
  }
58
57
  // Inject entry point if not already present
59
58
  const hasEntry = html.includes(`src="${browserRelative}"`) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@richapps/ong",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Angular CLI powered by Vite + OXC — blazing fast drop-in replacement for ng serve/build",
5
5
  "keywords": [
6
6
  "angular",