@ryanatkn/gro 0.141.1 → 0.142.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.
Files changed (54) hide show
  1. package/dist/changeset.task.d.ts.map +1 -1
  2. package/dist/changeset.task.js +2 -2
  3. package/dist/filer.d.ts +7 -0
  4. package/dist/filer.d.ts.map +1 -1
  5. package/dist/filer.js +28 -29
  6. package/dist/gro_config.d.ts +5 -0
  7. package/dist/gro_config.d.ts.map +1 -1
  8. package/dist/gro_config.js +3 -1
  9. package/dist/gro_plugin_sveltekit_library.js +4 -4
  10. package/dist/loader.d.ts.map +1 -1
  11. package/dist/loader.js +22 -16
  12. package/dist/moss_helpers.d.ts.map +1 -1
  13. package/dist/moss_helpers.js +2 -1
  14. package/dist/package.d.ts +326 -164
  15. package/dist/package.d.ts.map +1 -1
  16. package/dist/package.js +15 -15
  17. package/dist/package_json.d.ts +9 -6
  18. package/dist/package_json.d.ts.map +1 -1
  19. package/dist/package_json.js +19 -4
  20. package/dist/publish.task.d.ts.map +1 -1
  21. package/dist/publish.task.js +3 -8
  22. package/dist/reinstall.task.js +4 -4
  23. package/dist/resolve_node_specifier.d.ts +7 -1
  24. package/dist/resolve_node_specifier.d.ts.map +1 -1
  25. package/dist/resolve_node_specifier.js +77 -13
  26. package/dist/resolve_specifier.d.ts +2 -6
  27. package/dist/resolve_specifier.d.ts.map +1 -1
  28. package/dist/resolve_specifier.js +2 -6
  29. package/dist/src_json.d.ts +39 -3
  30. package/dist/src_json.d.ts.map +1 -1
  31. package/dist/sveltekit_config.d.ts +1 -1
  32. package/dist/sveltekit_config.d.ts.map +1 -1
  33. package/dist/sync.task.js +1 -1
  34. package/dist/upgrade.task.d.ts.map +1 -1
  35. package/dist/upgrade.task.js +4 -2
  36. package/dist/watch_dir.d.ts.map +1 -1
  37. package/dist/watch_dir.js +5 -5
  38. package/package.json +14 -14
  39. package/src/lib/changeset.task.ts +2 -1
  40. package/src/lib/filer.ts +37 -27
  41. package/src/lib/gro_config.ts +8 -0
  42. package/src/lib/gro_plugin_sveltekit_library.ts +4 -4
  43. package/src/lib/loader.ts +24 -16
  44. package/src/lib/moss_helpers.ts +2 -1
  45. package/src/lib/package.ts +15 -15
  46. package/src/lib/package_json.ts +21 -4
  47. package/src/lib/publish.task.ts +3 -9
  48. package/src/lib/reinstall.task.ts +4 -4
  49. package/src/lib/resolve_node_specifier.ts +99 -17
  50. package/src/lib/resolve_specifier.ts +2 -6
  51. package/src/lib/sveltekit_config.ts +1 -1
  52. package/src/lib/sync.task.ts +1 -1
  53. package/src/lib/upgrade.task.ts +4 -2
  54. package/src/lib/watch_dir.ts +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"changeset.task.d.ts","sourceRoot":"../src/lib/","sources":["changeset.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAchD,eAAO,MAAM,IAAI;IAEf;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBK,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAiF3B,CAAC"}
1
+ {"version":3,"file":"changeset.task.d.ts","sourceRoot":"../src/lib/","sources":["changeset.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAchD,eAAO,MAAM,IAAI;IAEf;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBK,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAkF3B,CAAC"}
@@ -44,7 +44,7 @@ export const task = {
44
44
  summary: 'call changeset with gro patterns',
45
45
  Args,
46
46
  run: async (ctx) => {
47
- const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, dep, origin, changeset_cli }, log, sveltekit_config, } = ctx;
47
+ const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, dep, origin, changeset_cli }, log, sveltekit_config, config, } = ctx;
48
48
  const message = _.join(' ');
49
49
  if (!message && (minor || major))
50
50
  throw new Task_Error('cannot bump version without a message');
@@ -79,7 +79,7 @@ export const task = {
79
79
  }
80
80
  await spawn('git', ['add', dir]);
81
81
  if (dep) {
82
- await spawn('npm', ['i', '-D', changelog]);
82
+ await spawn(config.pm_cli, ['i', '-D', changelog]);
83
83
  }
84
84
  }
85
85
  // TODO small problem here where generated files don't get committed
