@ryanatkn/gro 0.185.0 → 0.186.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.
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.185.0",
3
+ "version": "0.186.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.45.3",
64
64
  "@sveltejs/kit": "^2",
65
65
  "esbuild": "^0.27.0",
66
66
  "svelte": "^5",
@@ -82,8 +82,8 @@
82
82
  "@changesets/changelog-git": "^0.2.1",
83
83
  "@changesets/types": "^6.1.0",
84
84
  "@fuzdev/fuz_code": "^0.38.0",
85
- "@fuzdev/fuz_css": "^0.42.1",
86
- "@fuzdev/fuz_ui": "^0.177.0",
85
+ "@fuzdev/fuz_css": "^0.44.1",
86
+ "@fuzdev/fuz_ui": "^0.178.1",
87
87
  "@fuzdev/fuz_util": "^0.45.3",
88
88
  "@ryanatkn/eslint-config": "^0.9.0",
89
89
  "@sveltejs/adapter-static": "^3.0.10",
@@ -91,6 +91,7 @@
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/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