@ryanatkn/gro 0.185.0 → 0.187.0

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/gro.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env -S node --experimental-import-meta-resolve --experimental-strip-types --disable-warning=ExperimentalWarning
2
2
  // @sync Node options to `$lib/gro_helpers.ts`
3
3
  import { join } from 'node:path';
4
+ import { spawn_result_is_exited } from '@fuzdev/fuz_util/process.js';
4
5
  import { resolve_gro_module_path, spawn_with_loader } from "./gro_helpers.js";
5
6
  /*
6
7
 
@@ -16,5 +17,5 @@ const invoke_path = resolve_gro_module_path('invoke.js');
16
17
  const loader_path = join(invoke_path, '../loader.js');
17
18
  const spawned = await spawn_with_loader(loader_path, invoke_path, process.argv.slice(2));
18
19
  if (!spawned.ok) {
19
- process.exitCode = spawned.code || 1;
20
+ process.exitCode = spawn_result_is_exited(spawned) ? spawned.code : 1;
20
21
  }
@@ -113,7 +113,7 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
113
113
  return;
114
114
  print_build_result(log, build_result);
115
115
  deps = parse_deps(metafile.inputs, dir);
116
- server_process?.restart();
116
+ void server_process?.restart();
117
117
  }, { delay: rebuild_throttle_delay });
118
118
  await rebuild();
119
119
  if (watch) {
@@ -1 +1 @@
1
- {"version":3,"file":"gro_plugin_sveltekit_app.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAMxC,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,GAAI,gBAEtC,4BAAiC,KAAG,MAqCtC,CAAC"}
1
+ {"version":3,"file":"gro_plugin_sveltekit_app.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAMxC,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,GAAI,gBAEtC,4BAAiC,KAAG,MAuCtC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { spawn_result_to_message } from '@fuzdev/fuz_util/process.js';
1
2
  import { serialize_args, to_forwarded_args } from "./args.js";
2
3
  import { TaskError } from "./task.js";
3
4
  import { find_cli, spawn_cli, spawn_cli_process } from "./cli.js";
@@ -26,7 +27,7 @@ export const gro_plugin_sveltekit_app = ({ vite_cli = VITE_CLI, } = {}) => {
26
27
  const serialized_args = ['build', ...serialize_args(to_forwarded_args(vite_cli))];
27
28
  const spawned = await spawn_cli(found_vite_cli, serialized_args, log);
28
29
  if (!spawned?.ok) {
29
- throw new TaskError(`${vite_cli} build failed with exit code ${spawned?.code}`);
30
+ throw new TaskError(`${vite_cli} build failed: ${spawned ? spawn_result_to_message(spawned) : 'unknown error'}`);
30
31
  }
31
32
  }
32
33
  },
@@ -1 +1 @@
1
- {"version":3,"file":"gro_plugin_sveltekit_library.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_library.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAqB,KAAK,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAGrF,MAAM,WAAW,gCAAgC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,oBAAoB,CAAC;IAC9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,4BAA4B,GAAI,kDAG1C,gCAAqC,KAAG,MAoC1C,CAAC"}
1
+ {"version":3,"file":"gro_plugin_sveltekit_library.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/gro_plugin_sveltekit_library.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAqB,KAAK,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAGrF,MAAM,WAAW,gCAAgC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,oBAAoB,CAAC;IAC9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,4BAA4B,GAAI,kDAG1C,gCAAqC,KAAG,MAsC1C,CAAC"}
@@ -1,4 +1,4 @@
1
- import { print_spawn_result, spawn } from '@fuzdev/fuz_util/process.js';
1
+ import { print_spawn_result, spawn, spawn_result_to_message } from '@fuzdev/fuz_util/process.js';
2
2
  import { TaskError } from "./task.js";
3
3
  import { package_json_load } from "./package_json.js";
4
4
  import { run_svelte_package } from "./sveltekit_helpers.js";
@@ -20,7 +20,7 @@ export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_pa
20
20
  await Promise.all(Object.values(package_json.bin).map(async (bin_path) => {
21
21
  const chmod_result = await spawn('chmod', ['+x', bin_path]);
22
22
  if (!chmod_result.ok)
23
- log.error(`chmod on bin path ${bin_path} failed with code ${chmod_result.code}`);
23
+ log.error(`chmod on bin path ${bin_path} failed: ${spawn_result_to_message(chmod_result)}`);
24
24
  }));
25
25
  log.info(`linking`);
26
26
  const link_result = await spawn(config.pm_cli, ['link', '-f']); // TODO don't use `-f` unless necessary or at all?
package/dist/invoke.js CHANGED
@@ -1,4 +1,4 @@
1
- import { attach_process_error_handlers } from '@fuzdev/fuz_util/process.js';
1
+ import { attach_process_error_handler } from '@fuzdev/fuz_util/process.js';
2
2
  import { configure_print_colors } from '@fuzdev/fuz_util/print.js';
3
3
  import { invoke_task } from "./invoke_task.js";
4
4
  import { to_task_args } from "./args.js";
@@ -15,7 +15,10 @@ and the rest of the args are forwarded to the task's `run` function.
15
15
 
16
16
  */
