@untestutils/remix 0.5.2 → 0.5.3

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/index.d.mts CHANGED
@@ -1,14 +1,23 @@
1
- import { type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from "@untestutils/core";
2
2
  export type RemixRun = "server" | "dev";
3
+ export type ViteConfigOverride = Record<string, unknown>;
3
4
  export interface RemixOptions extends FrameworkBaseOptions {
4
5
  run?: RemixRun;
5
6
  /** Server build entry relative to root (default `build/server/index.js`). */
6
7
  serverEntry?: string;
8
+ /**
9
+ * When set, build/dev go through Vite with `--config` merge (Remix Vite apps).
10
+ * Same role as Nuxt `nuxtConfig`.
11
+ */
12
+ viteConfig?: ViteConfigOverride;
7
13
  }
14
+ export type RemixMatrixVariant = Partial<Pick<RemixOptions, "env" | "hashInputs" | "run" | "serverEntry" | "readyPath" | "readyTimeoutMs" | "workspaceDeps" | "viteConfig">>;
8
15
  /**
9
16
  * Remix (Vite) Recipe factory.
10
17
  * `run: 'server'` (default) — vite/remix build + remix-serve
11
18
  * `run: 'dev'` — remix vite:dev / vite
12
19
  */
13
- export declare function remix(opts: RemixOptions): Recipe;
20
+ export declare const remix: Driver<RemixOptions>;
21
+ /** Expand one Remix recipe base into many recipes with distinct ids. */
22
+ export declare function matrix(base: RemixOptions, variants: Record<string, RemixMatrixVariant>): Record<string, Recipe>;
14
23
  export default remix;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,24 @@
1
- import { type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
1
+ import { type Driver, type FrameworkBaseOptions, type Recipe } from '@untestutils/core';
2
2
  export type RemixRun = 'server' | 'dev';
3
+ export type ViteConfigOverride = Record<string, unknown>;
3
4
  export interface RemixOptions extends FrameworkBaseOptions {
4
5
  run?: RemixRun;
5
6
  /** Server build entry relative to root (default `build/server/index.js`). */
6
7
  serverEntry?: string;
8
+ /**
9
+ * When set, build/dev go through Vite with `--config` merge (Remix Vite apps).
10
+ * Same role as Nuxt `nuxtConfig`.
11
+ */
12
+ viteConfig?: ViteConfigOverride;
7
13
  }
14
+ export type RemixMatrixVariant = Partial<Pick<RemixOptions, 'env' | 'hashInputs' | 'run' | 'serverEntry' | 'readyPath' | 'readyTimeoutMs' | 'workspaceDeps' | 'viteConfig'>>;
8
15
  /**
9
16
  * Remix (Vite) Recipe factory.
10
17
  * `run: 'server'` (default) — vite/remix build + remix-serve
11
18
  * `run: 'dev'` — remix vite:dev / vite
12
19
  */
13
- export declare function remix(opts: RemixOptions): Recipe;
20
+ export declare const remix: Driver<RemixOptions>;
21
+ /** Expand one Remix recipe base into many recipes with distinct ids. */
22
+ export declare function matrix(base: RemixOptions, variants: Record<string, RemixMatrixVariant>): Record<string, Recipe>;
14
23
  export default remix;
15
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExC,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACxD,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgCD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAiFhD;AAED,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAUL,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACxD,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,IAAI,CACF,YAAY,EACV,KAAK,GACL,YAAY,GACZ,KAAK,GACL,aAAa,GACb,WAAW,GACX,gBAAgB,GAChB,eAAe,GACf,YAAY,CACf,CACF,CAAC;AAoDF;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,YAAY,CA6GrC,CAAC;AAEH,wEAAwE;AACxE,wBAAgB,MAAM,CACpB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB;AAED,eAAe,KAAK,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve } from "pathe";
3
- import { cliFrameworkRecipe, frameworkRoots, resolveBin } from "@untestutils/core";
3
+ import { cliFrameworkRecipe, configOverrideHashInput, deepMergePlain, defineDriver, frameworkRoots, matrixRecipe, resolveBin, serializeViteMergeConfigModule, writeEphemeralConfig } from "@untestutils/core";
4
4
  function resolveRemixCli(root) {
5
5
  return resolveBin({
6
6
  label: "remix",
@@ -28,12 +28,27 @@ function resolveViteBin(root) {
28
28
  binRelative: ["bin/vite.js", "bin/vite.mjs"]
29
29
  });
30
30
  }
31
+ function hashInputsFor(opts, root, extra) {
32
+ const inputs = [...opts.hashInputs ?? [root], ...extra];
33
+ if (opts.viteConfig) inputs.push(configOverrideHashInput("viteConfig", opts.viteConfig));
34
+ return inputs;
35
+ }
36
+ async function viteConfigArgs(root, outDir, viteConfig) {
37
+ if (!viteConfig || !Object.keys(viteConfig).length) return [];
38
+ const configPath = join(outDir, "vite.untestutils.mjs");
39
+ await writeEphemeralConfig(configPath, serializeViteMergeConfigModule({
40
+ appRoot: root,
41
+ overrides: viteConfig
42
+ }));
43
+ return ["--config", configPath];
44
+ }
31
45
 
32
- export function remix(opts) {
46
+ export const remix = defineDriver((opts) => {
33
47
  const root = resolve(opts.root);
34
48
  const runMode = opts.run ?? "server";
35
49
  const id = opts.id ?? `remix-${runMode}-${root.split("/").pop()}`;
36
50
  const serverEntry = opts.serverEntry ?? join("build", "server", "index.js");
51
+ const hasViteOverrides = Boolean(opts.viteConfig && Object.keys(opts.viteConfig).length);
37
52
  if (runMode === "dev") {
38
53
  return cliFrameworkRecipe({
39
54
  id,
@@ -41,11 +56,28 @@ export function remix(opts) {
41
56
  label: "remix",
42
57
  share: "never",
43
58
  env: opts.env,
44
- hashInputs: opts.hashInputs ?? [root, "run:dev"],
59
+ hashInputs: hashInputsFor(opts, root, ["run:dev"]),
45
60
  readyPath: opts.readyPath,
46
61
  readyTimeoutMs: opts.readyTimeoutMs,
47
- start: ({ port }) => {
48
-
62
+ workspaceDeps: opts.workspaceDeps,
63
+ start: async ({ port, outDir }) => {
64
+ if (hasViteOverrides) {
65
+ const viteBin = resolveViteBin(root);
66
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
67
+ return {
68
+ command: process.execPath,
69
+ args: [
70
+ viteBin,
71
+ ...configArgs,
72
+ "--port",
73
+ String(port),
74
+ "--strictPort",
75
+ "--host",
76
+ "127.0.0.1"
77
+ ],
78
+ cwd: root
79
+ };
80
+ }
49
81
  try {
50
82
  const cli = resolveRemixCli(root);
51
83
  return {
@@ -60,11 +92,11 @@ export function remix(opts) {
60
92
  env: { PORT: String(port) }
61
93
  };
62
94
  } catch {
63
- const vite = resolveViteBin(root);
95
+ const viteBin = resolveViteBin(root);
64
96
  return {
65
97
  command: process.execPath,
66
98
  args: [
67
- vite,
99
+ viteBin,
68
100
  "--port",
69
101
  String(port),
70
102
  "--strictPort",
@@ -83,14 +115,24 @@ export function remix(opts) {
83
115
  label: "remix",
84
116
  share: "always",
85
117
  env: opts.env,
86
- hashInputs: opts.hashInputs ?? [
87
- root,
88
- "run:server",
89
- serverEntry
90
- ],
118
+ hashInputs: hashInputsFor(opts, root, ["run:server", serverEntry]),
91
119
  readyPath: opts.readyPath,
92
120
  readyTimeoutMs: opts.readyTimeoutMs,
93
- prepare: () => {
121
+ workspaceDeps: opts.workspaceDeps,
122
+ prepare: async ({ outDir }) => {
123
+ if (hasViteOverrides) {
124
+ const viteBin = resolveViteBin(root);
125
+ const configArgs = await viteConfigArgs(root, outDir, opts.viteConfig);
126
+ return {
127
+ command: process.execPath,
128
+ args: [
129
+ viteBin,
130
+ "build",
131
+ ...configArgs
132
+ ],
133
+ cwd: root
134
+ };
135
+ }
94
136
  try {
95
137
  const cli = resolveRemixCli(root);
96
138
  return {
@@ -99,10 +141,10 @@ export function remix(opts) {
99
141
  cwd: root
100
142
  };
101
143
  } catch {
102
- const vite = resolveViteBin(root);
144
+ const viteBin = resolveViteBin(root);
103
145
  return {
104
146
  command: process.execPath,
105
- args: [vite, "build"],
147
+ args: [viteBin, "build"],
106
148
  cwd: root
107
149
  };
108
150
  }
@@ -127,5 +169,26 @@ export function remix(opts) {
127
169
  };
128
170
  }
129
171
  });
172
+ });
173
+
174
+ export function matrix(base, variants) {
175
+ return matrixRecipe(remix, base, variants, {
176
+ label: "remix",
177
+ merge: (b, patch, id, name) => ({
178
+ ...b,
179
+ ...patch,
180
+ id,
181
+ env: {
182
+ ...b.env ?? {},
183
+ ...patch.env ?? {}
184
+ },
185
+ viteConfig: b.viteConfig || patch.viteConfig ? deepMergePlain(b.viteConfig ?? {}, patch.viteConfig ?? {}) : undefined,
186
+ hashInputs: [
187
+ ...b.hashInputs ?? [b.root],
188
+ ...patch.hashInputs ?? [],
189
+ `variant:${name}`
190
+ ]
191
+ })
192
+ });
130
193
  }
131
194
  export default remix;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untestutils/remix",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "homepage": "https://s00d.github.io/untestutils/",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "pathe": "^2.0.3",
31
- "@untestutils/core": "0.5.2"
31
+ "@untestutils/core": "0.5.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^26.6.1",