@incajs/cli 0.0.8 → 0.0.10

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/README.md CHANGED
@@ -26,7 +26,7 @@ bootstrapping; it wins outright when both exist.
26
26
  reloading on every change. `--experimental-hmr` (or
27
27
  `INCA_EXPERIMENTAL_HMR=1`) opts into experimental, module-granular
28
28
  hot reloading instead — see the
29
- [HMR guide](https://tom96da.github.io/incajs/guide/hmr).
29
+ [HMR guide](https://incajs.tom96da.com/guide/hmr).
30
30
  - **`inca build`** — bundles your app for production, once, with no
31
31
  window opened.
32
32
  - **`inca package`** — builds your app, then packages it with a
@@ -62,7 +62,7 @@ once it is packaged.
62
62
 
63
63
  A prebuilt binary is pulled in automatically as a platform-specific
64
64
  optional dependency — neither Cargo nor Rust are needed. See
65
- [Host binary](https://tom96da.github.io/incajs/guide/#host-binary) for
65
+ [Host binary](https://incajs.tom96da.com/guide/#host-binary) for
66
66
  per-platform support.
67
67
 
68
68
  Set `INCA_HOST_BIN` to use a specific binary instead, e.g. on a
@@ -32,11 +32,15 @@ export interface BundlerOptions extends BuildOptions {
32
32
  /** Called after each successful (re)build, with what it wrote. */
33
33
  onBuild: (output: BuildOutput) => void;
34
34
  /** Called instead of `onBuild` when a (re)build fails. */
35
- onError: (error: {
36
- message: string;
37
- stack: string | null;
38
- code?: string | null;
39
- }) => void;
35
+ onError: (error: BuildFailure) => void;
36
+ }
37
+ /** A failed build or HMR update, in the one shape every bundler adapter reports. */
38
+ export interface BuildFailure {
39
+ message: string;
40
+ /** The stack, plus any further detail worth printing under it. */
41
+ stack: string | null;
42
+ /** An `ERR_INCA_*` identifier, when the failure has one to look up. */
43
+ code?: string | null;
40
44
  }
41
45
  /** What a build wrote — the result of {@link Bundler.build}, and every {@link BundlerOptions.onBuild} call. */
42
46
  export interface BuildOutput {
@@ -52,21 +56,6 @@ export interface BuildOutput {
52
56
  at: number;
53
57
  };
54
58
  }
55
- /**
56
- * A failed HMR update's detail — the same fields a Rollup/Vite plugin
57
- * error carries beyond `message`/`stack`, when it has them.
58
- */
59
- export interface UpdateError {
60
- message: string;
61
- stack?: string | null;
62
- plugin?: string | null;
63
- id?: string | null;
64
- frame?: string | null;
65
- loc?: {
66
- line: number;
67
- column: number;
68
- } | null;
69
- }
70
59
  /** Options for {@link Bundler.hmr}. */
71
60
  export interface HmrOptions {
72
61
  /** The app's own entry point — may import `.vue` files. */
@@ -91,7 +80,7 @@ export interface HmrOptions {
91
80
  /** Called in place of forwarding a whole-app reload payload to the app. */
92
81
  reload: () => void;
93
82
  /** Called when an update the app fetched failed to compile. */
94
- onError: (error: UpdateError) => void;
83
+ onError: (error: BuildFailure) => void;
95
84
  /** Called after a successful update, with the file that changed and how long it took. */
96
85
  onUpdate?: (info: {
97
86
  file: string;
@@ -1,7 +1,8 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
1
2
  import { BuildOptions, BuildOutput } from '../types.mts';
2
3
  /**
3
4
  * Builds `entry` into a minified, production build under `outDir` once, and
4
5
  * rejects on failure rather than reporting it through a callback. Never
5
6
  * starts or talks to `inca-host` — that's `dev.mts`'s job.
6
7
  */
7
- export declare function build({ entry, outDir, runtimeConfig, stdout, stderr, quiet, }: BuildOptions): Promise<BuildOutput>;
8
+ export declare function build(core: AdapterCore, { entry, outDir, runtimeConfig, stdout, stderr, quiet, }: BuildOptions): Promise<BuildOutput>;
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  import { BuildOutput } from '../types.mts';
3
4
  /** What one (re)build actually wrote, relative to its own `outDir`. */
4
5
  export interface CapturedOutput {
@@ -15,4 +16,4 @@ export declare function toBuildOutput(outDir: string, captured: CapturedOutput,
15
16
  * one-shot build and every watch rebuild, so both read the bundler's real
16
17
  * output instead of assuming a file name or layout.
17
18
  */
18
- export declare function captureOutput(sink: (output: CapturedOutput) => void): Plugin;
19
+ export declare function captureOutput(core: AdapterCore, sink: (output: CapturedOutput) => void): Plugin;
@@ -1,7 +1,9 @@
1
1
  import { InlineConfig } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  import { CapturedOutput } from './captureOutput.mts';
3
4
  export declare const BUNDLE_FILE_NAME = "bundle.js";
4
5
  export interface ResolveConfigOptions {
6
+ core: AdapterCore;
5
7
  /** The app's own entry point — may import `.vue` files. */
6
8
  entry: string;
7
9
  /** Where the build's output is written. */
@@ -31,4 +33,4 @@ export interface ResolveConfigOptions {
31
33
  * the entry, named by `chunkFileNames`/`assetFileNames` below, rather than
32
34
  * failing the build.
33
35
  */
34
- export declare function resolveViteConfig({ entry, outDir, mode, watch, onOutput, stdout, stderr, quiet, runtimeConfig, }: ResolveConfigOptions): InlineConfig;
36
+ export declare function resolveViteConfig({ core, entry, outDir, mode, watch, onOutput, stdout, stderr, quiet, runtimeConfig, }: ResolveConfigOptions): InlineConfig;
@@ -0,0 +1,4 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
2
+ import { Bundler } from '../types.mts';
3
+ /** The Vite adapter. */
4
+ export declare function createViteBundler(core: AdapterCore): Bundler;
@@ -1,7 +1,30 @@
1
- import { HmrChannel, HmrOptions } from '../types.mts';
1
+ import { AdapterCore } from '../../adapterCore.mts';
2
+ import { BuildFailure, HmrChannel, HmrOptions } from '../types.mts';
3
+ /**
4
+ * A failed update's detail — the same fields a Rollup/Vite plugin
5
+ * error carries beyond `message`/`stack`, when it has them.
6
+ */
7
+ interface UpdateError {
8
+ message: string;
9
+ stack?: string | null;
10
+ plugin?: string | null;
11
+ id?: string | null;
12
+ frame?: string | null;
13
+ loc?: {
14
+ line: number;
15
+ column: number;
16
+ } | null;
17
+ }
18
+ /**
19
+ * Reduces a failed update to a {@link BuildFailure}, with the message and
20
+ * `code` a failed rebuild reports. Plugin, file and frame detail from Vite's
21
+ * `buildErrorMessage` follows the stack.
22
+ */
23
+ export declare function faultOfUpdate(core: AdapterCore, error: UpdateError): BuildFailure;
2
24
  /**
3
25
  * Starts a Vite dev server driving the app over its dev channel instead of
4
26
  * a browser: a `"client"` environment with a custom {@link HotChannel}
5
27
  * standing in for the WebSocket server `server.ws: false` disables.
6
28
  */
7
- export declare function hmr({ entry, cwd, runtimeConfig, runtimePath, stdout, stderr, quiet, notify, reload, onError, onUpdate, }: HmrOptions): Promise<HmrChannel>;
29
+ export declare function hmr(core: AdapterCore, { entry, cwd, runtimeConfig, runtimePath, stdout, stderr, quiet, notify, reload, onError, onUpdate, }: HmrOptions): Promise<HmrChannel>;
30
+ export {};
@@ -1,3 +1 @@
1
- export { build } from './build.mts';
2
- export { hmr } from './hmr.mts';
3
- export { watch } from './watch.mts';
1
+ export { createViteBundler } from './createBundler.mts';
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  /** Something an app can write that the engine can't run yet. */
3
4
  export interface UnsupportedFeature {
4
5
  /** The `ERR_INCA_*` identifier this failure is looked up by. */
@@ -20,4 +21,4 @@ export declare const UNSUPPORTED: readonly UnsupportedFeature[];
20
21
  * Fails the build on the first module that uses an unsupported feature,
21
22
  * naming the file that used it.
22
23
  */
23
- export declare function rejectUnsupported(features?: readonly UnsupportedFeature[]): Plugin;
24
+ export declare function rejectUnsupported(core: AdapterCore, features?: readonly UnsupportedFeature[]): Plugin;
@@ -1,7 +1,8 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
1
2
  import { BundlerOptions, Watcher } from '../types.mts';
2
3
  /**
3
4
  * Builds `entry` into a build under `outDir` and rebuilds it on every
4
5
  * change, calling `onBuild` with what each rebuild wrote. Never starts,
5
6
  * reloads, or talks to `inca-host` — that's `dev.mts`'s job.
6
7
  */
7
- export declare function watch({ onBuild, onError, stdout, stderr, quiet, ...buildOptions }: BundlerOptions): Promise<Watcher>;
8
+ export declare function watch(core: AdapterCore, { onBuild, onError, stdout, stderr, quiet, ...buildOptions }: BundlerOptions): Promise<Watcher>;
@@ -0,0 +1,10 @@
1
+ export { IncaError } from './error.mts';
2
+ export { bundlerFault } from './log.mts';
3
+ /**
4
+ * The CLI logic the CLI injects into a bundler adapter: the `IncaError`
5
+ * class and `bundlerFault`, which reduces a bundler's error to a printable
6
+ * fault.
7
+ *
8
+ * Also the seam an adapter's own tests pass the real module through.
9
+ */
10
+ export type AdapterCore = typeof import('./adapterCore.mts');