17
17
  // handle uncaught errors
18
- attach_process_error_handlers((err) => (err.constructor.name === 'TaskError' ? 'TaskError' : null), (err) => (err.constructor.name === 'SilentError' ? '' : null));
18
+ attach_process_error_handler({
19
+ to_error_label: (err) => (err.constructor.name === 'TaskError' ? 'TaskError' : null),
20
+ map_error_text: (err) => (err.constructor.name === 'SilentError' ? '' : null),
21
+ });
19
22
  if (!process.env.NO_COLOR) {
20
23
  const { styleText } = await import('node:util');
21
24
  configure_print_colors(styleText);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AA2EvD,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,QA0GlB,CAAC;AAEF,cAAc;AACd,eAAO,MAAM,OAAO,EAAE,WAsDrB,CAAC"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAoEvD,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,QA0GlB,CAAC;AAEF,cAAc;AACd,eAAO,MAAM,OAAO,EAAE,WA+CrB,CAAC"}
package/dist/loader.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import { compile, compileModule, preprocess } from 'svelte/compiler';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { dirname, join } from 'node:path';
4
- import { escape_regexp } from '@fuzdev/fuz_util/regexp.js';
5
4
  import { readFileSync } from 'node:fs';
6
5
  import ts_blank_space from 'ts-blank-space';
7
6
  import { render_env_shim_module } from "./sveltekit_shim_env.js";
8
7
  import { render_sveltekit_shim_app_environment, render_sveltekit_shim_app_paths, SVELTEKIT_SHIM_APP_ENVIRONMENT_MATCHER, SVELTEKIT_SHIM_APP_PATHS_MATCHER, sveltekit_shim_app_specifiers, } from "./sveltekit_shim_app.js";
9
8
  import { default_svelte_config } from "./svelte_config.js";
10
- import { IS_THIS_GRO, paths } from "./paths.js";
11
- import { NODE_MODULES_DIRNAME, TS_MATCHER, SVELTE_MATCHER, SVELTE_RUNES_MATCHER, } from "./constants.js";
9
+ import { paths } from "./paths.js";
10
+ import { TS_MATCHER, SVELTE_MATCHER, SVELTE_RUNES_MATCHER } from "./constants.js";
12
11
  import { resolve_specifier } from "./resolve_specifier.js";
13
12
  import { map_sveltekit_aliases } from "./sveltekit_helpers.js";
14
13
  // TODO get out of the loader business, starting with https://nodejs.org/api/typescript.html#type-stripping
@@ -43,7 +42,6 @@ const dir = paths.root;
43
42
  const { alias, base_url, assets_url, env_dir, private_prefix, public_prefix, svelte_compile_options, svelte_compile_module_options, svelte_preprocessors, } = default_svelte_config;
44
43
  const aliases = Object.entries(alias);
45
44
  const RAW_MATCHER = /(%3Fraw|\.css|\.svg)$/; // TODO others? configurable?
