@ryanatkn/gro 0.133.2 → 0.133.4

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 (65) hide show
  1. package/dist/build.task.d.ts +6 -0
  2. package/dist/build.task.d.ts.map +1 -1
  3. package/dist/build.task.js +6 -3
  4. package/dist/check.task.d.ts +2 -2
  5. package/dist/dev.task.d.ts +2 -2
  6. package/dist/esbuild_helpers.d.ts +1 -1
  7. package/dist/esbuild_helpers.d.ts.map +1 -1
  8. package/dist/esbuild_helpers.js +1 -1
  9. package/dist/esbuild_plugin_external_worker.d.ts +2 -2
  10. package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
  11. package/dist/esbuild_plugin_external_worker.js +3 -1
  12. package/dist/esbuild_plugin_svelte.d.ts +7 -2
  13. package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
  14. package/dist/esbuild_plugin_svelte.js +20 -9
  15. package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +1 -1
  16. package/dist/esbuild_plugin_sveltekit_local_imports.js +3 -2
  17. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
  18. package/dist/esbuild_plugin_sveltekit_shim_app.js +3 -2
  19. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -1
  20. package/dist/esbuild_plugin_sveltekit_shim_env.js +6 -5
  21. package/dist/gro_plugin_server.d.ts.map +1 -1
  22. package/dist/gro_plugin_server.js +4 -10
  23. package/dist/gro_plugin_sveltekit_app.js +2 -2
  24. package/dist/loader.d.ts.map +1 -1
  25. package/dist/loader.js +14 -14
  26. package/dist/package.d.ts +0 -11
  27. package/dist/package.d.ts.map +1 -1
  28. package/dist/package.js +16 -18
  29. package/dist/path_constants.d.ts +3 -0
  30. package/dist/path_constants.d.ts.map +1 -1
  31. package/dist/path_constants.js +3 -0
  32. package/dist/paths.d.ts.map +1 -1
  33. package/dist/paths.js +3 -3
  34. package/dist/run_gen.js +2 -2
  35. package/dist/run_task.js +2 -2
  36. package/dist/sveltekit_config.d.ts +7 -2
  37. package/dist/sveltekit_config.d.ts.map +1 -1
  38. package/dist/sveltekit_config.js +11 -1
  39. package/dist/sveltekit_helpers.d.ts +2 -1
  40. package/dist/sveltekit_helpers.d.ts.map +1 -1
  41. package/dist/sveltekit_helpers.js +3 -2
  42. package/dist/task_logging.js +2 -4
  43. package/package.json +8 -12
  44. package/src/lib/build.task.ts +6 -3
  45. package/src/lib/esbuild_helpers.ts +1 -1
  46. package/src/lib/esbuild_plugin_external_worker.ts +4 -2
  47. package/src/lib/esbuild_plugin_svelte.ts +38 -11
  48. package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +16 -9
  49. package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +3 -2
  50. package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +7 -5
  51. package/src/lib/gro_plugin_server.ts +4 -11
  52. package/src/lib/gro_plugin_sveltekit_app.ts +2 -2
  53. package/src/lib/loader.ts +14 -16
  54. package/src/lib/package.ts +16 -18
  55. package/src/lib/path_constants.ts +4 -0
  56. package/src/lib/paths.ts +3 -3
  57. package/src/lib/run_gen.ts +2 -2
  58. package/src/lib/run_task.ts +2 -2
  59. package/src/lib/sveltekit_config.ts +21 -4
  60. package/src/lib/sveltekit_helpers.ts +4 -3
  61. package/src/lib/task_logging.ts +4 -6
  62. package/dist/sveltekit_config_global.d.ts +0 -5
  63. package/dist/sveltekit_config_global.d.ts.map +0 -1
  64. package/dist/sveltekit_config_global.js +0 -5
  65. package/src/lib/sveltekit_config_global.ts +0 -6
@@ -1,6 +1,8 @@
1
1
  import type * as esbuild from 'esbuild';
2
2
 
