@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.
- 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/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 +16 -18
- 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_logging.js +2 -4
- package/package.json +8 -12
- 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/loader.ts +14 -16
- package/src/lib/package.ts +16 -18
- 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_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
package/dist/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// generated by src/lib/package.gen.ts
|
|
2
2
|
export const package_json = {
|
|
3
3
|
name: '@ryanatkn/gro',
|
|
4
|
-
version: '0.133.
|
|
4
|
+
version: '0.133.4',
|
|
5
5
|
description: 'task runner and toolkit extending SvelteKit',
|
|
6
6
|
motto: 'generate, run, optimize',
|
|
7
7
|
glyph: '🌰',
|
|
@@ -39,14 +39,14 @@ export const package_json = {
|
|
|
39
39
|
'typescript',
|
|
40
40
|
],
|
|
41
41
|
dependencies: {
|
|
42
|
-
'@ryanatkn/belt': '^0.24.
|
|
42
|
+
'@ryanatkn/belt': '^0.24.11',
|
|
43
43
|
chokidar: '^3.6.0',
|
|
44
44
|
dotenv: '^16.4.5',
|
|
45
45
|
'es-module-lexer': '^1.5.4',
|
|
46
46
|
'esm-env': '^1.0.0',
|
|
47
47
|
mri: '^1.2.0',
|
|
48
48
|
prettier: '^3.3.3',
|
|
49
|
-
'prettier-plugin-svelte': '^3.2.
|
|
49
|
+
'prettier-plugin-svelte': '^3.2.6',
|
|
50
50
|
'ts-morph': '^23.0.0',
|
|
51
51
|
tslib: '^2.6.3',
|
|
52
52
|
zod: '^3.23.8',
|
|
@@ -56,18 +56,18 @@ export const package_json = {
|
|
|
56
56
|
'@changesets/changelog-git': '^0.2.0',
|
|
57
57
|
'@changesets/types': '^6.0.0',
|
|
58
58
|
'@ryanatkn/eslint-config': '^0.4.2',
|
|
59
|
-
'@ryanatkn/fuz': '^0.
|
|
60
|
-
'@ryanatkn/moss': '^0.
|
|
59
|
+
'@ryanatkn/fuz': '^0.117.0',
|
|
60
|
+
'@ryanatkn/moss': '^0.10.1',
|
|
61
61
|
'@sveltejs/adapter-static': '^3.0.2',
|
|
62
62
|
'@sveltejs/kit': '^2.5.18',
|
|
63
63
|
'@sveltejs/package': '^2.3.2',
|
|
64
64
|
'@sveltejs/vite-plugin-svelte': '^3.1.1',
|
|
65
65
|
'@types/fs-extra': '^11.0.4',
|
|
66
|
-
'@types/node': '^20.14.
|
|
66
|
+
'@types/node': '^20.14.11',
|
|
67
67
|
esbuild: '^0.21.5',
|
|
68
68
|
eslint: '^9.7.0',
|
|
69
|
-
'eslint-plugin-svelte': '^2.
|
|
70
|
-
svelte: '^5.0.0-next.
|
|
69
|
+
'eslint-plugin-svelte': '^2.43.0',
|
|
70
|
+
svelte: '^5.0.0-next.193',
|
|
71
71
|
'svelte-check': '^3.8.4',
|
|
72
72
|
typescript: '^5.5.3',
|
|
73
73
|
'typescript-eslint': '^8.0.0-alpha.44',
|
|
@@ -211,10 +211,6 @@ export const package_json = {
|
|
|
211
211
|
types: './dist/svelte_helpers.d.ts',
|
|
212
212
|
default: './dist/svelte_helpers.js',
|
|
213
213
|
},
|
|
214
|
-
'./sveltekit_config_global.js': {
|
|
215
|
-
types: './dist/sveltekit_config_global.d.ts',
|
|
216
|
-
default: './dist/sveltekit_config_global.js',
|
|
217
|
-
},
|
|
218
214
|
'./sveltekit_config.js': {
|
|
219
215
|
types: './dist/sveltekit_config.d.ts',
|
|
220
216
|
default: './dist/sveltekit_config.js',
|
|
@@ -266,7 +262,7 @@ export const package_json = {
|
|
|
266
262
|
};
|
|
267
263
|
export const src_json = {
|
|
268
264
|
name: '@ryanatkn/gro',
|
|
269
|
-
version: '0.133.
|
|
265
|
+
version: '0.133.4',
|
|
270
266
|
modules: {
|
|
271
267
|
'.': {
|
|
272
268
|
path: 'index.ts',
|
|
@@ -391,7 +387,7 @@ export const src_json = {
|
|
|
391
387
|
declarations: [
|
|
392
388
|
{ name: 'print_build_result', kind: 'function' },
|
|
393
389
|
{ name: 'to_define_import_meta_env', kind: 'function' },
|
|
394
|
-
{ name: '
|
|
390
|
+
{ name: 'default_ts_transform_options', kind: 'variable' },
|
|
395
391
|
],
|
|
396
392
|
},
|
|
397
393
|
'./esbuild_plugin_external_worker.js': {
|
|
@@ -706,6 +702,9 @@ export const src_json = {
|
|
|
706
702
|
{ name: 'GITHUB_DIRNAME', kind: 'variable' },
|
|
707
703
|
{ name: 'GIT_DIRNAME', kind: 'variable' },
|
|
708
704
|
{ name: 'TSCONFIG_FILENAME', kind: 'variable' },
|
|
705
|
+
{ name: 'TS_MATCHER', kind: 'variable' },
|
|
706
|
+
{ name: 'JSON_MATCHER', kind: 'variable' },
|
|
707
|
+
{ name: 'EVERYTHING_MATCHER', kind: 'variable' },
|
|
709
708
|
],
|
|
710
709
|
},
|
|
711
710
|
'./path.js': {
|
|
@@ -844,16 +843,14 @@ export const src_json = {
|
|
|
844
843
|
{ name: 'SVELTE_RUNES_MATCHER', kind: 'variable' },
|
|
845
844
|
],
|
|
846
845
|
},
|
|
847
|
-
'./sveltekit_config_global.js': {
|
|
848
|
-
path: 'sveltekit_config_global.ts',
|
|
849
|
-
declarations: [{ name: 'sveltekit_config_global', kind: 'variable' }],
|
|
850
|
-
},
|
|
851
846
|
'./sveltekit_config.js': {
|
|
852
847
|
path: 'sveltekit_config.ts',
|
|
853
848
|
declarations: [
|
|
854
849
|
{ name: 'load_sveltekit_config', kind: 'function' },
|
|
855
850
|
{ name: 'Parsed_Sveltekit_Config', kind: 'type' },
|
|
856
851
|
{ name: 'init_sveltekit_config', kind: 'function' },
|
|
852
|
+
{ name: 'to_default_compile_module_options', kind: 'function' },
|
|
853
|
+
{ name: 'default_sveltekit_config', kind: 'variable' },
|
|
857
854
|
],
|
|
858
855
|
},
|
|
859
856
|
'./sveltekit_helpers.js': {
|
|
@@ -864,6 +861,7 @@ export const src_json = {
|
|
|
864
861
|
{ name: 'SVELTE_PACKAGE_CLI', kind: 'variable' },
|
|
865
862
|
{ name: 'SVELTE_PACKAGE_DEP_NAME', kind: 'variable' },
|
|
866
863
|
{ name: 'VITE_CLI', kind: 'variable' },
|
|
864
|
+
{ name: 'SVELTEKIT_ENV_MATCHER', kind: 'variable' },
|
|
867
865
|
{ name: 'has_sveltekit_app', kind: 'function' },
|
|
868
866
|
{ name: 'has_sveltekit_library', kind: 'function' },
|
|
869
867
|
{ name: 'sveltekit_sync', kind: 'function' },
|
package/dist/path_constants.d.ts
CHANGED
|
@@ -19,4 +19,7 @@ export declare const SVELTEKIT_VITE_CACHE_PATH: string;
|
|
|
19
19
|
export declare const GITHUB_DIRNAME = ".github";
|
|
20
20
|
export declare const GIT_DIRNAME = ".git";
|
|
21
21
|
export declare const TSCONFIG_FILENAME = "tsconfig.json";
|
|
22
|
+
export declare const TS_MATCHER: RegExp;
|
|
23
|
+
export declare const JSON_MATCHER: RegExp;
|
|
24
|
+
export declare const EVERYTHING_MATCHER: RegExp;
|
|
22
25
|
//# sourceMappingURL=path_constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path_constants.d.ts","sourceRoot":"../src/lib/","sources":["path_constants.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,eAAe,QAAuB,CAAC;AACpD,eAAO,MAAM,UAAU,QAAuB,CAAC;AAC/C,eAAO,MAAM,OAAO,QAAoB,CAAC;AACzC,eAAO,MAAM,WAAW,QAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAC/C,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,yBAAyB,QAAkC,CAAC;AACzE,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,iBAAiB,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"path_constants.d.ts","sourceRoot":"../src/lib/","sources":["path_constants.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,eAAe,QAAuB,CAAC;AACpD,eAAO,MAAM,UAAU,QAAuB,CAAC;AAC/C,eAAO,MAAM,OAAO,QAAoB,CAAC;AACzC,eAAO,MAAM,WAAW,QAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAC/C,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,yBAAyB,QAAkC,CAAC;AACzE,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,eAAO,MAAM,YAAY,QAAc,CAAC;AACxC,eAAO,MAAM,kBAAkB,QAAO,CAAC"}
|
package/dist/path_constants.js
CHANGED
|
@@ -26,3 +26,6 @@ export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
|
|
|
26
26
|
export const GITHUB_DIRNAME = '.github';
|
|
27
27
|
export const GIT_DIRNAME = '.git';
|
|
28
28
|
export const TSCONFIG_FILENAME = 'tsconfig.json';
|
|
29
|
+
export const TS_MATCHER = /\.(ts|tsx|mts|cts)$/;
|
|
30
|
+
export const JSON_MATCHER = /\.(json)$/;
|
|
31
|
+
export const EVERYTHING_MATCHER = /.*/;
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"../src/lib/","sources":["paths.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AASvC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"../src/lib/","sources":["paths.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AASvC,eAAO,MAAM,WAAW,QAA8C,CAAC;AACvE,eAAO,MAAM,QAAQ,QAA2B,CAAC;AACjD,eAAO,MAAM,OAAO,QAAiB,CAAC;AACtC,eAAO,MAAM,cAAc,QAAiD,CAAC;AAE7E,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,aAAc,MAAM,KAAG,KAW/C,CAAC;AAEF,eAAO,MAAM,WAAW,OAAQ,OAAO,KAAG,KAA4C,CAAC;AACvF,eAAO,MAAM,SAAS,OAAQ,OAAO,KAAG,OAAwD,CAAC;AAGjG,eAAO,MAAM,YAAY,OAAQ,OAAO,gBAAwB,MACnC,CAAC;AAG9B,eAAO,MAAM,oBAAoB,YAAa,OAAO,gBAA6B,MACtD,CAAC;AAI7B,eAAO,MAAM,oBAAoB,cAAe,MAAM,gBAA+B,OAC3D,CAAC;AAE3B,eAAO,MAAM,UAAU,SAAU,MAAM,gBAA0B,MAMhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,MAAM,iBAAiB,MAAM,KAAG,MAGvE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,OAA8B,CAAC;AAEjD,eAAO,MAAM,eAAe,SAAS,CAAC;AAYtC,eAAO,MAAM,WAAW,SAAsC,CAAC;AAC/D;;GAEG;AACH,eAAO,MAAM,SAAS,OAA2D,CAAC;AAClF,eAAO,MAAM,YAAY,QAAgD,CAAC"}
|
package/dist/paths.js
CHANGED
|
@@ -3,17 +3,17 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { strip_end } from '@ryanatkn/belt/string.js';
|
|
4
4
|
import { gray } from '@ryanatkn/belt/styletext.js';
|
|
5
5
|
import { GRO_CONFIG_PATH, GRO_DEV_DIR, GRO_DIR, SOURCE_DIR, SVELTEKIT_DIST_DIRNAME, } from './path_constants.js';
|
|
6
|
-
import {
|
|
6
|
+
import { default_sveltekit_config } from './sveltekit_config.js';
|
|
7
7
|
/*
|
|
8
8
|
|
|
9
9
|
A path `id` is an absolute path to the source/.gro/dist directory.
|
|
10
10
|
It's the same name that Rollup uses.
|
|
11
11
|
|
|
12
12
|
*/
|
|
13
|
-
export const LIB_DIRNAME = basename(
|
|
13
|
+
export const LIB_DIRNAME = basename(default_sveltekit_config.lib_path);
|
|
14
14
|
export const LIB_PATH = SOURCE_DIR + LIB_DIRNAME;
|
|
15
15
|
export const LIB_DIR = LIB_PATH + '/';
|
|
16
|
-
export const ROUTES_DIRNAME = basename(
|
|
16
|
+
export const ROUTES_DIRNAME = basename(default_sveltekit_config.routes_path);
|
|
17
17
|
export const create_paths = (root_dir) => {
|
|
18
18
|
// TODO remove reliance on trailing slash towards windows support
|
|
19
19
|
const root = strip_end(root_dir, '/') + '/';
|
package/dist/run_gen.js
CHANGED
|
@@ -2,7 +2,7 @@ import { red } from '@ryanatkn/belt/styletext.js';
|
|
|
2
2
|
import { print_error } from '@ryanatkn/belt/print.js';
|
|
3
3
|
import { to_gen_result, } from './gen.js';
|
|
4
4
|
import { print_path } from './paths.js';
|
|
5
|
-
import {
|
|
5
|
+
import { default_sveltekit_config } from './sveltekit_config.js';
|
|
6
6
|
export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
|
|
7
7
|
export const run_gen = async (gen_modules, config, log, timings, format_file) => {
|
|
8
8
|
let input_count = 0;
|
|
@@ -15,7 +15,7 @@ export const run_gen = async (gen_modules, config, log, timings, format_file) =>
|
|
|
15
15
|
// Perform code generation by calling `gen` on the module.
|
|
16
16
|
const gen_ctx = {
|
|
17
17
|
config,
|
|
18
|
-
sveltekit_config:
|
|
18
|
+
sveltekit_config: default_sveltekit_config,
|
|
19
19
|
origin_id: id,
|
|
20
20
|
log,
|
|
21
21
|
};
|
package/dist/run_task.js
CHANGED
|
@@ -3,7 +3,7 @@ import { print_log_label, System_Logger } from '@ryanatkn/belt/log.js';
|
|
|
3
3
|
import { parse_args } from './args.js';
|
|
4
4
|
import { log_task_help } from './task_logging.js';
|
|
5
5
|
import { Task_Error } from './task.js';
|
|
6
|
-
import {
|
|
6
|
+
import { default_sveltekit_config } from './sveltekit_config.js';
|
|
7
7
|
export const run_task = async (task_meta, unparsed_args, invoke_task, config, timings) => {
|
|
8
8
|
const { task } = task_meta.mod;
|
|
9
9
|
const log = new System_Logger(print_log_label(task_meta.name));
|
|
@@ -27,7 +27,7 @@ export const run_task = async (task_meta, unparsed_args, invoke_task, config, ti
|
|
|
27
27
|
output = await task.run({
|
|
28
28
|
args,
|
|
29
29
|
config,
|
|
30
|
-
sveltekit_config:
|
|
30
|
+
sveltekit_config: default_sveltekit_config,
|
|
31
31
|
log,
|
|
32
32
|
timings,
|
|
33
33
|
invoke_task: (invoked_task_name, invoked_args, invoked_config) => invoke_task(invoked_task_name, invoked_args, invoked_config ?? config, timings),
|
|
@@ -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
|
/**
|
|
4
4
|
* Loads a SvelteKit config at `dir`.
|
|
5
5
|
* @returns `null` if no config is found
|
|
@@ -34,7 +34,7 @@ export interface Parsed_Sveltekit_Config {
|
|
|
34
34
|
private_prefix: string | undefined;
|
|
35
35
|
public_prefix: string | undefined;
|
|
36
36
|
svelte_compile_options: CompileOptions;
|
|
37
|
-
svelte_compile_module_options:
|
|
37
|
+
svelte_compile_module_options: CompileOptions;
|
|
38
38
|
svelte_preprocessors: PreprocessorGroup | PreprocessorGroup[] | undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -43,4 +43,9 @@ export interface Parsed_Sveltekit_Config {
|
|
|
43
43
|
* Needed because SvelteKit doesn't expose its config resolver.
|
|
44
44
|
*/
|
|
45
45
|
export declare const init_sveltekit_config: (dir_or_config?: string | SveltekitConfig) => Promise<Parsed_Sveltekit_Config>;
|
|
46
|
+
export declare const to_default_compile_module_options: ({ dev, generate, filename, rootDir, }: CompileOptions) => ModuleCompileOptions;
|
|
47
|
+
/**
|
|
48
|
+
* The parsed SvelteKit config for the cwd, cached globally at the module level.
|
|
49
|
+
*/
|
|
50
|
+
export declare const default_sveltekit_config: Parsed_Sveltekit_Config;
|
|
46
51
|
//# sourceMappingURL=sveltekit_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit_config.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAC,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sveltekit_config.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAC,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAW7F;;;GAGG;AACH,eAAO,MAAM,qBAAqB,SAC5B,MAAM,KACT,OAAO,CAAC,eAAe,GAAG,IAAI,CAMhC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IAEvC,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,EAAE,GAAG,UAAU,MAAM,EAAE,GAAG,WAAW,MAAM,EAAE,GAAG,SAAS,CAAC;IAGtE;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,sBAAsB,EAAE,cAAc,CAAC;IACvC,6BAA6B,EAAE,cAAc,CAAC;IAC9C,oBAAoB,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC;CAC1E;AAGD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,mBAClB,MAAM,GAAG,eAAe,KACrC,OAAO,CAAC,uBAAuB,CA2CjC,CAAC;AAEF,eAAO,MAAM,iCAAiC,0CAK3C,cAAc,KAAG,oBAA4D,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,wBAAwB,yBAAgC,CAAC"}
|
package/dist/sveltekit_config.js
CHANGED
|
@@ -37,7 +37,12 @@ export const init_sveltekit_config = async (dir_or_config = process.cwd()) => {
|
|
|
37
37
|
const private_prefix = kit?.env?.privatePrefix;
|
|
38
38
|
const public_prefix = kit?.env?.publicPrefix;
|
|
39
39
|
const svelte_compile_options = sveltekit_config?.compilerOptions ?? {};
|
|
40
|
-
|
|
40
|
+
// Change the default to `generate: 'server'`,
|
|
41
|
+
// because SvelteKit handles the client in the normal cases.
|
|
42
|
+
if (svelte_compile_options.generate === undefined) {
|
|
43
|
+
svelte_compile_options.generate = 'server';
|
|
44
|
+
}
|
|
45
|
+
const svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options); // TODO will kit have these separately?
|
|
41
46
|
const svelte_preprocessors = sveltekit_config?.preprocess;
|
|
42
47
|
return {
|
|
43
48
|
sveltekit_config,
|
|
@@ -55,3 +60,8 @@ export const init_sveltekit_config = async (dir_or_config = process.cwd()) => {
|
|
|
55
60
|
svelte_preprocessors,
|
|
56
61
|
};
|
|
57
62
|
};
|
|
63
|
+
export const to_default_compile_module_options = ({ dev, generate, filename, rootDir, }) => ({ dev, generate, filename, rootDir });
|
|
64
|
+
/**
|
|
65
|
+
* The parsed SvelteKit config for the cwd, cached globally at the module level.
|
|
66
|
+
*/
|
|
67
|
+
export const default_sveltekit_config = await init_sveltekit_config(); // always load it to keep things simple ahead
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Result } from '@ryanatkn/belt/result.js';
|
|
2
2
|
import { Package_Json } from './package_json.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type Parsed_Sveltekit_Config } from './sveltekit_config.js';
|
|
4
4
|
import { type Cli } from './cli.js';
|
|
5
5
|
export declare const SVELTEKIT_CLI = "svelte-kit";
|
|
6
6
|
export declare const SVELTE_CHECK_CLI = "svelte-check";
|
|
7
7
|
export declare const SVELTE_PACKAGE_CLI = "svelte-package";
|
|
8
8
|
export declare const SVELTE_PACKAGE_DEP_NAME = "@sveltejs/package";
|
|
9
9
|
export declare const VITE_CLI = "vite";
|
|
10
|
+
export declare const SVELTEKIT_ENV_MATCHER: RegExp;
|
|
10
11
|
export declare const has_sveltekit_app: () => Result<object, {
|
|
11
12
|
message: string;
|
|
12
13
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit_helpers.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAGrD,OAAO,EAAC,YAAY,EAAoB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sveltekit_helpers.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAGrD,OAAO,EAAC,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAA2B,KAAK,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE7F,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAGpE,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B,eAAO,MAAM,qBAAqB,QAAgD,CAAC;AAEnF,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAMpE,CAAC;AAEF,eAAO,MAAM,qBAAqB,kBAClB,YAAY,qBACT,uBAAuB,KACvC,MAAM,CAAC,MAAM,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAqBlC,CAAC;AAEF,eAAO,MAAM,cAAc,mBACX,MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,mBAC/B,MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CAUd,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { Package_Json, load_package_json } from './package_json.js';
|
|
3
|
-
import {
|
|
3
|
+
import { default_sveltekit_config } from './sveltekit_config.js';
|
|
4
4
|
import { SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME } from './path_constants.js';
|
|
5
5
|
import { find_cli, spawn_cli, to_cli_name } from './cli.js';
|
|
6
6
|
import { Task_Error } from './task.js';
|
|
@@ -9,6 +9,7 @@ export const SVELTE_CHECK_CLI = 'svelte-check';
|
|
|
9
9
|
export const SVELTE_PACKAGE_CLI = 'svelte-package';
|
|
10
10
|
export const SVELTE_PACKAGE_DEP_NAME = '@sveltejs/package';
|
|
11
11
|
export const VITE_CLI = 'vite';
|
|
12
|
+
export const SVELTEKIT_ENV_MATCHER = /^\$env\/(static|dynamic)\/(public|private)$/;
|
|
12
13
|
export const has_sveltekit_app = () => {
|
|
13
14
|
if (!existsSync(SVELTEKIT_CONFIG_FILENAME)) {
|
|
14
15
|
return { ok: false, message: `no SvelteKit config found at ${SVELTEKIT_CONFIG_FILENAME}` };
|
|
@@ -16,7 +17,7 @@ export const has_sveltekit_app = () => {
|
|
|
16
17
|
// TODO check for routes?
|
|
17
18
|
return { ok: true };
|
|
18
19
|
};
|
|
19
|
-
export const has_sveltekit_library = (package_json, sveltekit_config =
|
|
20
|
+
export const has_sveltekit_library = (package_json, sveltekit_config = default_sveltekit_config) => {
|
|
20
21
|
const has_sveltekit_app_result = has_sveltekit_app();
|
|
21
22
|
if (!has_sveltekit_app_result.ok) {
|
|
22
23
|
return has_sveltekit_app_result;
|
package/dist/task_logging.js
CHANGED
|
@@ -20,7 +20,7 @@ export const log_tasks = (log, loaded_tasks, log_intro = true) => {
|
|
|
20
20
|
const longest_task_name = to_max_length(modules, (m) => m.name);
|
|
21
21
|
for (const resolved_input_file of resolved_input_files) {
|
|
22
22
|
const meta = modules.find((m) => m.id === resolved_input_file.id);
|
|
23
|
-
logged.push('\n' + cyan(
|
|
23
|
+
logged.push('\n' + cyan(meta.name.padEnd(longest_task_name)), ' ', meta.mod.task.summary ?? '');
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
log[log_intro ? 'info' : 'plain'](logged.join('') + '\n');
|
|
@@ -43,7 +43,7 @@ export const log_task_help = (log, meta) => {
|
|
|
43
43
|
const longest_default = to_max_length(properties, (p) => print_value(p.schema.default));
|
|
44
44
|
for (const property of properties) {
|
|
45
45
|
const name = property.name === '_' ? ARGS_PROPERTY_NAME : property.name;
|
|
46
|
-
logged.push(`\n${green(
|
|
46
|
+
logged.push(`\n${green(name.padEnd(longest_task_name))} `, gray(property.schema.type.padEnd(longest_type)) + ' ', print_value(property.schema.default).padEnd(longest_default) + ' ', property.schema.description || '(no description available)');
|
|
47
47
|
}
|
|
48
48
|
if (!properties.length) {
|
|
49
49
|
logged.push('\n' + gray('this task has no args'));
|
|
@@ -71,8 +71,6 @@ const to_arg_properties = (def, meta) => {
|
|
|
71
71
|
}
|
|
72
72
|
return properties;
|
|
73
73
|
};
|
|
74
|
-
// quick n dirty padding logic
|
|
75
|
-
const pad = (s, n) => s + ' '.repeat(n - s.length);
|
|
76
74
|
const to_max_length = (items, toString) => items.reduce((max, m) => Math.max(toString(m).length, max), 0);
|
|
77
75
|
// The following Zod helpers only need to support single-depth schemas for CLI args,
|
|
78
76
|
// but there's generic recursion to handle things like `ZodOptional` and `ZodDefault`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.133.
|
|
3
|
+
"version": "0.133.4",
|
|
4
4
|
"description": "task runner and toolkit extending SvelteKit",
|
|
5
5
|
"motto": "generate, run, optimize",
|
|
6
6
|
"glyph": "🌰",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"typescript"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ryanatkn/belt": "^0.24.
|
|
52
|
+
"@ryanatkn/belt": "^0.24.11",
|
|
53
53
|
"chokidar": "^3.6.0",
|
|
54
54
|
"dotenv": "^16.4.5",
|
|
55
55
|
"es-module-lexer": "^1.5.4",
|
|
56
56
|
"esm-env": "^1.0.0",
|
|
57
57
|
"mri": "^1.2.0",
|
|
58
58
|
"prettier": "^3.3.3",
|
|
59
|
-
"prettier-plugin-svelte": "^3.2.
|
|
59
|
+
"prettier-plugin-svelte": "^3.2.6",
|
|
60
60
|
"ts-morph": "^23.0.0",
|
|
61
61
|
"tslib": "^2.6.3",
|
|
62
62
|
"zod": "^3.23.8"
|
|
@@ -69,18 +69,18 @@
|
|
|
69
69
|
"@changesets/changelog-git": "^0.2.0",
|
|
70
70
|
"@changesets/types": "^6.0.0",
|
|
71
71
|
"@ryanatkn/eslint-config": "^0.4.2",
|
|
72
|
-
"@ryanatkn/fuz": "^0.
|
|
73
|
-
"@ryanatkn/moss": "^0.
|
|
72
|
+
"@ryanatkn/fuz": "^0.117.0",
|
|
73
|
+
"@ryanatkn/moss": "^0.10.1",
|
|
74
74
|
"@sveltejs/adapter-static": "^3.0.2",
|
|
75
75
|
"@sveltejs/kit": "^2.5.18",
|
|
76
76
|
"@sveltejs/package": "^2.3.2",
|
|
77
77
|
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
78
78
|
"@types/fs-extra": "^11.0.4",
|
|
79
|
-
"@types/node": "^20.14.
|
|
79
|
+
"@types/node": "^20.14.11",
|
|
80
80
|
"esbuild": "^0.21.5",
|
|
81
81
|
"eslint": "^9.7.0",
|
|
82
|
-
"eslint-plugin-svelte": "^2.
|
|
83
|
-
"svelte": "^5.0.0-next.
|
|
82
|
+
"eslint-plugin-svelte": "^2.43.0",
|
|
83
|
+
"svelte": "^5.0.0-next.193",
|
|
84
84
|
"svelte-check": "^3.8.4",
|
|
85
85
|
"typescript": "^5.5.3",
|
|
86
86
|
"typescript-eslint": "^8.0.0-alpha.44",
|
|
@@ -378,10 +378,6 @@
|
|
|
378
378
|
"types": "./dist/svelte_helpers.d.ts",
|
|
379
379
|
"default": "./dist/svelte_helpers.js"
|
|
380
380
|
},
|
|
381
|
-
"./sveltekit_config_global.js": {
|
|
382
|
-
"types": "./dist/sveltekit_config_global.d.ts",
|
|
383
|
-
"default": "./dist/sveltekit_config_global.js"
|
|
384
|
-
},
|
|
385
381
|
"./sveltekit_config.js": {
|
|
386
382
|
"types": "./dist/sveltekit_config.d.ts",
|
|
387
383
|
"default": "./dist/sveltekit_config.js"
|
package/src/lib/build.task.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {clean_fs} from './clean_fs.js';
|
|
|
6
6
|
|
|
7
7
|
export const Args = z
|
|
8
8
|
.object({
|
|
9
|
+
sync: z.boolean({description: 'dual of no-sync'}).default(true),
|
|
10
|
+
'no-sync': z.boolean({description: 'opt out of gro sync'}).default(false),
|
|
9
11
|
install: z.boolean({description: 'dual of no-install'}).default(true),
|
|
10
12
|
'no-install': z // convenience, same as `gro build -- gro sync --no-install` but the latter takes precedence
|
|
11
13
|
.boolean({description: 'opt out of `npm install` before building'})
|
|
@@ -19,10 +21,11 @@ export const task: Task<Args> = {
|
|
|
19
21
|
Args,
|
|
20
22
|
run: async (ctx): Promise<void> => {
|
|
21
23
|
const {args, invoke_task} = ctx;
|
|
22
|
-
const {install} = args;
|
|
24
|
+
const {sync, install} = args;
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
if (sync) {
|
|
27
|
+
await invoke_task('sync', {install});
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
// TODO possibly detect if the git workspace is clean, and ask for confirmation if not,
|
|
28
31
|
// because we're not doing things like `gro gen` here because that's a dev/CI concern
|
|
@@ -41,7 +41,7 @@ export const to_define_import_meta_env = (
|
|
|
41
41
|
[import_meta_env + 'BASE_URL']: JSON.stringify(base_url || '/'), // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
export const
|
|
44
|
+
export const default_ts_transform_options: esbuild.TransformOptions = {
|
|
45
45
|
target: 'esnext',
|
|
46
46
|
format: 'esm',
|
|
47
47
|
loader: 'ts',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
3
3
|
import {basename} from 'node:path';
|
|
4
|
-
import type {CompileOptions,
|
|
4
|
+
import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
|
|
5
5
|
|
|
6
6
|
import {print_build_result, to_define_import_meta_env} from './esbuild_helpers.js';
|
|
7
7
|
import {resolve_specifier} from './resolve_specifier.js';
|
|
@@ -36,8 +36,8 @@ export const esbuild_plugin_external_worker = ({
|
|
|
36
36
|
build_options,
|
|
37
37
|
dir = process.cwd(),
|
|
38
38
|
svelte_compile_options,
|
|
39
|
-
svelte_preprocessors,
|
|
40
39
|
svelte_compile_module_options,
|
|
40
|
+
svelte_preprocessors,
|
|
41
41
|
alias,
|
|
42
42
|
base_url,
|
|
43
43
|
assets_url,
|
|
@@ -67,6 +67,8 @@ export const esbuild_plugin_external_worker = ({
|
|
|
67
67
|
}),
|
|
68
68
|
esbuild_plugin_sveltekit_shim_alias({dir, alias}),
|
|
69
69
|
esbuild_plugin_svelte({
|
|
70
|
+
dev,
|
|
71
|
+
base_url,
|
|
70
72
|
dir,
|
|
71
73
|
svelte_compile_options,
|
|
72
74
|
svelte_compile_module_options,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
2
|
import {
|
|
3
3
|
compile,
|
|
4
4
|
compileModule,
|
|
@@ -11,21 +11,43 @@ import {readFile} from 'node:fs/promises';
|
|
|
11
11
|
import {relative} from 'node:path';
|
|
12
12
|
|
|
13
13
|
import {SVELTE_MATCHER, SVELTE_RUNES_MATCHER} from './svelte_helpers.js';
|
|
14
|
+
import {to_define_import_meta_env, default_ts_transform_options} from './esbuild_helpers.js';
|
|
15
|
+
import {
|
|
16
|
+
default_sveltekit_config,
|
|
17
|
+
to_default_compile_module_options,
|
|
18
|
+
type Parsed_Sveltekit_Config,
|
|
19
|
+
} from './sveltekit_config.js';
|
|
20
|
+
import {TS_MATCHER} from './path_constants.js';
|
|
14
21
|
|
|
15
22
|
export interface Options {
|
|
23
|
+
dev: boolean;
|
|
24
|
+
base_url: Parsed_Sveltekit_Config['base_url'];
|
|
16
25
|
dir?: string;
|
|
17
26
|
svelte_compile_options?: CompileOptions;
|
|
18
27
|
svelte_compile_module_options?: ModuleCompileOptions;
|
|
19
28
|
svelte_preprocessors?: PreprocessorGroup | PreprocessorGroup[];
|
|
29
|
+
ts_transform_options?: esbuild.TransformOptions;
|
|
30
|
+
is_ts?: (filename: string) => boolean;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
export const esbuild_plugin_svelte = (options: Options
|
|
33
|
+
export const esbuild_plugin_svelte = (options: Options): esbuild.Plugin => {
|
|
23
34
|
const {
|
|
35
|
+
dev,
|
|
36
|
+
base_url,
|
|
24
37
|
dir = process.cwd(),
|
|
25
|
-
svelte_compile_options =
|
|
26
|
-
svelte_compile_module_options =
|
|
38
|
+
svelte_compile_options = default_sveltekit_config.svelte_compile_options,
|
|
39
|
+
svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options),
|
|
27
40
|
svelte_preprocessors,
|
|
41
|
+
ts_transform_options = default_ts_transform_options,
|
|
42
|
+
is_ts = (f) => TS_MATCHER.test(f),
|
|
28
43
|
} = options;
|
|
44
|
+
|
|
45
|
+
const final_ts_transform_options: esbuild.TransformOptions = {
|
|
46
|
+
...ts_transform_options,
|
|
47
|
+
define: to_define_import_meta_env(dev, base_url),
|
|
48
|
+
sourcemap: 'inline',
|
|
49
|
+
};
|
|
50
|
+
|
|
29
51
|
return {
|
|
30
52
|
name: 'svelte',
|
|
31
53
|
setup: (build) => {
|
|
@@ -33,9 +55,17 @@ export const esbuild_plugin_svelte = (options: Options = {}): esbuild.Plugin =>
|
|
|
33
55
|
const source = await readFile(path, 'utf8');
|
|
34
56
|
try {
|
|
35
57
|
const filename = relative(dir, path);
|
|
36
|
-
const
|
|
37
|
-
|
|
58
|
+
const js_source = is_ts(filename)
|
|
59
|
+
? (
|
|
60
|
+
await esbuild.transform(source, {
|
|
61
|
+
...final_ts_transform_options,
|
|
62
|
+
sourcefile: filename,
|
|
63
|
+
})
|
|
64
|
+
).code // TODO @many use warnings? handle not-inline sourcemaps?
|
|
65
|
+
: source;
|
|
66
|
+
const {js, warnings} = compileModule(js_source, {
|
|
38
67
|
...svelte_compile_module_options,
|
|
68
|
+
filename,
|
|
39
69
|
});
|
|
40
70
|
const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
|
|
41
71
|
return {
|
|
@@ -46,6 +76,7 @@ export const esbuild_plugin_svelte = (options: Options = {}): esbuild.Plugin =>
|
|
|
46
76
|
return {errors: [convert_svelte_message_to_esbuild(path, source, err)]};
|
|
47
77
|
}
|
|
48
78
|
});
|
|
79
|
+
|
|
49
80
|
build.onLoad({filter: SVELTE_MATCHER}, async ({path}) => {
|
|
50
81
|
let source = await readFile(path, 'utf8');
|
|
51
82
|
try {
|
|
@@ -53,12 +84,8 @@ export const esbuild_plugin_svelte = (options: Options = {}): esbuild.Plugin =>
|
|
|
53
84
|
const preprocessed = svelte_preprocessors
|
|
54
85
|
? await preprocess(source, svelte_preprocessors, {filename})
|
|
55
86
|
: null;
|
|
56
|
-
// TODO handle preprocessor sourcemaps, same as in loader - merge?
|
|
57
87
|
if (preprocessed?.code) source = preprocessed.code;
|
|
58
|
-
const {js, warnings} = compile(source, {
|
|
59
|
-
filename,
|
|
60
|
-
...svelte_compile_options,
|
|
61
|
-
});
|
|
88
|
+
const {js, warnings} = compile(source, {...svelte_compile_options, filename});
|
|
62
89
|
const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
|
|
63
90
|
return {
|
|
64
91
|
contents,
|
|
@@ -3,6 +3,7 @@ import {readFile} from 'node:fs/promises';
|
|
|
3
3
|
import {dirname} from 'node:path';
|
|
4
4
|
|
|
5
5
|
import {resolve_specifier} from './resolve_specifier.js';
|
|
6
|
+
import {EVERYTHING_MATCHER} from './path_constants.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Adds support for imports to both `.ts` and `.js`,
|
|
@@ -18,14 +19,20 @@ export const esbuild_plugin_sveltekit_local_imports = (): esbuild.Plugin => ({
|
|
|
18
19
|
const {path_id, namespace} = resolve_specifier(path, dirname(importer));
|
|
19
20
|
return {path: path_id, namespace}; // `namespace` may be `undefined`, but esbuild needs the absolute path for json etc
|
|
20
21
|
});
|
|
21
|
-
build.onLoad(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
build.onLoad(
|
|
23
|
+
{filter: EVERYTHING_MATCHER, namespace: 'sveltekit_local_imports_ts'},
|
|
24
|
+
async ({path}) => ({
|
|
25
|
+
contents: await readFile(path),
|
|
26
|
+
loader: 'ts',
|
|
27
|
+
resolveDir: dirname(path),
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
build.onLoad(
|
|
31
|
+
{filter: EVERYTHING_MATCHER, namespace: 'sveltekit_local_imports_js'},
|
|
32
|
+
async ({path}) => ({
|
|
33
|
+
contents: await readFile(path),
|
|
34
|
+
resolveDir: dirname(path),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
30
37
|
},
|
|
31
38
|
});
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
sveltekit_shim_app_specifiers,
|
|
7
7
|
} from './sveltekit_shim_app.js';
|
|
8
8
|
import type {Parsed_Sveltekit_Config} from './sveltekit_config.js';
|
|
9
|
+
import {EVERYTHING_MATCHER} from './path_constants.js';
|
|
9
10
|
|
|
10
11
|
export interface Options {
|
|
11
12
|
dev: boolean;
|
|
@@ -27,14 +28,14 @@ export const esbuild_plugin_sveltekit_shim_app = ({
|
|
|
27
28
|
path: sveltekit_shim_app_specifiers.get(path)!,
|
|
28
29
|
namespace: 'sveltekit_shim_app_paths',
|
|
29
30
|
}));
|
|
30
|
-
build.onLoad({filter:
|
|
31
|
+
build.onLoad({filter: EVERYTHING_MATCHER, namespace: 'sveltekit_shim_app_paths'}, () => ({
|
|
31
32
|
contents: render_sveltekit_shim_app_paths(base_url, assets_url),
|
|
32
33
|
}));
|
|
33
34
|
build.onResolve({filter: /^\$app\/environment$/}, ({path}) => ({
|
|
34
35
|
path: sveltekit_shim_app_specifiers.get(path)!,
|
|
35
36
|
namespace: 'sveltekit_shim_app_environment',
|
|
36
37
|
}));
|
|
37
|
-
build.onLoad({filter:
|
|
38
|
+
build.onLoad({filter: EVERYTHING_MATCHER, namespace: 'sveltekit_shim_app_environment'}, () => ({
|
|
38
39
|
contents: render_sveltekit_shim_app_environment(dev),
|
|
39
40
|
}));
|
|
40
41
|
},
|