@ryanatkn/gro 0.133.1 → 0.133.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/build.task.d.ts +6 -0
- package/dist/build.task.d.ts.map +1 -1
- package/dist/build.task.js +6 -3
- package/dist/check.task.d.ts +2 -2
- package/dist/dev.task.d.ts +2 -2
- package/dist/esbuild_helpers.d.ts +1 -1
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_helpers.js +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +2 -2
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.js +3 -1
- package/dist/esbuild_plugin_svelte.d.ts +7 -2
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.js +20 -9
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_local_imports.js +3 -2
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.js +3 -2
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.js +6 -5
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_server.js +4 -10
- package/dist/gro_plugin_sveltekit_app.js +2 -2
- package/dist/invoke.js +1 -1
- package/dist/invoke_task.js +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +14 -14
- package/dist/package.d.ts +0 -11
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +12 -13
- package/dist/path_constants.d.ts +3 -0
- package/dist/path_constants.d.ts.map +1 -1
- package/dist/path_constants.js +3 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +3 -3
- package/dist/run_gen.js +2 -2
- package/dist/run_task.js +2 -2
- package/dist/sveltekit_config.d.ts +7 -2
- package/dist/sveltekit_config.d.ts.map +1 -1
- package/dist/sveltekit_config.js +11 -1
- package/dist/sveltekit_helpers.d.ts +2 -1
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +3 -2
- package/dist/task.d.ts +6 -0
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +6 -0
- package/dist/task_logging.js +2 -4
- package/package.json +3 -7
- package/src/lib/build.task.ts +6 -3
- package/src/lib/esbuild_helpers.ts +1 -1
- package/src/lib/esbuild_plugin_external_worker.ts +4 -2
- package/src/lib/esbuild_plugin_svelte.ts +38 -11
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +16 -9
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +3 -2
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +7 -5
- package/src/lib/gro_plugin_server.ts +4 -11
- package/src/lib/gro_plugin_sveltekit_app.ts +2 -2
- package/src/lib/invoke.ts +3 -2
- package/src/lib/invoke_task.ts +3 -3
- package/src/lib/loader.ts +14 -16
- package/src/lib/package.ts +12 -13
- package/src/lib/path_constants.ts +4 -0
- package/src/lib/paths.ts +3 -3
- package/src/lib/run_gen.ts +2 -2
- package/src/lib/run_task.ts +2 -2
- package/src/lib/sveltekit_config.ts +21 -4
- package/src/lib/sveltekit_helpers.ts +4 -3
- package/src/lib/task.ts +6 -0
- package/src/lib/task_logging.ts +4 -6
- package/dist/sveltekit_config_global.d.ts +0 -5
- package/dist/sveltekit_config_global.d.ts.map +0 -1
- package/dist/sveltekit_config_global.js +0 -5
- 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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
?
|
|
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 {
|
|
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} =
|
|
109
|
+
const {assets_path} = default_sveltekit_config;
|
|
110
110
|
const cleanups: Cleanup[] = [
|
|
111
111
|
serialized_package_json
|
|
112
112
|
? create_temporarily(
|
package/src/lib/invoke.ts
CHANGED
|
@@ -17,8 +17,9 @@ and the rest of the args are forwarded to the task's `run` function.
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
// handle uncaught errors
|
|
20
|
-
attach_process_error_handlers(
|
|
21
|
-
err
|
|
20
|
+
attach_process_error_handlers(
|
|
21
|
+
(err) => (err.constructor.name === 'Task_Error' ? 'Task_Error' : null),
|
|
22
|
+
(err) => (err.constructor.name === 'Silent_Error' ? '' : null),
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
await sveltekit_sync_if_obviously_needed();
|
package/src/lib/invoke_task.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {print_ms, print_timings} from '@ryanatkn/belt/print.js';
|
|
|
6
6
|
import {to_forwarded_args, type Args} from './args.js';
|
|
7
7
|
import {run_task} from './run_task.js';
|
|
8
8
|
import {to_input_path, Raw_Input_Path} from './input_path.js';
|
|
9
|
-
import {find_tasks, load_tasks} from './task.js';
|
|
9
|
+
import {find_tasks, load_tasks, Silent_Error} from './task.js';
|
|
10
10
|
import {load_gro_package_json} from './package_json.js';
|
|
11
11
|
import {log_tasks, log_error_reasons} from './task_logging.js';
|
|
12
12
|
import type {Gro_Config} from './gro_config.js';
|
|
@@ -69,7 +69,7 @@ export const invoke_task = async (
|
|
|
69
69
|
const found = find_tasks([input_path], task_root_dirs, config);
|
|
70
70
|
if (!found.ok) {
|
|
71
71
|
log_error_reasons(log, found.reasons);
|
|
72
|
-
|
|
72
|
+
throw new Silent_Error();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Found a match either in the current working directory or Gro's directory.
|
|
@@ -80,7 +80,7 @@ export const invoke_task = async (
|
|
|
80
80
|
const loaded = await load_tasks(found_tasks);
|
|
81
81
|
if (!loaded.ok) {
|
|
82
82
|
log_error_reasons(log, loaded.reasons);
|
|
83
|
-
|
|
83
|
+
throw new Silent_Error();
|
|
84
84
|
}
|
|
85
85
|
const loaded_tasks = loaded.value;
|
|
86
86
|
|
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 {
|
|
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,
|
|
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
|
-
} =
|
|
68
|
+
} = default_sveltekit_config;
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
...
|
|
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
|
|
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
|
|
119
|
-
|
|
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
|
package/src/lib/package.ts
CHANGED
|
@@ -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.
|
|
8
|
+
version: '0.133.3',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -44,7 +44,7 @@ export const package_json = {
|
|
|
44
44
|
'typescript',
|
|
45
45
|
],
|
|
46
46
|
dependencies: {
|
|
47
|
-
'@ryanatkn/belt': '^0.24.
|
|
47
|
+
'@ryanatkn/belt': '^0.24.10',
|
|
48
48
|
chokidar: '^3.6.0',
|
|
49
49
|
dotenv: '^16.4.5',
|
|
50
50
|
'es-module-lexer': '^1.5.4',
|
|
@@ -61,7 +61,7 @@ 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.
|
|
64
|
+
'@ryanatkn/fuz': '^0.115.1',
|
|
65
65
|
'@ryanatkn/moss': '^0.8.0',
|
|
66
66
|
'@sveltejs/adapter-static': '^3.0.2',
|
|
67
67
|
'@sveltejs/kit': '^2.5.18',
|
|
@@ -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.
|
|
271
|
+
version: '0.133.3',
|
|
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: '
|
|
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'},
|
|
@@ -964,6 +962,7 @@ export const src_json = {
|
|
|
964
962
|
{name: 'is_task_path', kind: 'function'},
|
|
965
963
|
{name: 'to_task_name', kind: 'function'},
|
|
966
964
|
{name: 'Task_Error', kind: 'class'},
|
|
965
|
+
{name: 'Silent_Error', kind: 'class'},
|
|
967
966
|
{name: 'Found_Task', kind: 'type'},
|
|
968
967
|
{name: 'Found_Tasks', kind: 'type'},
|
|
969
968
|
{name: 'Find_Tasks_Result', kind: 'type'},
|
|
@@ -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 {
|
|
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(
|
|
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(
|
|
26
|
+
export const ROUTES_DIRNAME = basename(default_sveltekit_config.routes_path);
|
|
27
27
|
|
|
28
28
|
export interface Paths {
|
|
29
29
|
root: string;
|
package/src/lib/run_gen.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
40
|
+
sveltekit_config: default_sveltekit_config,
|
|
41
41
|
origin_id: id,
|
|
42
42
|
log,
|
|
43
43
|
};
|
package/src/lib/run_task.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
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,
|
|
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:
|
|
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
|
-
|
|
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 {
|
|
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 =
|
|
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) {
|
package/src/lib/task.ts
CHANGED
|
@@ -80,6 +80,12 @@ export const to_task_name = (
|
|
|
80
80
|
*/
|
|
81
81
|
export class Task_Error extends Error {}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* This is used to tell Gro to exit silently, usually still with with a non-zero exit code.
|
|
85
|
+
* Using it means error logging is handled by the code that threw it.
|
|
86
|
+
*/
|
|
87
|
+
export class Silent_Error extends Error {}
|
|
88
|
+
|
|
83
89
|
export interface Found_Task {
|
|
84
90
|
input_path: Input_Path;
|
|
85
91
|
id: Path_Id;
|
package/src/lib/task_logging.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
79
|
-
gray(
|
|
80
|
-
|
|
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 +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
|