46
- const NODE_MODULES_MATCHER = new RegExp(escape_regexp('/' + NODE_MODULES_DIRNAME + '/'), 'u');
47
45
  /** @nodocs */
48
46
  export const load = async (url, context, nextLoad) => {
49
47
  // console.log(`url`, url);
@@ -174,22 +172,17 @@ export const resolve = async (specifier, context, nextResolve) => {
174
172
  if (shimmed !== undefined) {
175
173
  return nextResolve(shimmed, context);
176
174
  }
177
- // Special case for Gro's dependencies that import into Gro.
178
- // Without this, we'd need to add a dev dep to Gro for Gro, which causes problems.
179
- // TODO maybe make this generic, checking `package_json.name` against `s` and map it, possibly need to export `resolve_exported_value`
180
- if (IS_THIS_GRO && s.startsWith('@ryanatkn/gro')) {
181
- s = join(dir, 'dist', s.substring(13));
182
- }
183
- const parent_url = context.parentURL;
184
- if (!parent_url || NODE_MODULES_MATCHER.test(parent_url)) {
185
- return nextResolve(s, context);
186
- }
175
+ // Apply SvelteKit aliases (handles self-referencing packages like @fuzdev/fuz_util -> src/lib)
187
176
  s = map_sveltekit_aliases(s, aliases);
188
- // The specifier has now been mapped to its final form, so we can inspect it.
189
- // Imports into `node_modules` use the default algorithm, and the rest use use Vite conventions.
177
+ // Bare specifiers (not starting with . or /) use Node's default resolution
190
178
  if (s[0] !== '.' && s[0] !== '/') {
191
179
  return nextResolve(s, context);
192
180
  }
181
+ // Resolve paths using Vite conventions
182
+ const parent_url = context.parentURL;
183
+ if (!parent_url) {
184
+ return nextResolve(s, context);
185
+ }
193
186
  const resolved = await resolve_specifier(s, dirname(fileURLToPath(parent_url)));
194
187
  return {
195
188
  url: pathToFileURL(resolved.path_id_with_querystring).href,
@@ -1 +1 @@
1
- {"version":3,"file":"run.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/run.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAI/C;;;;;GAKG;AAEH,cAAc;AACd,eAAO,MAAM,IAAI;;8JAWf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA+B3B,CAAC"}
1
+ {"version":3,"file":"run.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/run.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAK/C;;;;;GAKG;AAEH,cAAc;AACd,eAAO,MAAM,IAAI;;8JAWf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA+B3B,CAAC"}
package/dist/run.task.js CHANGED
@@ -3,6 +3,7 @@ import { styleText as st } from 'node:util';
3
3
  import { fs_exists } from '@fuzdev/fuz_util/fs.js';
4
4
  import { TaskError } from "./task.js";
5
5
  import { resolve_gro_module_path, spawn_with_loader } from "./gro_helpers.js";
6
+ import { spawn_result_to_message } from '@fuzdev/fuz_util/process.js';
6
7
  import { serialize_args, to_implicit_forwarded_args } from "./args.js";
7
8
  /**
8
9
  * Runs a TypeScript file with Gro's loader, forwarding all args to the script.
@@ -44,7 +45,7 @@ export const task = {
44
45
  const loader_path = resolve_gro_module_path('loader.js');
45
46
  const spawned = await spawn_with_loader(loader_path, path, full_argv);
46
47
  if (!spawned.ok) {
47
- throw new TaskError(`\`gro run ${path}\` failed with exit code ${spawned.code}`);
48
+ throw new TaskError(`\`gro run ${path}\` failed: ${spawn_result_to_message(spawned)}`);
48
49
  }
49
50
  },
50
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"test.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/test.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAO/C,cAAc;AACd,eAAO,MAAM,IAAI;;;;;kBAWf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAgC3B,CAAC"}
1
+ {"version":3,"file":"test.task.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/test.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAO/C,cAAc;AACd,eAAO,MAAM,IAAI;;;;;kBAWf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,cAAc;AACd,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAkC3B,CAAC"}
package/dist/test.task.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { spawn_cli } from './cli.js';
3
+ import { spawn_result_to_message } from '@fuzdev/fuz_util/process.js';
3
4
  import { TaskError } from "./task.js";
4
5
  import { find_cli } from "./cli.js";
5
6
  import { package_json_has_dependency, package_json_load } from "./package_json.js";
@@ -45,7 +46,7 @@ export const task = {
45
46
  vitest_args.push(...serialize_args(to_implicit_forwarded_args(VITEST_CLI)));
46
47
  const spawned = await spawn_cli(VITEST_CLI, vitest_args);
47
48
  if (!spawned?.ok) {
48
- throw new TaskError(`vitest failed with exit code ${spawned?.code}`);
49
+ throw new TaskError(`vitest failed: ${spawned ? spawn_result_to_message(spawned) : 'unknown error'}`);
49
50
  }
50
51
  },
51
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.185.0",
3
+ "version": "0.187.0",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
@@ -60,7 +60,7 @@
60
60
  "zod": "^4.1.13"
61
61
  },
62
62
  "peerDependencies": {
63
- "@fuzdev/fuz_util": ">=0.42.0",
63
+ "@fuzdev/fuz_util": ">=0.46.0",
64
64
  "@sveltejs/kit": "^2",
65
65
  "esbuild": "^0.27.0",
66
66
  "svelte": "^5",
@@ -81,16 +81,17 @@
81
81
  "devDependencies": {
82
82
  "@changesets/changelog-git": "^0.2.1",
83
83
  "@changesets/types": "^6.1.0",
84
- "@fuzdev/fuz_code": "^0.38.0",
85
- "@fuzdev/fuz_css": "^0.42.1",
86
- "@fuzdev/fuz_ui": "^0.177.0",
87
- "@fuzdev/fuz_util": "^0.45.3",
84
+ "@fuzdev/fuz_code": "^0.40.0",
85
+ "@fuzdev/fuz_css": "^0.44.1",
86
+ "@fuzdev/fuz_ui": "^0.179.0",
87
+ "@fuzdev/fuz_util": "^0.46.0",
88
88
  "@ryanatkn/eslint-config": "^0.9.0",
89
89
  "@sveltejs/adapter-static": "^3.0.10",
90
90
  "@sveltejs/kit": "^2.49.1",
91
91
  "@sveltejs/package": "^2.5.7",
92
92
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
93
93
  "@types/node": "^24.10.1",
94
+ "@webref/css": "^8.2.0",
94
95
  "esbuild": "^0.27.1",
95
96
  "eslint": "^9.39.1",
96
97
  "eslint-plugin-svelte": "^3.13.1",
package/src/lib/gro.ts CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  import {join} from 'node:path';
6
6
 
7
+ import {spawn_result_is_exited} from '@fuzdev/fuz_util/process.js';
8
+
7
9
  import {resolve_gro_module_path, spawn_with_loader} from './gro_helpers.ts';
8
10
 
9
11
  /*
@@ -23,5 +25,5 @@ const loader_path = join(invoke_path, '../loader.js');
23
25
 
24
26
  const spawned = await spawn_with_loader(loader_path, invoke_path, process.argv.slice(2));
25
27
  if (!spawned.ok) {
26
- process.exitCode = spawned.code || 1;
28
+ process.exitCode = spawn_result_is_exited(spawned) ? spawned.code : 1;
27
29
  }
@@ -225,7 +225,7 @@ export const gro_plugin_server = ({
225
225
  if (!metafile) return;
226
226
  print_build_result(log, build_result);
227
227
  deps = parse_deps(metafile.inputs, dir);
228
- server_process?.restart();
228
+ void server_process?.restart();
229
229
  },
230
230
  {delay: rebuild_throttle_delay},
231
231
  );
@@ -1,4 +1,4 @@
1
- import type {SpawnedProcess} from '@fuzdev/fuz_util/process.js';
1
+ import {spawn_result_to_message, type SpawnedProcess} from '@fuzdev/fuz_util/process.js';
2
2
 
3
3
  import type {Plugin} from './plugin.ts';
4
4
  import {serialize_args, to_forwarded_args} from './args.ts';
@@ -41,7 +41,9 @@ export const gro_plugin_sveltekit_app = ({
41
41
  const serialized_args = ['build', ...serialize_args(to_forwarded_args(vite_cli))];
42
42
  const spawned = await spawn_cli(found_vite_cli, serialized_args, log);
43
43
  if (!spawned?.ok) {
44
- throw new TaskError(`${vite_cli} build failed with exit code ${spawned?.code}`);
44
+ throw new TaskError(
45
+ `${vite_cli} build failed: ${spawned ? spawn_result_to_message(spawned) : 'unknown error'}`,
46
+ );
45
47
  }
46
48
  }
47
49
  },
@@ -1,4 +1,4 @@
1
- import {print_spawn_result, spawn} from '@fuzdev/fuz_util/process.js';
1
+ import {print_spawn_result, spawn, spawn_result_to_message} from '@fuzdev/fuz_util/process.js';
2
2
 
3
3
  import type {Plugin} from './plugin.ts';
4
4
  import {TaskError} from './task.ts';
@@ -46,7 +46,9 @@ export const gro_plugin_sveltekit_library = ({
46
46
  Object.values(package_json.bin).map(async (bin_path) => {
47
47
  const chmod_result = await spawn('chmod', ['+x', bin_path]);
48
48
  if (!chmod_result.ok)
49
- log.error(`chmod on bin path ${bin_path} failed with code ${chmod_result.code}`);
49
+ log.error(
50
+ `chmod on bin path ${bin_path} failed: ${spawn_result_to_message(chmod_result)}`,
51
+ );
50
52
  }),
51
53
  );
52
54
  log.info(`linking`);
package/src/lib/invoke.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {attach_process_error_handlers} from '@fuzdev/fuz_util/process.js';
1
+ import {attach_process_error_handler} from '@fuzdev/fuz_util/process.js';
2
2
  import {configure_print_colors} from '@fuzdev/fuz_util/print.js';
3
3
 
4
4
  import {invoke_task} from './invoke_task.ts';
@@ -18,10 +18,10 @@ and the rest of the args are forwarded to the task's `run` function.
18
18
  */
19
19
 
20
20
  // handle uncaught errors
21
- attach_process_error_handlers(
22
- (err) => (err.constructor.name === 'TaskError' ? 'TaskError' : null),
23
- (err) => (err.constructor.name === 'SilentError' ? '' : null),
24
- );
21
+ attach_process_error_handler({
22
+ to_error_label: (err) => (err.constructor.name === 'TaskError' ? 'TaskError' : null),
23
+ map_error_text: (err) => (err.constructor.name === 'SilentError' ? '' : null),
24
+ });
25
25
 
26
26
  if (!process.env.NO_COLOR) {
27
27
  const {styleText} = await import('node:util');
package/src/lib/loader.ts CHANGED
@@ -2,7 +2,6 @@ import {compile, compileModule, preprocess} from 'svelte/compiler';
2
2
  import {fileURLToPath, pathToFileURL} from 'node:url';
3
3
  import {dirname, join} from 'node:path';
4
4
  import type {LoadHook, ResolveHook} from 'node:module';
5
- import {escape_regexp} from '@fuzdev/fuz_util/regexp.js';
6
5
  import {readFileSync} from 'node:fs';
7
6
  import ts_blank_space from 'ts-blank-space';
8
7
 
@@ -15,13 +14,8 @@ import {
15
14
  sveltekit_shim_app_specifiers,
16
15
  } from './sveltekit_shim_app.ts';
17
16
  import {default_svelte_config} from './svelte_config.ts';
18
- import {IS_THIS_GRO, paths} from './paths.ts';
19
- import {
20
- NODE_MODULES_DIRNAME,
21
- TS_MATCHER,
22
- SVELTE_MATCHER,
23
- SVELTE_RUNES_MATCHER,
24
- } from './constants.ts';
17
+ import {paths} from './paths.ts';
18
+ import {TS_MATCHER, SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './constants.ts';
25
19
  import {resolve_specifier} from './resolve_specifier.ts';
26
20
  import {map_sveltekit_aliases} from './sveltekit_helpers.ts';
27
21
 
@@ -74,7 +68,6 @@ const {
74
68
  const aliases = Object.entries(alias);
75
69
 
76
70
  const RAW_MATCHER = /(%3Fraw|\.css|\.svg)$/; // TODO others? configurable?
77
- const NODE_MODULES_MATCHER = new RegExp(escape_regexp('/' + NODE_MODULES_DIRNAME + '/'), 'u');
78
71
 
79
72
  /** @nodocs */
80
73
  export const load: LoadHook = async (url, context, nextLoad) => {
@@ -212,24 +205,17 @@ export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
212
205
  return nextResolve(shimmed, context);
213
206
  }
214
207
 
215
- // Special case for Gro's dependencies that import into Gro.
216
- // Without this, we'd need to add a dev dep to Gro for Gro, which causes problems.
217
- // TODO maybe make this generic, checking `package_json.name` against `s` and map it, possibly need to export `resolve_exported_value`
218
- if (IS_THIS_GRO && s.startsWith('@ryanatkn/gro')) {
219
- s = join(dir, 'dist', s.substring(13));
220
- }
208
+ // Apply SvelteKit aliases (handles self-referencing packages like @fuzdev/fuz_util -> src/lib)
209
+ s = map_sveltekit_aliases(s, aliases);
221
210
 
222
- const parent_url = context.parentURL;
223
- if (!parent_url || NODE_MODULES_MATCHER.test(parent_url)) {
211
+ // Bare specifiers (not starting with . or /) use Node's default resolution
212
+ if (s[0] !== '.' && s[0] !== '/') {
224
213
  return nextResolve(s, context);
225
214
  }
226
215
 
227
- s = map_sveltekit_aliases(s, aliases);
228
-
229
- // The specifier has now been mapped to its final form, so we can inspect it.
230
-
231
- // Imports into `node_modules` use the default algorithm, and the rest use use Vite conventions.
232
- if (s[0] !== '.' && s[0] !== '/') {
216
+ // Resolve paths using Vite conventions
217
+ const parent_url = context.parentURL;
218
+ if (!parent_url) {
233
219
  return nextResolve(s, context);
234
220
  }
235
221
 
@@ -4,6 +4,7 @@ import {fs_exists} from '@fuzdev/fuz_util/fs.js';
4
4
 
5
5
  import {TaskError, type Task} from './task.ts';
6
6
  import {resolve_gro_module_path, spawn_with_loader} from './gro_helpers.ts';
7
+ import {spawn_result_to_message} from '@fuzdev/fuz_util/process.js';
7
8
  import {serialize_args, to_implicit_forwarded_args} from './args.ts';
8
9
 
9
10
  /**
@@ -57,7 +58,7 @@ export const task: Task<Args> = {
57
58
 
58
59
  const spawned = await spawn_with_loader(loader_path, path, full_argv);
59
60
  if (!spawned.ok) {
60
- throw new TaskError(`\`gro run ${path}\` failed with exit code ${spawned.code}`);
61
+ throw new TaskError(`\`gro run ${path}\` failed: ${spawn_result_to_message(spawned)}`);
61
62
  }
62
63
  },
63
64
  };
@@ -1,5 +1,6 @@
1
1
  import {z} from 'zod';
2
2
  import {spawn_cli} from '@ryanatkn/gro/cli.js';
3
+ import {spawn_result_to_message} from '@fuzdev/fuz_util/process.js';
3
4
 
4
5
  import {TaskError, type Task} from './task.ts';
5
6
  import {find_cli} from './cli.ts';
@@ -53,7 +54,9 @@ export const task: Task<Args> = {
53
54
 
54
55
  const spawned = await spawn_cli(VITEST_CLI, vitest_args);
55
56
  if (!spawned?.ok) {
56
- throw new TaskError(`vitest failed with exit code ${spawned?.code}`);
57
+ throw new TaskError(
58
+ `vitest failed: ${spawned ? spawn_result_to_message(spawned) : 'unknown error'}`,
59
+ );
57
60
  }
58
61
  },
59
62
  };