3
3
  import {render_env_shim_module} from './sveltekit_shim_env.js';
4
+ import {EVERYTHING_MATCHER} from './path_constants.js';
5
+ import {SVELTEKIT_ENV_MATCHER} from './sveltekit_helpers.js';
4
6
 
5
7
  export interface Options {
6
8
  dev: boolean;
@@ -11,6 +13,8 @@ export interface Options {
11
13
  ambient_env?: Record<string, string>;
12
14
  }
13
15
 
16
+ const namespace = 'sveltekit_shim_env';
17
+
14
18
  export const esbuild_plugin_sveltekit_shim_env = ({
15
19
  dev,
16
20
  public_prefix,
@@ -21,11 +25,9 @@ export const esbuild_plugin_sveltekit_shim_env = ({
21
25
  }: Options): esbuild.Plugin => ({
22
26
  name: 'sveltekit_shim_env',
23
27
  setup: (build) => {
24
- const namespace = 'sveltekit_shim_env';
25
- const filter = /^\$env\/(static|dynamic)\/(public|private)$/;
26
- build.onResolve({filter}, ({path}) => ({path, namespace}));
27
- build.onLoad({filter: /.*/, namespace}, ({path}) => {
28
- const matches = filter.exec(path);
28
+ build.onResolve({filter: SVELTEKIT_ENV_MATCHER}, ({path}) => ({path, namespace}));
29
+ build.onLoad({filter: EVERYTHING_MATCHER, namespace}, ({path}) => {
30
+ const matches = SVELTEKIT_ENV_MATCHER.exec(path);
29
31
  const mode = matches![1] as 'static' | 'dynamic';
30
32
  const visibility = matches![2] as 'public' | 'private';
31
33
  return {
@@ -12,7 +12,7 @@ import {base_path_to_path_id, LIB_DIRNAME, paths} from './paths.js';
12
12
  import type {Path_Id} from './path.js';
13
13
  import {GRO_DEV_DIRNAME, SERVER_DIST_PATH} from './path_constants.js';
14
14
  import {watch_dir, type Watch_Node_Fs} from './watch_dir.js';
15
- import {init_sveltekit_config} from './sveltekit_config.js';
15
+ import {init_sveltekit_config, default_sveltekit_config} from './sveltekit_config.js';
16
16
  import {esbuild_plugin_sveltekit_shim_app} from './esbuild_plugin_sveltekit_shim_app.js';
17
17
  import {esbuild_plugin_sveltekit_shim_env} from './esbuild_plugin_sveltekit_shim_env.js';
18
18
  import {print_build_result, to_define_import_meta_env} from './esbuild_helpers.js';
@@ -21,7 +21,6 @@ import {esbuild_plugin_external_worker} from './esbuild_plugin_external_worker.j
21
21
  import {esbuild_plugin_sveltekit_local_imports} from './esbuild_plugin_sveltekit_local_imports.js';
22
22
  import {esbuild_plugin_svelte} from './esbuild_plugin_svelte.js';
23
23
  import {throttle} from './throttle.js';
24
- import {sveltekit_config_global} from './sveltekit_config_global.js';
25
24
 
26
25
  // TODO sourcemap as a hoisted option? disable for production by default - or like `outpaths`, passed a `dev` param
27
26
 
@@ -133,7 +132,7 @@ export const gro_plugin_server = ({
133
132
  setup: async ({dev, watch, timings, log}) => {
134
133
  const parsed_sveltekit_config =
135
134
  !sveltekit_config && strip_end(dir, '/') === process.cwd()
136
- ? sveltekit_config_global
135
+ ? default_sveltekit_config
137
136
  : await init_sveltekit_config(sveltekit_config ?? dir);
138
137
  const {
139
138
  alias,
@@ -147,14 +146,6 @@ export const gro_plugin_server = ({
147
146
  svelte_preprocessors,
148
147
  } = parsed_sveltekit_config;
149
148
 
150
- // TODO hacky
151
- if (svelte_compile_options.generate === undefined) {
152
- svelte_compile_options.generate = 'server';
153
- }
154
- if (svelte_compile_module_options.generate === undefined) {
155
- svelte_compile_module_options.generate = 'server';
156
- }
157
-
158
149
  const {outbase, outdir, outname} = outpaths(dev);
159
150
 
160
151
  const server_outpath = join(outdir, outname);
@@ -202,6 +193,8 @@ export const gro_plugin_server = ({
202
193
  log,
203
194
  }),
204
195
  esbuild_plugin_svelte({
196
+ dev,
197
+ base_url,
205
198
  dir,
206
199
  svelte_compile_options,
207
200
  svelte_compile_module_options,
@@ -9,7 +9,7 @@ import {Task_Error} from './task.js';
9
9
  import {find_cli, spawn_cli, spawn_cli_process} from './cli.js';
10
10
  import {type Map_Src_Json, serialize_src_json, create_src_json} from './src_json.js';
11
11
  import {DEFAULT_EXPORTS_EXCLUDER} from './gro_config.js';
12
- import {sveltekit_config_global} from './sveltekit_config_global.js';
12
+ import {default_sveltekit_config} from './sveltekit_config.js';
13
13
  import {SOURCE_DIRNAME} from './path_constants.js';
14
14
  import {VITE_CLI} from './sveltekit_helpers.js';
15
15
 
@@ -106,7 +106,7 @@ export const gro_plugin_sveltekit_app = ({
106
106
 
107
107
  // copy files to `static` before building, in such a way
108
108
  // that's non-destructive to existing files and dirs and easy to clean up
109
- const {assets_path} = sveltekit_config_global;
109
+ const {assets_path} = default_sveltekit_config;
110
110
  const cleanups: Cleanup[] = [
111
111
  serialized_package_json
112
112
  ? create_temporarily(
package/src/lib/loader.ts CHANGED
@@ -13,11 +13,11 @@ import {
13
13
  SVELTEKIT_SHIM_APP_PATHS_MATCHER,
14
14
  sveltekit_shim_app_specifiers,
15
15
  } from './sveltekit_shim_app.js';
16
- import {sveltekit_config_global} from './sveltekit_config_global.js';
16
+ import {default_sveltekit_config} from './sveltekit_config.js';
17
17
  import {SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './svelte_helpers.js';
18
18
  import {paths} from './paths.js';
19
- import {NODE_MODULES_DIRNAME} from './path_constants.js';
20
- import {to_define_import_meta_env, ts_transform_options} from './esbuild_helpers.js';
19
+ import {JSON_MATCHER, NODE_MODULES_DIRNAME, TS_MATCHER} from './path_constants.js';
20
+ import {to_define_import_meta_env, default_ts_transform_options} from './esbuild_helpers.js';
21
21
  import {resolve_specifier} from './resolve_specifier.js';
22
22
  import {resolve_node_specifier} from './resolve_node_specifier.js';
23
23
  import type {Package_Json} from './package_json.js';
@@ -65,18 +65,16 @@ const {
65
65
  svelte_compile_options,
66
66
  svelte_compile_module_options,
67
67
  svelte_preprocessors,
68
- } = sveltekit_config_global;
68
+ } = default_sveltekit_config;
69
69
 
70
- const final_ts_transform_options: esbuild.TransformOptions = {
71
- ...ts_transform_options,
70
+ const ts_transform_options: esbuild.TransformOptions = {
71
+ ...default_ts_transform_options,
72
72
  define: to_define_import_meta_env(dev, base_url),
73
73
  sourcemap: 'inline',
74
74
  };
75
75
 
76
76
  const aliases = Object.entries({$lib: 'src/lib', ...alias});
77
77
 
78
- const TS_MATCHER = /\.(ts|tsx|mts|cts)$/;
79
- const JSON_MATCHER = /\.(json)$/;
80
78
  const NOOP_MATCHER = /\.(css|svg)$/; // TODO others? configurable?
81
79
  const ENV_MATCHER = /src\/lib\/\$env\/(static|dynamic)\/(public|private)$/;
82
80
  const NODE_MODULES_MATCHER = new RegExp(escape_regexp('/' + NODE_MODULES_DIRNAME + '/'), 'u');
@@ -100,14 +98,16 @@ export const load: LoadHook = async (url, context, nextLoad) => {
100
98
  };
101
99
  } else if (SVELTE_RUNES_MATCHER.test(url)) {
102
100
  // Svelte runes in js/ts
103
- // TODO support sourcemaps
104
101
  const loaded = await nextLoad(
105
102
  url,
106
103
  context.format === 'module' ? context : {...context, format: 'module'}, // TODO dunno why this is needed, specifically with tests
107
104
  );
108
105
  const filename = fileURLToPath(url);
109
106
  const source = loaded.source!.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string
110
- const transformed = compileModule(source, {...svelte_compile_module_options, filename});
107
+ const js_source = TS_MATCHER.test(url)
108
+ ? (await esbuild.transform(source, {...ts_transform_options, sourcefile: url})).code // TODO @many use warnings? handle not-inline sourcemaps?
109
+ : source;
110
+ const transformed = compileModule(js_source, {...svelte_compile_module_options, dev, filename});
111
111
  return {format: 'module', shortCircuit: true, source: transformed.js.code};
112
112
  } else if (TS_MATCHER.test(url)) {
113
113
  // ts
@@ -115,10 +115,8 @@ export const load: LoadHook = async (url, context, nextLoad) => {
115
115
  url,
116
116
  context.format === 'module' ? context : {...context, format: 'module'}, // TODO dunno why this is needed, specifically with tests
117
117
  );
118
- const transformed = await esbuild.transform(
119
- loaded.source!.toString(), // eslint-disable-line @typescript-eslint/no-base-to-string
120
- {...final_ts_transform_options, sourcefile: url},
121
- );
118
+ const source = loaded.source!.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string
119
+ const transformed = await esbuild.transform(source, {...ts_transform_options, sourcefile: url}); // TODO @many use warnings? handle not-inline sourcemaps?
122
120
  return {format: 'module', shortCircuit: true, source: transformed.code};
123
121
  } else if (SVELTE_MATCHER.test(url)) {
124
122
  // Svelte
@@ -129,11 +127,11 @@ export const load: LoadHook = async (url, context, nextLoad) => {
129
127
  );
130
128
  const filename = fileURLToPath(url);
131
129
  const raw_source = loaded.source!.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string
132
- const preprocessed = svelte_preprocessors
130
+ const preprocessed = svelte_preprocessors // TODO @many use sourcemaps (and diagnostics?)
133
131
  ? await preprocess(raw_source, svelte_preprocessors, {filename})
134
132
  : null;
135
133
  const source = preprocessed?.code ?? raw_source;
136
- const transformed = compile(source, {...svelte_compile_options, filename});
134
+ const transformed = compile(source, {...svelte_compile_options, dev, filename});
137
135
  return {format: 'module', shortCircuit: true, source: transformed.js.code};
138
136
  } else if (JSON_MATCHER.test(url)) {
139
137
  // json
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
5
5
 
6
6
  export const package_json = {
7
7
  name: '@ryanatkn/gro',
8
- version: '0.133.2',
8
+ version: '0.133.4',
9
9
  description: 'task runner and toolkit extending SvelteKit',
10
10
  motto: 'generate, run, optimize',
11
11
  glyph: '🌰',
@@ -44,14 +44,14 @@ export const package_json = {
44
44
  'typescript',
45
45
  ],
46
46
  dependencies: {
47
- '@ryanatkn/belt': '^0.24.10',
47
+ '@ryanatkn/belt': '^0.24.11',
48
48
  chokidar: '^3.6.0',
49
49
  dotenv: '^16.4.5',
50
50
  'es-module-lexer': '^1.5.4',
51
51
  'esm-env': '^1.0.0',
52
52
  mri: '^1.2.0',
53
53
  prettier: '^3.3.3',
54
- 'prettier-plugin-svelte': '^3.2.5',
54
+ 'prettier-plugin-svelte': '^3.2.6',
55
55
  'ts-morph': '^23.0.0',
56
56
  tslib: '^2.6.3',
57
57
  zod: '^3.23.8',
@@ -61,18 +61,18 @@ export const package_json = {
61
61
  '@changesets/changelog-git': '^0.2.0',
62
62
  '@changesets/types': '^6.0.0',
63
63
  '@ryanatkn/eslint-config': '^0.4.2',
64
- '@ryanatkn/fuz': '^0.115.1',
65
- '@ryanatkn/moss': '^0.8.0',
64
+ '@ryanatkn/fuz': '^0.117.0',
65
+ '@ryanatkn/moss': '^0.10.1',
66
66
  '@sveltejs/adapter-static': '^3.0.2',
67
67
  '@sveltejs/kit': '^2.5.18',
68
68
  '@sveltejs/package': '^2.3.2',
69
69
  '@sveltejs/vite-plugin-svelte': '^3.1.1',
70
70
  '@types/fs-extra': '^11.0.4',
71
- '@types/node': '^20.14.10',
71
+ '@types/node': '^20.14.11',
72
72
  esbuild: '^0.21.5',
73
73
  eslint: '^9.7.0',
74
- 'eslint-plugin-svelte': '^2.42.0',
75
- svelte: '^5.0.0-next.184',
74
+ 'eslint-plugin-svelte': '^2.43.0',
75
+ svelte: '^5.0.0-next.193',
76
76
  'svelte-check': '^3.8.4',
77
77
  typescript: '^5.5.3',
78
78
  'typescript-eslint': '^8.0.0-alpha.44',
@@ -216,10 +216,6 @@ export const package_json = {
216
216
  types: './dist/svelte_helpers.d.ts',
217
217
  default: './dist/svelte_helpers.js',
218
218
  },
219
- './sveltekit_config_global.js': {
220
- types: './dist/sveltekit_config_global.d.ts',
221
- default: './dist/sveltekit_config_global.js',
222
- },
223
219
  './sveltekit_config.js': {
224
220
  types: './dist/sveltekit_config.d.ts',
225
221
  default: './dist/sveltekit_config.js',
@@ -272,7 +268,7 @@ export const package_json = {
272
268
 
273
269
  export const src_json = {
274
270
  name: '@ryanatkn/gro',
275
- version: '0.133.2',
271
+ version: '0.133.4',
276
272
  modules: {
277
273
  '.': {
278
274
  path: 'index.ts',
@@ -397,7 +393,7 @@ export const src_json = {
397
393
  declarations: [
398
394
  {name: 'print_build_result', kind: 'function'},
399
395
  {name: 'to_define_import_meta_env', kind: 'function'},
400
- {name: 'ts_transform_options', kind: 'variable'},
396
+ {name: 'default_ts_transform_options', kind: 'variable'},
401
397
  ],
402
398
  },
403
399
  './esbuild_plugin_external_worker.js': {
@@ -712,6 +708,9 @@ export const src_json = {
712
708
  {name: 'GITHUB_DIRNAME', kind: 'variable'},
713
709
  {name: 'GIT_DIRNAME', kind: 'variable'},
714
710
  {name: 'TSCONFIG_FILENAME', kind: 'variable'},
711
+ {name: 'TS_MATCHER', kind: 'variable'},
712
+ {name: 'JSON_MATCHER', kind: 'variable'},
713
+ {name: 'EVERYTHING_MATCHER', kind: 'variable'},
715
714
  ],
716
715
  },
717
716
  './path.js': {
@@ -850,16 +849,14 @@ export const src_json = {
850
849
  {name: 'SVELTE_RUNES_MATCHER', kind: 'variable'},
851
850
  ],
852
851
  },
853
- './sveltekit_config_global.js': {
854
- path: 'sveltekit_config_global.ts',
855
- declarations: [{name: 'sveltekit_config_global', kind: 'variable'}],
856
- },
857
852
  './sveltekit_config.js': {
858
853
  path: 'sveltekit_config.ts',
859
854
  declarations: [
860
855
  {name: 'load_sveltekit_config', kind: 'function'},
861
856
  {name: 'Parsed_Sveltekit_Config', kind: 'type'},
862
857
  {name: 'init_sveltekit_config', kind: 'function'},
858
+ {name: 'to_default_compile_module_options', kind: 'function'},
859
+ {name: 'default_sveltekit_config', kind: 'variable'},
863
860
  ],
864
861
  },
865
862
  './sveltekit_helpers.js': {
@@ -870,6 +867,7 @@ export const src_json = {
870
867
  {name: 'SVELTE_PACKAGE_CLI', kind: 'variable'},
871
868
  {name: 'SVELTE_PACKAGE_DEP_NAME', kind: 'variable'},
872
869
  {name: 'VITE_CLI', kind: 'variable'},
870
+ {name: 'SVELTEKIT_ENV_MATCHER', kind: 'variable'},
873
871
  {name: 'has_sveltekit_app', kind: 'function'},
874
872
  {name: 'has_sveltekit_library', kind: 'function'},
875
873
  {name: 'sveltekit_sync', kind: 'function'},
@@ -28,3 +28,7 @@ export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
28
28
  export const GITHUB_DIRNAME = '.github';
29
29
  export const GIT_DIRNAME = '.git';
30
30
  export const TSCONFIG_FILENAME = 'tsconfig.json';
31
+
32
+ export const TS_MATCHER = /\.(ts|tsx|mts|cts)$/;
33
+ export const JSON_MATCHER = /\.(json)$/;
34
+ export const EVERYTHING_MATCHER = /.*/;
package/src/lib/paths.ts CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  SOURCE_DIR,
11
11
  SVELTEKIT_DIST_DIRNAME,
12
12
  } from './path_constants.js';
13
- import {sveltekit_config_global} from './sveltekit_config_global.js';
13
+ import {default_sveltekit_config} from './sveltekit_config.js';
14
14
  import type {Path_Id} from './path.js';
15
15
 
16
16
  /*
@@ -20,10 +20,10 @@ It's the same name that Rollup uses.
20
20
 
21
21
  */
22
22
 
23
- export const LIB_DIRNAME = basename(sveltekit_config_global.lib_path);
23
+ export const LIB_DIRNAME = basename(default_sveltekit_config.lib_path);
24
24
  export const LIB_PATH = SOURCE_DIR + LIB_DIRNAME;
25
25
  export const LIB_DIR = LIB_PATH + '/';
26
- export const ROUTES_DIRNAME = basename(sveltekit_config_global.routes_path);
26
+ export const ROUTES_DIRNAME = basename(default_sveltekit_config.routes_path);
27
27
 
28
28
  export interface Paths {
29
29
  root: string;
@@ -14,7 +14,7 @@ import {
14
14
  import {print_path} from './paths.js';
15
15
  import type {format_file as base_format_file} from './format_file.js';
16
16
  import type {Gro_Config} from './gro_config.js';
17
- import {sveltekit_config_global} from './sveltekit_config_global.js';
17
+ import {default_sveltekit_config} from './sveltekit_config.js';
18
18
 
19
19
  export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
20
20
 
@@ -37,7 +37,7 @@ export const run_gen = async (
37
37
  // Perform code generation by calling `gen` on the module.
38
38
  const gen_ctx: Gen_Context = {
39
39
  config,
40
- sveltekit_config: sveltekit_config_global,
40
+ sveltekit_config: default_sveltekit_config,
41
41
  origin_id: id,
42
42
  log,
43
43
  };
@@ -7,7 +7,7 @@ import type {invoke_task as base_invoke_task} from './invoke_task.js';
7
7
  import {log_task_help} from './task_logging.js';
8
8
  import type {Gro_Config} from './gro_config.js';
9
9
  import {Task_Error, type Task_Module_Meta} from './task.js';
10
- import {sveltekit_config_global} from './sveltekit_config_global.js';
10
+ import {default_sveltekit_config} from './sveltekit_config.js';
11
11
 
12
12
  export type Run_Task_Result =
13
13
  | {
@@ -52,7 +52,7 @@ export const run_task = async (
52
52
  output = await task.run({
53
53
  args,
54
54
  config,
55
- sveltekit_config: sveltekit_config_global,
55
+ sveltekit_config: default_sveltekit_config,
56
56
  log,
57
57
  timings,
58
58
  invoke_task: (invoked_task_name, invoked_args, invoked_config) =>
@@ -1,5 +1,5 @@
1
1
  import type {Config as SveltekitConfig} from '@sveltejs/kit';
2
- import type {CompileOptions, PreprocessorGroup, ModuleCompileOptions} from 'svelte/compiler';
2
+ import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
3
3
  import {join} from 'node:path';
4
4
 
5
5
  import {SVELTEKIT_CONFIG_FILENAME} from './path_constants.js';
@@ -57,7 +57,7 @@ export interface Parsed_Sveltekit_Config {
57
57
  private_prefix: string | undefined;
58
58
  public_prefix: string | undefined;
59
59
  svelte_compile_options: CompileOptions;
60
- svelte_compile_module_options: ModuleCompileOptions;
60
+ svelte_compile_module_options: CompileOptions;
61
61
  svelte_preprocessors: PreprocessorGroup | PreprocessorGroup[] | undefined;
62
62
  }
63
63
 
@@ -88,8 +88,13 @@ export const init_sveltekit_config = async (
88
88
  const private_prefix = kit?.env?.privatePrefix;
89
89
  const public_prefix = kit?.env?.publicPrefix;
90
90
 
91
- const svelte_compile_options = sveltekit_config?.compilerOptions ?? {};
92
- const svelte_compile_module_options = {}; // TODO from `kit`? or subset of `svelte_compile_options`?
91
+ const svelte_compile_options: CompileOptions = sveltekit_config?.compilerOptions ?? {};
92
+ // Change the default to `generate: 'server'`,
93
+ // because SvelteKit handles the client in the normal cases.
94
+ if (svelte_compile_options.generate === undefined) {
95
+ svelte_compile_options.generate = 'server';
96
+ }
97
+ const svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options); // TODO will kit have these separately?
93
98
  const svelte_preprocessors = sveltekit_config?.preprocess;
94
99
 
95
100
  return {
@@ -108,3 +113,15 @@ export const init_sveltekit_config = async (
108
113
  svelte_preprocessors,
109
114
  };
110
115
  };
116
+
117
+ export const to_default_compile_module_options = ({
118
+ dev,
119
+ generate,
120
+ filename,
121
+ rootDir,
122
+ }: CompileOptions): ModuleCompileOptions => ({dev, generate, filename, rootDir});
123
+
124
+ /**
125
+ * The parsed SvelteKit config for the cwd, cached globally at the module level.
126
+ */
127
+ export const default_sveltekit_config = await init_sveltekit_config(); // always load it to keep things simple ahead
@@ -2,8 +2,7 @@ import type {Result} from '@ryanatkn/belt/result.js';
2
2
  import {existsSync} from 'node:fs';
3
3
 
4
4
  import {Package_Json, load_package_json} from './package_json.js';
5
- import {sveltekit_config_global} from './sveltekit_config_global.js';
6
- import type {Parsed_Sveltekit_Config} from './sveltekit_config.js';
5
+ import {default_sveltekit_config, type Parsed_Sveltekit_Config} from './sveltekit_config.js';
7
6
  import {SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME} from './path_constants.js';
8
7
  import {find_cli, spawn_cli, to_cli_name, type Cli} from './cli.js';
9
8
  import {Task_Error} from './task.js';
@@ -17,6 +16,8 @@ export const SVELTE_PACKAGE_DEP_NAME = '@sveltejs/package';
17
16
 
18
17
  export const VITE_CLI = 'vite';
19
18
 
19
+ export const SVELTEKIT_ENV_MATCHER = /^\$env\/(static|dynamic)\/(public|private)$/;
20
+
20
21
  export const has_sveltekit_app = (): Result<object, {message: string}> => {
21
22
  if (!existsSync(SVELTEKIT_CONFIG_FILENAME)) {
22
23
  return {ok: false, message: `no SvelteKit config found at ${SVELTEKIT_CONFIG_FILENAME}`};
@@ -27,7 +28,7 @@ export const has_sveltekit_app = (): Result<object, {message: string}> => {
27
28
 
28
29
  export const has_sveltekit_library = (
29
30
  package_json?: Package_Json,
30
- sveltekit_config: Parsed_Sveltekit_Config = sveltekit_config_global,
31
+ sveltekit_config: Parsed_Sveltekit_Config = default_sveltekit_config,
31
32
  ): Result<object, {message: string}> => {
32
33
  const has_sveltekit_app_result = has_sveltekit_app();
33
34
  if (!has_sveltekit_app_result.ok) {
@@ -35,7 +35,7 @@ export const log_tasks = (log: Logger, loaded_tasks: Loaded_Tasks, log_intro = t
35
35
  for (const resolved_input_file of resolved_input_files) {
36
36
  const meta = modules.find((m) => m.id === resolved_input_file.id)!;
37
37
  logged.push(
38
- '\n' + cyan(pad(meta.name, longest_task_name)),
38
+ '\n' + cyan(meta.name.padEnd(longest_task_name)),
39
39
  ' ',
40
40
  meta.mod.task.summary ?? '',
41
41
  );
@@ -75,9 +75,9 @@ export const log_task_help = (log: Logger, meta: Task_Module_Meta): void => {
75
75
  for (const property of properties) {
76
76
  const name = property.name === '_' ? ARGS_PROPERTY_NAME : property.name;
77
77
  logged.push(
78
- `\n${green(pad(name, longest_task_name))} `,
79
- gray(pad(property.schema.type, longest_type)) + ' ',
80
- pad(print_value(property.schema.default), longest_default) + ' ',
78
+ `\n${green(name.padEnd(longest_task_name))} `,
79
+ gray(property.schema.type.padEnd(longest_type)) + ' ',
80
+ print_value(property.schema.default).padEnd(longest_default) + ' ',
81
81
  property.schema.description || '(no description available)',
82
82
  );
83
83
  }
@@ -115,8 +115,6 @@ const to_arg_properties = (def: ZodTypeDef, meta: Task_Module_Meta): Arg_Schema_
115
115
  return properties;
116
116
  };
117
117
 
118
- // quick n dirty padding logic
119
- const pad = (s: string, n: number): string => s + ' '.repeat(n - s.length);
120
118
  const to_max_length = <T>(items: T[], toString: (item: T) => string) =>
121
119
  items.reduce((max, m) => Math.max(toString(m).length, max), 0);
122
120
 
@@ -1,5 +0,0 @@
1
- /**
2
- * The parsed SvelteKit config for the cwd, cached globally at the module level.
3
- */
4
- export declare const sveltekit_config_global: import("./sveltekit_config.js").Parsed_Sveltekit_Config;
5
- //# sourceMappingURL=sveltekit_config_global.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sveltekit_config_global.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_config_global.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,uBAAuB,yDAAgC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { init_sveltekit_config } from './sveltekit_config.js';
2
- /**
3
- * The parsed SvelteKit config for the cwd, cached globally at the module level.
4
- */
5
- export const sveltekit_config_global = await init_sveltekit_config(); // always load it to keep things simple ahead
@@ -1,6 +0,0 @@
1
- import {init_sveltekit_config} from './sveltekit_config.js';
2
-
3
- /**
4
- * The parsed SvelteKit config for the cwd, cached globally at the module level.
5
- */
6
- export const sveltekit_config_global = await init_sveltekit_config(); // always load it to keep things simple ahead