package/dist/filer.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Omit_Strict } from '@ryanatkn/belt/types.js';
2
2
  import type { Path_Id } from './path.js';
3
3
  import { watch_dir, type Watcher_Change, type Options as Watch_Dir_Options } from './watch_dir.js';
4
+ import type { Package_Json } from './package_json.js';
4
5
  export interface Source_File {
5
6
  id: Path_Id;
6
7
  /**
@@ -8,6 +9,11 @@ export interface Source_File {
8
9
  * We create the file in memory to track its dependents regardless of its existence on disk.
9
10
  */
10
11
  contents: string | null;
12
+ /**
13
+ * Is the source file outside of the `root_dir` or excluded by `watch_dir_options.filter`?
14
+ */
15
+ external: boolean;
16
+ ctime: number | null;
11
17
  mtime: number | null;
12
18
  dependents: Map<Path_Id, Source_File>;
13
19
  dependencies: Map<Path_Id, Source_File>;
@@ -17,6 +23,7 @@ export type On_Filer_Change = (change: Watcher_Change, source_file: Source_File)
17
23
  export interface Options {
18
24
  watch_dir?: typeof watch_dir;
19
25
  watch_dir_options?: Partial<Omit_Strict<Watch_Dir_Options, 'on_change'>>;
26
+ package_json_cache?: Record<string, Package_Json>;
20
27
  }
21
28
  export declare class Filer {
22
29
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":["filer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EACN,SAAS,EAET,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,iBAAiB,EAEjC,MAAM,gBAAgB,CAAC;AAYxB,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IAEZ;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACtC,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;AAEzF,MAAM,WAAW,OAAO;IACvB,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;CACzE;AAED,qBAAa,KAAK;;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;gBAK1C,OAAO,GAAE,OAAsB;IAW3C,SAAS,OAAQ,OAAO,KAAG,WAAW,GAAG,SAAS,CAEhD;IAEF,aAAa,OAAQ,OAAO,KAAG,WAAW,CAYxC;IA+II,KA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K;;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;gBAO1C,OAAO,GAAE,OAAsB;IAY3C,SAAS,OAAQ,OAAO,KAAG,WAAW,GAAG,SAAS,CAEhD;IAEF,aAAa,OAAQ,OAAO,KAAG,WAAW,CAkBxC;IAmII,KAAK,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAKxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5B"}
package/dist/filer.js CHANGED
@@ -9,6 +9,7 @@ import { resolve_specifier } from './resolve_specifier.js';
9
9
  import { default_sveltekit_config } from './sveltekit_config.js';
10
10
  import { map_sveltekit_aliases } from './sveltekit_helpers.js';
11
11
  import { Unreachable_Error } from '@ryanatkn/belt/error.js';
12
+ import { resolve_node_specifier } from './resolve_node_specifier.js';
12
13
  // TODO see below
13
14
  // import {resolve_node_specifier} from './resolve_node_specifier.js';
14
15
  const aliases = Object.entries(default_sveltekit_config.alias);
@@ -17,10 +18,12 @@ export class Filer {
17
18
  files = new Map();
18
19
  #watch_dir;
19
20
  #watch_dir_options;
21
+ #package_json_cache;
20
22
  constructor(options = EMPTY_OBJECT) {
21
23
  this.#watch_dir = options.watch_dir ?? watch_dir;
22
24
  this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
23
25
  this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
26
+ this.#package_json_cache = options.package_json_cache ?? {};
24
27
  }
25
28
  #watching;
26
29
  #listeners = new Set();
@@ -35,18 +38,23 @@ export class Filer {
35
38
  const file = {
36
39
  id,
37
40
  contents: null,
41
+ external: this.#is_external(id), // TODO maybe filter externals by default? the user needs to configure the filer then
42
+ ctime: null,
38
43
  mtime: null,
39
44
  dependents: new Map(),
40
45
  dependencies: new Map(),
41
46
  };
42
47
  this.files.set(id, file);
48
+ // TODO this may need to be batched/deferred
49
+ if (file.external) {
50
+ this.#on_change({ type: 'add', path: file.id, is_directory: false });
51
+ }
43
52
  return file;
44
53
  };
45
54
  #update(id) {
46
55
  const file = this.get_or_create(id);
47
56
  const stats = existsSync(id) ? statSync(id) : null;
48
- // const mtime_prev = file.mtime;
49
- // const mtime_changed = mtime_prev !== (stats?.mtimeMs ?? null);
57
+ file.ctime = stats?.ctimeMs ?? null;
50
58
  file.mtime = stats?.mtimeMs ?? null;
51
59
  const new_contents = stats ? readFileSync(id, 'utf8') : null;
52
60
  if (file.contents === new_contents) {
@@ -61,37 +69,24 @@ export class Filer {
61
69
  // TODO logic is duplicated from loader
62
70
  const path = map_sveltekit_aliases(specifier, aliases);
63
71
  // The specifier `path` has now been mapped to its final form, so we can inspect it.
64
- if (path[0] === '.' || path[0] === '/') {
65
- const { path_id } = resolve_specifier(path, dir);
66
- dependencies_removed.delete(path_id);
67
- if (!dependencies_before.has(path_id)) {
68
- const d = this.get_or_create(path_id);
69
- file.dependencies.set(d.id, d);
70
- d.dependents.set(file.id, file);
71
- }
72
+ const resolved = path[0] === '.' || path[0] === '/'
73
+ ? resolve_specifier(path, dir)
74
+ : resolve_node_specifier(path, undefined, file.id, this.#package_json_cache, false);
75
+ if (!resolved)
76
+ continue; // ignore any missing imports like Node identifiers
77
+ const { path_id } = resolved;
78
+ dependencies_removed.delete(path_id);
79
+ if (!dependencies_before.has(path_id)) {
80
+ const d = this.get_or_create(path_id);
81
+ file.dependencies.set(d.id, d);
82
+ d.dependents.set(file.id, file);
72
83
  }
73
- // TODO this doesn't work
74
- // const resolved =
75
- // path[0] === '.' || path[0] === '/'
76
- // ? resolve_specifier(path, dir)
77
- // : resolve_node_specifier(path, dir);
78
- // const {path_id} = resolved;
79
- // dependencies_removed.delete(path_id);
80
- // if (!dependencies_before.has(path_id)) {
81
- // const d = this.get_or_create(path_id);
82
- // file.dependencies.set(d.id, d);
83
- // d.dependents.set(file.id, file);
84
- // }
85
84
  }
86
85
  // update any removed dependencies
87
86
  for (const dependency_removed of dependencies_removed) {
88
- const deleted1 = file.dependencies.delete(dependency_removed);
89
- if (!deleted1)
90
- throw Error('expected to delete1 ' + file.id); // TODO @many delete if correct
87
+ file.dependencies.delete(dependency_removed);
91
88
  const dependency_removed_file = this.get_or_create(dependency_removed);
92
- const deleted2 = dependency_removed_file.dependents.delete(file.id);
93
- if (!deleted2)
94
- throw Error('expected to delete2 ' + file.id); // TODO @many delete if correct
89
+ dependency_removed_file.dependents.delete(file.id);
95
90
  }
96
91
  return file;
97
92
  }
@@ -151,7 +146,7 @@ export class Filer {
151
146
  }
152
147
  #on_change = (change) => {
153
148
  if (change.is_directory)
154
- return;
149
+ return; // TODO manage directories?
155
150
  let source_file;
156
151
  switch (change.type) {
157
152
  case 'add':
@@ -182,4 +177,8 @@ export class Filer {
182
177
  this.#watching = undefined;
183
178
  }
184
179
  }
180
+ #is_external(id) {
181
+ const { filter } = this.#watch_dir_options;
182
+ return !id.startsWith(this.root_dir + '/') || (!!filter && !filter(id, false));
183
+ }
185
184
  }
@@ -27,6 +27,10 @@ export interface Gro_Config {
27
27
  * directories and files are included if they pass all of these filters.
28
28
  */
29
29
  search_filters: Path_Filter[];
30
+ /**
31
+ * The CLI to use that's compatible with `npm install` and `npm link`. Defaults to `'npm'`.
32
+ */
33
+ pm_cli: string;
30
34
  }
31
35
  /**
32
36
  * The relaxed variant of `Gro_Config` that users can provide via `gro.config.ts`.
@@ -38,6 +42,7 @@ export interface Raw_Gro_Config {
38
42
  map_package_json?: Map_Package_Json | null;
39
43
  task_root_dirs?: string[];
40
44
  search_filters?: Path_Filter | Path_Filter[] | null;
45
+ pm_cli?: string;
41
46
  }
42
47
  export type Create_Gro_Config = (base_config: Gro_Config) => Raw_Gro_Config | Promise<Raw_Gro_Config>;
43
48
  export declare const create_empty_gro_config: () => Gro_Config;
@@ -1 +1 @@
1
- {"version":3,"file":"gro_config.d.ts","sourceRoot":"../src/lib/","sources":["gro_config.ts"],"names":[],"mappings":"AAY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iB;IACjC,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,iBAAiB,CAAC;CACrD;AAED,eAAO,MAAM,eAAe,oBAA6B,OAAO,CAAC,UAAU,CAiB1E,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,CACxC,aAAa,EAAE,GAAG,EAClB,WAAW,EAAE,MAAM,KACf,OAAO,CAAC,aAAa,IAAI,iBAS7B,CAAC"}
@@ -13,6 +13,7 @@ export const create_empty_gro_config = () => ({
13
13
  IS_THIS_GRO ? null : GRO_DIST_DIR,
14
14
  ].filter((v) => v !== null),
15
15
  search_filters: [(id) => !DEFAULT_SEARCH_EXCLUDER.test(id)],
16
+ pm_cli: 'npm',
16
17
  });
17
18
  /**
18
19
  * The regexp used by default to exclude directories and files
@@ -42,7 +43,7 @@ export const normalize_gro_config = (raw_config) => {
42
43
  const empty_config = create_empty_gro_config();
43
44
  // All of the raw config properties are optional,
44
45
  // so fall back to the empty values when `undefined`.
45
- const { plugins = empty_config.plugins, map_package_json = empty_config.map_package_json, task_root_dirs = empty_config.task_root_dirs, search_filters = empty_config.search_filters, } = raw_config;
46
+ const { plugins = empty_config.plugins, map_package_json = empty_config.map_package_json, task_root_dirs = empty_config.task_root_dirs, search_filters = empty_config.search_filters, pm_cli = empty_config.pm_cli, } = raw_config;
46
47
  return {
47
48
  plugins,
48
49
  map_package_json,
@@ -52,6 +53,7 @@ export const normalize_gro_config = (raw_config) => {
52
53
  : search_filters
53
54
  ? [search_filters]
54
55
  : [],
56
+ pm_cli,
55
57
  };
56
58
  };
57
59
  export const load_gro_config = async (dir = paths.root) => {
@@ -10,22 +10,22 @@ export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_pa
10
10
  await run_svelte_package(svelte_package_options, svelte_package_cli, log);
11
11
  }
12
12
  },
13
- adapt: async ({ log, timings }) => {
13
+ adapt: async ({ log, timings, config }) => {
14
14
  const package_json = load_package_json();
15
15
  // `npm link`
16
16
  if (package_json.bin) {
17
- const timing_to_npm_link = timings.start('npm link');
17
+ const timing_to_link = timings.start(`${config.pm_cli} link`);
18
18
  await Promise.all(Object.values(package_json.bin).map(async (bin_path) => {
19
19
  const chmod_result = await spawn('chmod', ['+x', bin_path]);
20
20
  if (!chmod_result.ok)
21
21
  log.error(`chmod on bin path ${bin_path} failed with code ${chmod_result.code}`);
22
22
  }));
23
23
  log.info(`linking`);
24
- const link_result = await spawn('npm', ['link', '-f']); // TODO don't use `-f` unless necessary or at all?
24
+ const link_result = await spawn(config.pm_cli, ['link', '-f']); // TODO don't use `-f` unless necessary or at all?
25
25
  if (!link_result.ok) {
26
26
  throw new Task_Error(`Failed to link. ${print_spawn_result(link_result)}`);
27
27
  }
28
- timing_to_npm_link();
28
+ timing_to_link();
29
29
  }
30
30
  },
31
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAgFvD,eAAO,MAAM,IAAI,EAAE,QAwFlB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WAoDrB,CAAC"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAgFvD,eAAO,MAAM,IAAI,EAAE,QAwFlB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WA4DrB,CAAC"}
package/dist/loader.js CHANGED
@@ -8,7 +8,7 @@ import { render_env_shim_module } from './sveltekit_shim_env.js';
8
8
  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
9
  import { default_sveltekit_config } from './sveltekit_config.js';
10
10
  import { SVELTE_MATCHER, SVELTE_RUNES_MATCHER } from './svelte_helpers.js';
11
- import { paths } from './paths.js';
11
+ import { IS_THIS_GRO, paths } from './paths.js';
12
12
  import { JSON_MATCHER, NODE_MODULES_DIRNAME, TS_MATCHER } from './path_constants.js';
13
13
  import { to_define_import_meta_env, default_ts_transform_options } from './esbuild_helpers.js';
14
14
  import { resolve_specifier } from './resolve_specifier.js';
@@ -132,34 +132,40 @@ export const load = async (url, context, nextLoad) => {
132
132
  return nextLoad(url, context);
133
133
  };
134
134
  export const resolve = async (specifier, context, nextResolve) => {
135
- if (specifier === '$env/static/public' ||
136
- specifier === '$env/static/private' ||
137
- specifier === '$env/dynamic/public' ||
138
- specifier === '$env/dynamic/private') {
135
+ let s = specifier;
136
+ // Support SvelteKit `$env` imports
137
+ if (s === '$env/static/public' ||
138
+ s === '$env/static/private' ||
139
+ s === '$env/dynamic/public' ||
140
+ s === '$env/dynamic/private') {
139
141
  // The returned `url` is validated before `load` is called,
140
142
  // so we need a slightly roundabout strategy to pass through the specifier for virtual files.
141
143
  return {
142
- url: pathToFileURL(join(dir, 'src/lib', specifier)).href,
144
+ url: pathToFileURL(join(dir, 'src/lib', s)).href,
143
145
  format: 'module',
144
146
  shortCircuit: true,
145
147
  };
146
148
  }
149
+ // Special case for Gro's dependencies that import into Gro.
150
+ // Without this, we'd need to add a dev dep to Gro for Gro, which causes problems.
151
+ if (IS_THIS_GRO && s.startsWith('@ryanatkn/gro')) {
152
+ s = join(dir, 'dist', s.substring(13));
153
+ }
147
154
  const parent_url = context.parentURL;
148
155
  if (!parent_url || NODE_MODULES_MATCHER.test(parent_url)) {
149
- return nextResolve(specifier, context);
156
+ return nextResolve(s, context);
150
157
  }
151
- const shimmed = sveltekit_shim_app_specifiers.get(specifier);
158
+ const shimmed = sveltekit_shim_app_specifiers.get(s);
152
159
  if (shimmed !== undefined) {
153
160
  return nextResolve(shimmed, context);
154
161
  }
155
- const path = map_sveltekit_aliases(specifier, aliases);
156
- // The specifier `path` has now been mapped to its final form, so we can inspect it.
157
- if (path[0] !== '.' && path[0] !== '/') {
162
+ s = map_sveltekit_aliases(s, aliases);
163
+ // The specifier has now been mapped to its final form, so we can inspect it.
164
+ if (s[0] !== '.' && s[0] !== '/') {
158
165
  // Resolve to `node_modules`.
159
- if (SVELTE_MATCHER.test(path) || JSON_MATCHER.test(path)) {
166
+ if (SVELTE_MATCHER.test(s) || JSON_MATCHER.test(s)) {
160
167
  // Match the behavior of Vite and esbuild for Svelte and JSON imports.
161
- // TODO `.ts` too
162
- const resolved = resolve_node_specifier(path, dir, parent_url, package_json_cache);
168
+ const resolved = resolve_node_specifier(s, dir, parent_url, package_json_cache); // `node:` specifiers shouldn't reach this point, so the assertion is safe
163
169
  return {
164
170
  url: pathToFileURL(resolved.path_id_with_querystring).href,
165
171
  format: 'module',
@@ -167,10 +173,10 @@ export const resolve = async (specifier, context, nextResolve) => {
167
173
  };
168
174
  }
169
175
  else {
170
- return nextResolve(path, context);
176
+ return nextResolve(s, context);
171
177
  }
172
178
  }
173
- const resolved = resolve_specifier(path, dirname(fileURLToPath(parent_url)));
179
+ const resolved = resolve_specifier(s, dirname(fileURLToPath(parent_url)));
174
180
  return {
175
181
  url: pathToFileURL(resolved.path_id_with_querystring).href,
176
182
  format: 'module',
@@ -1 +1 @@
1
- {"version":3,"file":"moss_helpers.d.ts","sourceRoot":"../src/lib/","sources":["moss_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,OAAO,EAAU,KAAK,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,kBACb,YAAY,0EAIzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CA4B3D,CAAC"}
1
+ {"version":3,"file":"moss_helpers.d.ts","sourceRoot":"../src/lib/","sources":["moss_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,OAAO,EAAU,KAAK,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,kBACb,YAAY,0EAIzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CA4B3D,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { has_dep } from './package_json.js';
4
+ import { NODE_MODULES_DIRNAME } from './path_constants.js';
4
5
  export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
5
6
  // TODO plugin type?
6
- export const load_moss_plugin = async (package_json, dep_name = MOSS_PACKAGE_DEP_NAME, plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
7
+ export const load_moss_plugin = async (package_json, dep_name = MOSS_PACKAGE_DEP_NAME, plugin_path = `${NODE_MODULES_DIRNAME}/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
7
8
  local_plugin_path = 'src/lib/gro_plugin_moss.ts') => {
8
9
  if (!has_dep(dep_name, package_json)) {
9
10
  return {