@ryanatkn/gro 0.152.0 → 0.153.1
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/changeset.task.js +2 -2
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/esbuild_helpers.d.ts +2 -2
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +3 -3
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.d.ts +2 -2
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.js +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +3 -3
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
- package/dist/filer.js +2 -2
- package/dist/format_directory.js +2 -2
- package/dist/gen.d.ts +2 -2
- package/dist/gen.d.ts.map +1 -1
- package/dist/gro.config.default.d.ts +4 -4
- package/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro.config.default.js +22 -12
- package/dist/gro_config.d.ts +4 -1
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_plugin_server.d.ts +5 -5
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_server.js +9 -6
- package/dist/gro_plugin_sveltekit_app.js +2 -2
- package/dist/loader.js +2 -2
- package/dist/package.d.ts +10 -10
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +17 -20
- package/dist/package_json.d.ts +0 -1
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +0 -1
- 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/search_fs.d.ts +1 -0
- package/dist/search_fs.d.ts.map +1 -1
- package/dist/search_fs.js +8 -0
- package/dist/{sveltekit_config.d.ts → svelte_config.d.ts} +16 -10
- package/dist/svelte_config.d.ts.map +1 -0
- package/dist/{sveltekit_config.js → svelte_config.js} +16 -12
- package/dist/sveltekit_helpers.d.ts +3 -3
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +8 -8
- package/dist/sveltekit_shim_app.d.ts +2 -2
- package/dist/sveltekit_shim_app.d.ts.map +1 -1
- package/dist/task.d.ts +2 -2
- package/dist/task.d.ts.map +1 -1
- package/dist/upgrade.task.d.ts.map +1 -1
- package/dist/upgrade.task.js +8 -0
- package/package.json +7 -7
- package/src/lib/changeset.task.ts +2 -2
- package/src/lib/constants.ts +1 -1
- package/src/lib/esbuild_helpers.ts +2 -2
- package/src/lib/esbuild_plugin_external_worker.ts +3 -3
- package/src/lib/esbuild_plugin_svelte.ts +5 -5
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +3 -3
- package/src/lib/filer.ts +2 -2
- package/src/lib/format_directory.ts +2 -2
- package/src/lib/gen.ts +2 -2
- package/src/lib/gro.config.default.ts +25 -12
- package/src/lib/gro_config.ts +4 -0
- package/src/lib/gro_plugin_server.ts +14 -11
- package/src/lib/gro_plugin_sveltekit_app.ts +2 -2
- package/src/lib/loader.ts +2 -2
- package/src/lib/package.ts +17 -20
- package/src/lib/package_json.ts +0 -5
- 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/search_fs.ts +9 -0
- package/src/lib/{sveltekit_config.ts → svelte_config.ts} +31 -21
- package/src/lib/sveltekit_helpers.ts +10 -8
- package/src/lib/sveltekit_shim_app.ts +3 -3
- package/src/lib/task.ts +3 -3
- package/src/lib/upgrade.task.ts +9 -0
- package/dist/sveltekit_config.d.ts.map +0 -1
|
@@ -10,7 +10,7 @@ import {esbuild_plugin_sveltekit_shim_env} from './esbuild_plugin_sveltekit_shim
|
|
|
10
10
|
import {esbuild_plugin_sveltekit_shim_app} from './esbuild_plugin_sveltekit_shim_app.js';
|
|
11
11
|
import {esbuild_plugin_sveltekit_local_imports} from './esbuild_plugin_sveltekit_local_imports.js';
|
|
12
12
|
import {esbuild_plugin_svelte} from './esbuild_plugin_svelte.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
14
14
|
import type {Path_Id} from './path.js';
|
|
15
15
|
|
|
16
16
|
export interface Esbuild_Plugin_External_Worker_Options {
|
|
@@ -21,8 +21,8 @@ export interface Esbuild_Plugin_External_Worker_Options {
|
|
|
21
21
|
svelte_compile_module_options?: ModuleCompileOptions;
|
|
22
22
|
svelte_preprocessors?: PreprocessorGroup | Array<PreprocessorGroup>;
|
|
23
23
|
alias?: Record<string, string>;
|
|
24
|
-
base_url?:
|
|
25
|
-
assets_url?:
|
|
24
|
+
base_url?: Parsed_Svelte_Config['base_url'];
|
|
25
|
+
assets_url?: Parsed_Svelte_Config['assets_url'];
|
|
26
26
|
public_prefix?: string;
|
|
27
27
|
private_prefix?: string;
|
|
28
28
|
env_dir?: string;
|
|
@@ -13,15 +13,15 @@ import {relative} from 'node:path';
|
|
|
13
13
|
import {SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './svelte_helpers.js';
|
|
14
14
|
import {to_define_import_meta_env, default_ts_transform_options} from './esbuild_helpers.js';
|
|
15
15
|
import {
|
|
16
|
-
|
|
16
|
+
default_svelte_config,
|
|
17
17
|
to_default_compile_module_options,
|
|
18
|
-
type
|
|
19
|
-
} from './
|
|
18
|
+
type Parsed_Svelte_Config,
|
|
19
|
+
} from './svelte_config.js';
|
|
20
20
|
import {TS_MATCHER} from './constants.js';
|
|
21
21
|
|
|
22
22
|
export interface Esbuild_Plugin_Svelte_Options {
|
|
23
23
|
dev: boolean;
|
|
24
|
-
base_url:
|
|
24
|
+
base_url: Parsed_Svelte_Config['base_url'];
|
|
25
25
|
dir?: string;
|
|
26
26
|
svelte_compile_options?: CompileOptions;
|
|
27
27
|
svelte_compile_module_options?: ModuleCompileOptions;
|
|
@@ -35,7 +35,7 @@ export const esbuild_plugin_svelte = (options: Esbuild_Plugin_Svelte_Options): e
|
|
|
35
35
|
dev,
|
|
36
36
|
base_url,
|
|
37
37
|
dir = process.cwd(),
|
|
38
|
-
svelte_compile_options =
|
|
38
|
+
svelte_compile_options = default_svelte_config.svelte_compile_options,
|
|
39
39
|
svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options),
|
|
40
40
|
svelte_preprocessors,
|
|
41
41
|
ts_transform_options = default_ts_transform_options,
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
render_sveltekit_shim_app_paths,
|
|
6
6
|
sveltekit_shim_app_specifiers,
|
|
7
7
|
} from './sveltekit_shim_app.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
9
9
|
import {EVERYTHING_MATCHER} from './constants.js';
|
|
10
10
|
|
|
11
11
|
export interface Esbuild_Plugin_Sveltekit_Shim_App_Options {
|
|
12
12
|
dev: boolean;
|
|
13
|
-
base_url:
|
|
14
|
-
assets_url:
|
|
13
|
+
base_url: Parsed_Svelte_Config['base_url'];
|
|
14
|
+
assets_url: Parsed_Svelte_Config['assets_url'];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const esbuild_plugin_sveltekit_shim_app = ({
|
package/src/lib/filer.ts
CHANGED
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
import {paths} from './paths.js';
|
|
20
20
|
import {parse_imports} from './parse_imports.js';
|
|
21
21
|
import {resolve_specifier} from './resolve_specifier.js';
|
|
22
|
-
import {
|
|
22
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
23
23
|
import {map_sveltekit_aliases, SVELTEKIT_GLOBAL_SPECIFIER} from './sveltekit_helpers.js';
|
|
24
24
|
import type {Package_Json} from './package_json.js';
|
|
25
25
|
|
|
26
|
-
const aliases = Object.entries(
|
|
26
|
+
const aliases = Object.entries(default_svelte_config.alias);
|
|
27
27
|
|
|
28
28
|
export interface Source_File {
|
|
29
29
|
id: Path_Id;
|
|
@@ -5,7 +5,7 @@ import {paths} from './paths.js';
|
|
|
5
5
|
import {
|
|
6
6
|
GITHUB_DIRNAME,
|
|
7
7
|
README_FILENAME,
|
|
8
|
-
|
|
8
|
+
SVELTE_CONFIG_FILENAME,
|
|
9
9
|
VITE_CONFIG_FILENAME,
|
|
10
10
|
TSCONFIG_FILENAME,
|
|
11
11
|
GRO_CONFIG_PATH,
|
|
@@ -19,7 +19,7 @@ const EXTENSIONS_DEFAULT = 'ts,js,json,svelte,html,css,md,yml';
|
|
|
19
19
|
const ROOT_PATHS_DEFAULT = `${[
|
|
20
20
|
README_FILENAME,
|
|
21
21
|
GRO_CONFIG_PATH,
|
|
22
|
-
|
|
22
|
+
SVELTE_CONFIG_FILENAME,
|
|
23
23
|
VITE_CONFIG_FILENAME,
|
|
24
24
|
TSCONFIG_FILENAME,
|
|
25
25
|
GITHUB_DIRNAME,
|
package/src/lib/gen.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {existsSync} from 'node:fs';
|
|
|
10
10
|
import {print_path} from './paths.js';
|
|
11
11
|
import type {Path_Id} from './path.js';
|
|
12
12
|
import type {Gro_Config} from './gro_config.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
14
14
|
import {load_modules, type Load_Modules_Failure, type Module_Meta} from './modules.js';
|
|
15
15
|
import {
|
|
16
16
|
Input_Path,
|
|
@@ -40,7 +40,7 @@ export interface Gen_File {
|
|
|
40
40
|
export type Gen = (ctx: Gen_Context) => Raw_Gen_Result | Promise<Raw_Gen_Result>;
|
|
41
41
|
export interface Gen_Context {
|
|
42
42
|
config: Gro_Config;
|
|
43
|
-
|
|
43
|
+
svelte_config: Parsed_Svelte_Config;
|
|
44
44
|
/**
|
|
45
45
|
* Same as `import.meta.url` but in path form.
|
|
46
46
|
*/
|
|
@@ -1,37 +1,50 @@
|
|
|
1
|
+
import {resolve} from 'node:path';
|
|
2
|
+
|
|
1
3
|
import type {Create_Gro_Config} from './gro_config.js';
|
|
2
4
|
import {gro_plugin_sveltekit_library} from './gro_plugin_sveltekit_library.js';
|
|
3
5
|
import {has_server, gro_plugin_server} from './gro_plugin_server.js';
|
|
4
6
|
import {gro_plugin_sveltekit_app} from './gro_plugin_sveltekit_app.js';
|
|
5
7
|
import {has_sveltekit_app, has_sveltekit_library} from './sveltekit_helpers.js';
|
|
6
8
|
import {gro_plugin_gen} from './gro_plugin_gen.js';
|
|
7
|
-
import {has_dep,
|
|
9
|
+
import {has_dep, load_package_json} from './package_json.js';
|
|
10
|
+
import {find_first_existing_file} from './search_fs.js';
|
|
11
|
+
|
|
12
|
+
// TODO hacky, maybe extract utils?
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* This is the default config that's passed to `gro.config.ts`
|
|
11
16
|
* if it exists in the current project, and if not, this is the final config.
|
|
12
|
-
* It looks at the
|
|
17
|
+
* It looks at the SvelteKit config and filesystem and tries to do the right thing:
|
|
13
18
|
*
|
|
14
|
-
* - if `src/routes`, assumes a SvelteKit frontend
|
|
15
|
-
* - if `src/lib`, assumes a Node library
|
|
16
|
-
* - if `src/lib/server/server.ts`, assumes a Node server
|
|
19
|
+
* - if `src/routes`, assumes a SvelteKit frontend - respects `KitConfig.kit.files.routes`
|
|
20
|
+
* - if `src/lib`, assumes a Node library - respects `KitConfig.kit.files.lib`
|
|
21
|
+
* - if `src/lib/server/server.ts`, assumes a Node server - needs config
|
|
17
22
|
*/
|
|
18
|
-
const config: Create_Gro_Config = async (cfg) => {
|
|
23
|
+
const config: Create_Gro_Config = async (cfg, svelte_config) => {
|
|
19
24
|
const package_json = load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
|
|
20
25
|
|
|
21
26
|
const [has_moss_dep, has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] =
|
|
22
27
|
await Promise.all([
|
|
23
|
-
has_dep('@ryanatkn/moss', package_json)
|
|
28
|
+
has_dep('@ryanatkn/moss', package_json),
|
|
24
29
|
has_server(),
|
|
25
|
-
has_sveltekit_library(package_json),
|
|
30
|
+
has_sveltekit_library(package_json, svelte_config),
|
|
26
31
|
has_sveltekit_app(),
|
|
27
32
|
]);
|
|
28
33
|
|
|
34
|
+
const local_moss_plugin_path = find_first_existing_file([
|
|
35
|
+
'./src/lib/gro_plugin_moss.ts',
|
|
36
|
+
'./src/routes/gro_plugin_moss.ts',
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
// put things that generate files before SvelteKit so it can see them
|
|
29
40
|
cfg.plugins = async () =>
|
|
30
41
|
[
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
? (
|
|
34
|
-
:
|
|
42
|
+
// TODO probably belongs in the gen system
|
|
43
|
+
local_moss_plugin_path
|
|
44
|
+
? (await import(resolve(local_moss_plugin_path))).gro_plugin_moss()
|
|
45
|
+
: has_moss_dep
|
|
46
|
+
? (await import('@ryanatkn/moss/gro_plugin_moss.js')).gro_plugin_moss()
|
|
47
|
+
: null, // lazy load to avoid errors if it's not installed
|
|
35
48
|
gro_plugin_gen(),
|
|
36
49
|
has_server_result.ok ? gro_plugin_server() : null,
|
|
37
50
|
has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
|
package/src/lib/gro_config.ts
CHANGED
|
@@ -15,6 +15,7 @@ import create_default_config from './gro.config.default.js';
|
|
|
15
15
|
import type {Create_Config_Plugins} from './plugin.js';
|
|
16
16
|
import type {Map_Package_Json} from './package_json.js';
|
|
17
17
|
import type {Path_Filter, Path_Id} from './path.js';
|
|
18
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The config that users can extend via `gro.config.ts`.
|
|
@@ -50,6 +51,8 @@ export interface Gro_Config extends Raw_Gro_Config {
|
|
|
50
51
|
* The CLI to use that's compatible with `npm install` and `npm link`. Defaults to `'npm'`.
|
|
51
52
|
*/
|
|
52
53
|
pm_cli: string;
|
|
54
|
+
/** @default SVELTE_CONFIG_FILENAME */
|
|
55
|
+
svelte_config_filename?: string;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
/**
|
|
@@ -68,6 +71,7 @@ export interface Raw_Gro_Config {
|
|
|
68
71
|
|
|
69
72
|
export type Create_Gro_Config = (
|
|
70
73
|
base_config: Gro_Config,
|
|
74
|
+
svelte_config?: Parsed_Svelte_Config,
|
|
71
75
|
) => Raw_Gro_Config | Promise<Raw_Gro_Config>;
|
|
72
76
|
|
|
73
77
|
export const create_empty_gro_config = (): Gro_Config => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {spawn_restartable_process, type Restartable_Process} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import * as esbuild from 'esbuild';
|
|
3
|
-
import type {Config as
|
|
3
|
+
import type {Config as SvelteConfig} from '@sveltejs/kit';
|
|
4
4
|
import {join, resolve} from 'node:path';
|
|
5
5
|
import {identity} from '@ryanatkn/belt/function.js';
|
|
6
6
|
import {strip_before, strip_end} from '@ryanatkn/belt/string.js';
|
|
@@ -13,7 +13,7 @@ import {base_path_to_path_id, LIB_DIRNAME, paths} from './paths.js';
|
|
|
13
13
|
import type {Path_Id} from './path.js';
|
|
14
14
|
import {GRO_DEV_DIRNAME, SERVER_DIST_PATH} from './constants.js';
|
|
15
15
|
import {watch_dir, type Watch_Node_Fs} from './watch_dir.js';
|
|
16
|
-
import {
|
|
16
|
+
import {parse_svelte_config, default_svelte_config} from './svelte_config.js';
|
|
17
17
|
import {esbuild_plugin_sveltekit_shim_app} from './esbuild_plugin_sveltekit_shim_app.js';
|
|
18
18
|
import {esbuild_plugin_sveltekit_shim_env} from './esbuild_plugin_sveltekit_shim_env.js';
|
|
19
19
|
import {print_build_result, to_define_import_meta_env} from './esbuild_helpers.js';
|
|
@@ -49,7 +49,7 @@ export interface Gro_Plugin_Server_Options {
|
|
|
49
49
|
*/
|
|
50
50
|
outpaths?: Create_Outpaths;
|
|
51
51
|
/**
|
|
52
|
-
* @default SvelteKit's `.env`, `.env.development`, and `.env.production
|
|
52
|
+
* @default ```SvelteKit's `.env`, `.env.development`, and `.env.production````
|
|
53
53
|
*/
|
|
54
54
|
env_files?: Array<string>;
|
|
55
55
|
/**
|
|
@@ -57,9 +57,9 @@ export interface Gro_Plugin_Server_Options {
|
|
|
57
57
|
*/
|
|
58
58
|
ambient_env?: Record<string, string>;
|
|
59
59
|
/**
|
|
60
|
-
* @default loaded from `${cwd}/${
|
|
60
|
+
* @default ```loaded from `${cwd}/${SVELTE_CONFIG_FILENAME}````
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
svelte_config?: SvelteConfig;
|
|
63
63
|
/**
|
|
64
64
|
* @default 'esnext'
|
|
65
65
|
*/
|
|
@@ -115,7 +115,7 @@ export const gro_plugin_server = ({
|
|
|
115
115
|
}),
|
|
116
116
|
env_files,
|
|
117
117
|
ambient_env,
|
|
118
|
-
|
|
118
|
+
svelte_config,
|
|
119
119
|
target = 'esnext',
|
|
120
120
|
esbuild_build_options = identity,
|
|
121
121
|
rebuild_throttle_delay = 1000,
|
|
@@ -130,10 +130,13 @@ export const gro_plugin_server = ({
|
|
|
130
130
|
return {
|
|
131
131
|
name: 'gro_plugin_server',
|
|
132
132
|
setup: async ({dev, watch, timings, log, config}) => {
|
|
133
|
-
const
|
|
134
|
-
!
|
|
135
|
-
?
|
|
136
|
-
: await
|
|
133
|
+
const parsed_svelte_config =
|
|
134
|
+
!svelte_config && strip_end(dir, '/') === process.cwd()
|
|
135
|
+
? default_svelte_config
|
|
136
|
+
: await parse_svelte_config({
|
|
137
|
+
dir_or_config: svelte_config ?? dir,
|
|
138
|
+
config_filename: config.svelte_config_filename,
|
|
139
|
+
});
|
|
137
140
|
const {
|
|
138
141
|
alias,
|
|
139
142
|
base_url,
|
|
@@ -144,7 +147,7 @@ export const gro_plugin_server = ({
|
|
|
144
147
|
svelte_compile_options,
|
|
145
148
|
svelte_compile_module_options,
|
|
146
149
|
svelte_preprocessors,
|
|
147
|
-
} =
|
|
150
|
+
} = parsed_svelte_config;
|
|
148
151
|
|
|
149
152
|
const {outbase, outdir, outname} = outpaths(dev);
|
|
150
153
|
|
|
@@ -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 {EXPORTS_EXCLUDER_DEFAULT} from './gro_config.js';
|
|
12
|
-
import {
|
|
12
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
13
13
|
import {SOURCE_DIRNAME} from './constants.js';
|
|
14
14
|
import {VITE_CLI} from './sveltekit_helpers.js';
|
|
15
15
|
|
|
@@ -108,7 +108,7 @@ export const gro_plugin_sveltekit_app = ({
|
|
|
108
108
|
|
|
109
109
|
// copy files to `static` before building, in such a way
|
|
110
110
|
// that's non-destructive to existing files and dirs and easy to clean up
|
|
111
|
-
const {assets_path} =
|
|
111
|
+
const {assets_path} = default_svelte_config;
|
|
112
112
|
const cleanups: Array<Cleanup> = [
|
|
113
113
|
serialized_package_json
|
|
114
114
|
? create_temporarily(
|
package/src/lib/loader.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
SVELTEKIT_SHIM_APP_PATHS_MATCHER,
|
|
15
15
|
sveltekit_shim_app_specifiers,
|
|
16
16
|
} from './sveltekit_shim_app.js';
|
|
17
|
-
import {
|
|
17
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
18
18
|
import {SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './svelte_helpers.js';
|
|
19
19
|
import {IS_THIS_GRO, paths} from './paths.js';
|
|
20
20
|
import {JSON_MATCHER, NODE_MODULES_DIRNAME, TS_MATCHER} from './constants.js';
|
|
@@ -66,7 +66,7 @@ const {
|
|
|
66
66
|
svelte_compile_options,
|
|
67
67
|
svelte_compile_module_options,
|
|
68
68
|
svelte_preprocessors,
|
|
69
|
-
} =
|
|
69
|
+
} = default_svelte_config;
|
|
70
70
|
|
|
71
71
|
const ts_transform_options: esbuild.TransformOptions = {
|
|
72
72
|
...default_ts_transform_options,
|
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.
|
|
8
|
+
version: '0.153.1',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -61,7 +61,7 @@ export const package_json = {
|
|
|
61
61
|
'@changesets/changelog-git': '^0.2.1',
|
|
62
62
|
'@changesets/types': '^6.1.0',
|
|
63
63
|
'@ryanatkn/eslint-config': '^0.8.0',
|
|
64
|
-
'@ryanatkn/fuz': '^0.139.
|
|
64
|
+
'@ryanatkn/fuz': '^0.139.2',
|
|
65
65
|
'@ryanatkn/moss': '^0.26.0',
|
|
66
66
|
'@sveltejs/adapter-static': '^3.0.8',
|
|
67
67
|
'@sveltejs/kit': '^2.20.8',
|
|
@@ -77,7 +77,7 @@ export const package_json = {
|
|
|
77
77
|
'typescript-eslint': '^8.31.1',
|
|
78
78
|
uvu: '^0.5.6',
|
|
79
79
|
},
|
|
80
|
-
optionalDependencies: {'@ryanatkn/moss': '^0.
|
|
80
|
+
optionalDependencies: {'@ryanatkn/moss': '^0.27.0'},
|
|
81
81
|
prettier: {
|
|
82
82
|
plugins: ['prettier-plugin-svelte'],
|
|
83
83
|
useTabs: true,
|
|
@@ -211,14 +211,11 @@ export const package_json = {
|
|
|
211
211
|
'./run.task.js': {types: './dist/run.task.d.ts', default: './dist/run.task.js'},
|
|
212
212
|
'./search_fs.js': {types: './dist/search_fs.d.ts', default: './dist/search_fs.js'},
|
|
213
213
|
'./src_json.js': {types: './dist/src_json.d.ts', default: './dist/src_json.js'},
|
|
214
|
+
'./svelte_config.js': {types: './dist/svelte_config.d.ts', default: './dist/svelte_config.js'},
|
|
214
215
|
'./svelte_helpers.js': {
|
|
215
216
|
types: './dist/svelte_helpers.d.ts',
|
|
216
217
|
default: './dist/svelte_helpers.js',
|
|
217
218
|
},
|
|
218
|
-
'./sveltekit_config.js': {
|
|
219
|
-
types: './dist/sveltekit_config.d.ts',
|
|
220
|
-
default: './dist/sveltekit_config.js',
|
|
221
|
-
},
|
|
222
219
|
'./sveltekit_helpers.js': {
|
|
223
220
|
types: './dist/sveltekit_helpers.d.ts',
|
|
224
221
|
default: './dist/sveltekit_helpers.js',
|
|
@@ -266,7 +263,7 @@ export const package_json = {
|
|
|
266
263
|
|
|
267
264
|
export const src_json = {
|
|
268
265
|
name: '@ryanatkn/gro',
|
|
269
|
-
version: '0.
|
|
266
|
+
version: '0.153.1',
|
|
270
267
|
modules: {
|
|
271
268
|
'.': {
|
|
272
269
|
path: 'index.ts',
|
|
@@ -381,7 +378,7 @@ export const src_json = {
|
|
|
381
378
|
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
382
379
|
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
383
380
|
{name: 'README_FILENAME', kind: 'variable'},
|
|
384
|
-
{name: '
|
|
381
|
+
{name: 'SVELTE_CONFIG_FILENAME', kind: 'variable'},
|
|
385
382
|
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
386
383
|
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
387
384
|
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
@@ -717,7 +714,6 @@ export const src_json = {
|
|
|
717
714
|
{name: 'update_package_json', kind: 'function'},
|
|
718
715
|
{name: 'to_package_exports', kind: 'function'},
|
|
719
716
|
{name: 'parse_repo_url', kind: 'function'},
|
|
720
|
-
{name: 'is_dep', kind: 'function'},
|
|
721
717
|
{name: 'has_dep', kind: 'function'},
|
|
722
718
|
{name: 'Package_Json_Dep', kind: 'type'},
|
|
723
719
|
{name: 'extract_deps', kind: 'function'},
|
|
@@ -853,6 +849,7 @@ export const src_json = {
|
|
|
853
849
|
declarations: [
|
|
854
850
|
{name: 'Search_Fs_Options', kind: 'type'},
|
|
855
851
|
{name: 'search_fs', kind: 'function'},
|
|
852
|
+
{name: 'find_first_existing_file', kind: 'function'},
|
|
856
853
|
],
|
|
857
854
|
},
|
|
858
855
|
'./src_json.js': {
|
|
@@ -868,6 +865,16 @@ export const src_json = {
|
|
|
868
865
|
{name: 'to_src_modules', kind: 'function'},
|
|
869
866
|
],
|
|
870
867
|
},
|
|
868
|
+
'./svelte_config.js': {
|
|
869
|
+
path: 'svelte_config.ts',
|
|
870
|
+
declarations: [
|
|
871
|
+
{name: 'load_svelte_config', kind: 'function'},
|
|
872
|
+
{name: 'Parsed_Svelte_Config', kind: 'type'},
|
|
873
|
+
{name: 'parse_svelte_config', kind: 'function'},
|
|
874
|
+
{name: 'to_default_compile_module_options', kind: 'function'},
|
|
875
|
+
{name: 'default_svelte_config', kind: 'variable'},
|
|
876
|
+
],
|
|
877
|
+
},
|
|
871
878
|
'./svelte_helpers.js': {
|
|
872
879
|
path: 'svelte_helpers.ts',
|
|
873
880
|
declarations: [
|
|
@@ -875,16 +882,6 @@ export const src_json = {
|
|
|
875
882
|
{name: 'SVELTE_RUNES_MATCHER', kind: 'variable'},
|
|
876
883
|
],
|
|
877
884
|
},
|
|
878
|
-
'./sveltekit_config.js': {
|
|
879
|
-
path: 'sveltekit_config.ts',
|
|
880
|
-
declarations: [
|
|
881
|
-
{name: 'load_sveltekit_config', kind: 'function'},
|
|
882
|
-
{name: 'Parsed_Sveltekit_Config', kind: 'type'},
|
|
883
|
-
{name: 'init_sveltekit_config', kind: 'function'},
|
|
884
|
-
{name: 'to_default_compile_module_options', kind: 'function'},
|
|
885
|
-
{name: 'default_sveltekit_config', kind: 'variable'},
|
|
886
|
-
],
|
|
887
|
-
},
|
|
888
885
|
'./sveltekit_helpers.js': {
|
|
889
886
|
path: 'sveltekit_helpers.ts',
|
|
890
887
|
declarations: [
|
package/src/lib/package_json.ts
CHANGED
|
@@ -347,11 +347,6 @@ const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
|
|
|
347
347
|
return parsed.data;
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
export const is_dep = (
|
|
351
|
-
dep_name: string,
|
|
352
|
-
package_json: Package_Json = load_package_json(),
|
|
353
|
-
): boolean => package_json.name === dep_name;
|
|
354
|
-
|
|
355
350
|
export const has_dep = (
|
|
356
351
|
dep_name: string,
|
|
357
352
|
package_json: Package_Json = load_package_json(),
|
package/src/lib/paths.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SOURCE_DIR,
|
|
11
11
|
SVELTEKIT_DIST_DIRNAME,
|
|
12
12
|
} from './constants.js';
|
|
13
|
-
import {
|
|
13
|
+
import {default_svelte_config} from './svelte_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_svelte_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_svelte_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, to_root_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_svelte_config} from './svelte_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
|
-
|
|
40
|
+
svelte_config: default_svelte_config,
|
|
41
41
|
origin_id: id,
|
|
42
42
|
origin_path: to_root_path(id),
|
|
43
43
|
log,
|
package/src/lib/run_task.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {invoke_task as base_invoke_task} from './invoke_task.js';
|
|
|
8
8
|
import {log_task_help} from './task_logging.js';
|
|
9
9
|
import type {Gro_Config} from './gro_config.js';
|
|
10
10
|
import {Task_Error, type Task_Module_Meta} from './task.js';
|
|
11
|
-
import {
|
|
11
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
12
12
|
import type {Filer} from './filer.js';
|
|
13
13
|
|
|
14
14
|
export type Run_Task_Result =
|
|
@@ -55,7 +55,7 @@ export const run_task = async (
|
|
|
55
55
|
output = await task.run({
|
|
56
56
|
args,
|
|
57
57
|
config,
|
|
58
|
-
|
|
58
|
+
svelte_config: default_svelte_config,
|
|
59
59
|
filer,
|
|
60
60
|
log,
|
|
61
61
|
timings,
|
package/src/lib/search_fs.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {Config as
|
|
1
|
+
import type {Config as SvelteConfig} from '@sveltejs/kit';
|
|
2
2
|
import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
|
+
import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import {SVELTE_CONFIG_FILENAME} from './constants.js';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
|
|
@@ -14,11 +15,12 @@ This module is intended to have minimal dependencies to avoid over-imports in th
|
|
|
14
15
|
* Loads a SvelteKit config at `dir`.
|
|
15
16
|
* @returns `null` if no config is found
|
|
16
17
|
*/
|
|
17
|
-
export const
|
|
18
|
-
dir
|
|
19
|
-
|
|
18
|
+
export const load_svelte_config = async ({
|
|
19
|
+
dir = process.cwd(),
|
|
20
|
+
config_filename = SVELTE_CONFIG_FILENAME,
|
|
21
|
+
}: {dir?: string; config_filename?: string} = EMPTY_OBJECT): Promise<SvelteConfig | null> => {
|
|
20
22
|
try {
|
|
21
|
-
return (await import(join(dir,
|
|
23
|
+
return (await import(join(dir, config_filename))).default;
|
|
22
24
|
} catch (_err) {
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
@@ -28,13 +30,13 @@ export const load_sveltekit_config = async (
|
|
|
28
30
|
* A subset of SvelteKit's config in a form that Gro uses
|
|
29
31
|
* because SvelteKit doesn't expose its config resolver.
|
|
30
32
|
* Flattens things out to keep them simple and easy to pass around,
|
|
31
|
-
* and doesn't deal with most properties
|
|
33
|
+
* and doesn't deal with most properties, but includes the full `svelte_config`.
|
|
32
34
|
* The `base` and `assets` in particular are renamed for clarity with Gro's internal systems,
|
|
33
35
|
* so these properties become first-class vocabulary inside Gro.
|
|
34
36
|
*/
|
|
35
|
-
export interface
|
|
37
|
+
export interface Parsed_Svelte_Config {
|
|
36
38
|
// TODO probably fill these out with defaults
|
|
37
|
-
|
|
39
|
+
svelte_config: SvelteConfig | null;
|
|
38
40
|
alias: Record<string, string>;
|
|
39
41
|
base_url: '' | `/${string}` | undefined;
|
|
40
42
|
assets_url: '' | `http://${string}` | `https://${string}` | undefined;
|
|
@@ -64,15 +66,22 @@ export interface Parsed_Sveltekit_Config {
|
|
|
64
66
|
// TODO currently incomplete and hack - maybe rethink
|
|
65
67
|
/**
|
|
66
68
|
* Returns Gro-relevant properties of a SvelteKit config
|
|
67
|
-
* as a convenience wrapper around `
|
|
69
|
+
* as a convenience wrapper around `load_svelte_config`.
|
|
68
70
|
* Needed because SvelteKit doesn't expose its config resolver.
|
|
69
71
|
*/
|
|
70
|
-
export const
|
|
71
|
-
dir_or_config
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
export const parse_svelte_config = async ({
|
|
73
|
+
dir_or_config = process.cwd(), // TODO maybe not the best API, maybe a type union? `({svelte_config} | {dir}) & {config_filename}`
|
|
74
|
+
config_filename = SVELTE_CONFIG_FILENAME,
|
|
75
|
+
}: {
|
|
76
|
+
dir_or_config?: string | SvelteConfig;
|
|
77
|
+
config_filename?: string;
|
|
78
|
+
} = EMPTY_OBJECT): Promise<Parsed_Svelte_Config> => {
|
|
79
|
+
const svelte_config =
|
|
80
|
+
typeof dir_or_config === 'string'
|
|
81
|
+
? await load_svelte_config({dir: dir_or_config, config_filename})
|
|
82
|
+
: dir_or_config;
|
|
83
|
+
|
|
84
|
+
const kit = svelte_config?.kit;
|
|
76
85
|
|
|
77
86
|
const alias = {$lib: 'src/lib', ...kit?.alias};
|
|
78
87
|
|
|
@@ -88,17 +97,17 @@ export const init_sveltekit_config = async (
|
|
|
88
97
|
const private_prefix = kit?.env?.privatePrefix;
|
|
89
98
|
const public_prefix = kit?.env?.publicPrefix;
|
|
90
99
|
|
|
91
|
-
const svelte_compile_options: CompileOptions =
|
|
100
|
+
const svelte_compile_options: CompileOptions = svelte_config?.compilerOptions ?? {};
|
|
92
101
|
// Change the default to `generate: 'server'`,
|
|
93
102
|
// because SvelteKit handles the client in the normal cases.
|
|
94
103
|
if (svelte_compile_options.generate === undefined) {
|
|
95
104
|
svelte_compile_options.generate = 'server';
|
|
96
105
|
}
|
|
97
106
|
const svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options); // TODO will kit have these separately?
|
|
98
|
-
const svelte_preprocessors =
|
|
107
|
+
const svelte_preprocessors = svelte_config?.preprocess;
|
|
99
108
|
|
|
100
109
|
return {
|
|
101
|
-
|
|
110
|
+
svelte_config,
|
|
102
111
|
alias,
|
|
103
112
|
base_url,
|
|
104
113
|
assets_url,
|
|
@@ -119,9 +128,10 @@ export const to_default_compile_module_options = ({
|
|
|
119
128
|
generate,
|
|
120
129
|
filename,
|
|
121
130
|
rootDir,
|
|
122
|
-
|
|
131
|
+
warningFilter,
|
|
132
|
+
}: CompileOptions): ModuleCompileOptions => ({dev, generate, filename, rootDir, warningFilter});
|
|
123
133
|
|
|
124
134
|
/**
|
|
125
135
|
* The parsed SvelteKit config for the cwd, cached globally at the module level.
|
|
126
136
|
*/
|
|
127
|
-
export const
|
|
137
|
+
export const default_svelte_config = await parse_svelte_config(); // always load it to keep things simple ahead
|