@ryanatkn/gro 0.164.0 → 0.165.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro.config.default.js +3 -25
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_config.js +2 -7
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +22 -175
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +40 -53
- package/dist/src_json.d.ts.map +1 -1
- package/dist/src_json.js +96 -23
- package/package.json +7 -343
- package/src/lib/constants.ts +1 -0
- package/src/lib/gro.config.default.ts +3 -19
- package/src/lib/gro_config.ts +2 -10
- package/src/lib/package.ts +22 -175
- package/src/lib/package_json.ts +55 -49
- package/src/lib/src_json.ts +102 -30
package/dist/src_json.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { join
|
|
1
|
+
import { join } from 'node:path';
|
|
2
2
|
import { ensure_end, strip_start } from '@ryanatkn/belt/string.js';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import ts from 'typescript';
|
|
5
5
|
import { Src_Json, Src_Modules } from '@ryanatkn/belt/src_json.js';
|
|
6
6
|
import { paths, replace_extension } from "./paths.js";
|
|
7
7
|
import { parse_exports } from "./parse_exports.js";
|
|
8
|
-
import { TS_MATCHER } from "./constants.js";
|
|
8
|
+
import { TS_MATCHER, SVELTE_MATCHER, JSON_MATCHER, CSS_MATCHER } from "./constants.js";
|
|
9
|
+
import { search_fs } from "./search_fs.js";
|
|
9
10
|
export const create_src_json = (package_json, lib_path) => Src_Json.parse({
|
|
10
11
|
name: package_json.name,
|
|
11
12
|
version: package_json.version,
|
|
@@ -18,27 +19,7 @@ export const serialize_src_json = (src_json) => {
|
|
|
18
19
|
export const to_src_modules = (exports, lib_path = paths.lib) => {
|
|
19
20
|
if (!exports)
|
|
20
21
|
return;
|
|
21
|
-
|
|
22
|
-
const file_paths = [];
|
|
23
|
-
for (const [k, _v] of Object.entries(exports)) {
|
|
24
|
-
// Handle different file types
|
|
25
|
-
const source_file_path = k === '.' || k === './'
|
|
26
|
-
? 'index.ts'
|
|
27
|
-
: strip_start(k.endsWith('.js') ? replace_extension(k, '.ts') : k, './');
|
|
28
|
-
const source_file_id = join(lib_path, source_file_path);
|
|
29
|
-
// Check if file exists
|
|
30
|
-
if (!existsSync(source_file_id)) {
|
|
31
|
-
// Handle non-TypeScript files (Svelte, CSS, JSON)
|
|
32
|
-
const extension = extname(source_file_id);
|
|
33
|
-
if (extension === '.svelte' || extension === '.css' || extension === '.json') {
|
|
34
|
-
file_paths.push({ export_key: k, file_path: source_file_id });
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
// TODO still an error for unknown files running `gro gen`, can it use the filer to invalidate correctly?
|
|
38
|
-
throw Error(`Failed to infer source file from package.json export path ${k} - the inferred file ${source_file_id} does not exist`);
|
|
39
|
-
}
|
|
40
|
-
file_paths.push({ export_key: k, file_path: source_file_id });
|
|
41
|
-
}
|
|
22
|
+
const file_paths = collect_file_paths(exports, lib_path);
|
|
42
23
|
// Create a TypeScript program for all TypeScript files
|
|
43
24
|
const ts_files = file_paths
|
|
44
25
|
.filter(({ file_path }) => TS_MATCHER.test(file_path))
|
|
@@ -71,3 +52,95 @@ export const to_src_modules = (exports, lib_path = paths.lib) => {
|
|
|
71
52
|
}
|
|
72
53
|
return result;
|
|
73
54
|
};
|
|
55
|
+
const collect_file_paths = (exports, lib_path) => {
|
|
56
|
+
const file_paths = [];
|
|
57
|
+
// Handle string exports (single default export)
|
|
58
|
+
if (typeof exports === 'string') {
|
|
59
|
+
const source_file = infer_source_from_export(exports, lib_path);
|
|
60
|
+
if (source_file) {
|
|
61
|
+
file_paths.push({ export_key: '.', file_path: source_file });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw Error(`Failed to infer source file from package.json string export "${exports}" - no matching file found in ${lib_path}`);
|
|
65
|
+
}
|
|
66
|
+
return file_paths;
|
|
67
|
+
}
|
|
68
|
+
// Handle object exports
|
|
69
|
+
for (const k in exports) {
|
|
70
|
+
// Skip package.json
|
|
71
|
+
if (k === './package.json')
|
|
72
|
+
continue;
|
|
73
|
+
// Check if this is a pattern export
|
|
74
|
+
if (k.includes('*')) {
|
|
75
|
+
// Handle pattern exports by finding matching files in lib
|
|
76
|
+
const matching_files = search_fs(lib_path, {
|
|
77
|
+
file_filter: (path) => {
|
|
78
|
+
const p = path.replace(ensure_end(lib_path, '/'), '');
|
|
79
|
+
// Only match files in the root directory (no subdirectories)
|
|
80
|
+
if (p.includes('/'))
|
|
81
|
+
return false;
|
|
82
|
+
// Match based on the export pattern
|
|
83
|
+
if (k === './*.js') {
|
|
84
|
+
return TS_MATCHER.test(p) && !p.endsWith('.d.ts') && !p.endsWith('.test.ts');
|
|
85
|
+
}
|
|
86
|
+
else if (k === './*.svelte') {
|
|
87
|
+
return SVELTE_MATCHER.test(p);
|
|
88
|
+
}
|
|
89
|
+
else if (k === './*.json') {
|
|
90
|
+
return JSON_MATCHER.test(p);
|
|
91
|
+
}
|
|
92
|
+
else if (k === './*.css') {
|
|
93
|
+
return CSS_MATCHER.test(p);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
// Add each matching file
|
|
99
|
+
for (const file of matching_files) {
|
|
100
|
+
let export_path;
|
|
101
|
+
if (file.path.endsWith('.ts')) {
|
|
102
|
+
export_path = './' + file.path.replace('.ts', '.js');
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
export_path = './' + file.path;
|
|
106
|
+
}
|
|
107
|
+
file_paths.push({ export_key: export_path, file_path: file.id });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// Handle explicit exports (non-patterns)
|
|
112
|
+
const source_file = infer_source_from_export(k, lib_path);
|
|
113
|
+
if (source_file) {
|
|
114
|
+
file_paths.push({ export_key: k, file_path: source_file });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw Error(`Failed to infer source file from package.json export path ${k} - no matching file found in ${lib_path}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return file_paths;
|
|
122
|
+
};
|
|
123
|
+
const infer_source_from_export = (export_path, lib_path) => {
|
|
124
|
+
// Handle index specially
|
|
125
|
+
if (export_path === '.' || export_path === './') {
|
|
126
|
+
const index_ts = join(lib_path, 'index.ts');
|
|
127
|
+
if (existsSync(index_ts))
|
|
128
|
+
return index_ts;
|
|
129
|
+
const index_js = join(lib_path, 'index.js');
|
|
130
|
+
if (existsSync(index_js))
|
|
131
|
+
return index_js;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const clean_path = strip_start(export_path, './');
|
|
135
|
+
// For .js exports, try .ts first
|
|
136
|
+
if (clean_path.endsWith('.js')) {
|
|
137
|
+
const ts_path = join(lib_path, replace_extension(clean_path, '.ts'));
|
|
138
|
+
if (existsSync(ts_path))
|
|
139
|
+
return ts_path;
|
|
140
|
+
}
|
|
141
|
+
// Try the exact path
|
|
142
|
+
const exact_path = join(lib_path, clean_path);
|
|
143
|
+
if (existsSync(exact_path))
|
|
144
|
+
return exact_path;
|
|
145
|
+
return null;
|
|
146
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.165.0",
|
|
4
4
|
"description": "task runner and toolkit extending SvelteKit",
|
|
5
5
|
"motto": "generate, run, optimize",
|
|
6
6
|
"glyph": "🌰",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"optionalDependencies": {
|
|
80
|
-
"@ryanatkn/moss": ">=0.
|
|
80
|
+
"@ryanatkn/moss": ">=0.33.0",
|
|
81
81
|
"vitest": "^3"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@changesets/types": "^6.1.0",
|
|
86
86
|
"@ryanatkn/eslint-config": "^0.8.0",
|
|
87
87
|
"@ryanatkn/fuz": "^0.145.0",
|
|
88
|
-
"@ryanatkn/moss": "^0.
|
|
88
|
+
"@ryanatkn/moss": "^0.33.0",
|
|
89
89
|
"@sveltejs/adapter-static": "^3.0.9",
|
|
90
90
|
"@sveltejs/kit": "^2.37.1",
|
|
91
91
|
"@sveltejs/package": "^2.5.0",
|
|
@@ -127,350 +127,14 @@
|
|
|
127
127
|
"!dist/**/*.test.*"
|
|
128
128
|
],
|
|
129
129
|
"exports": {
|
|
130
|
+
"./package.json": "./package.json",
|
|
130
131
|
".": {
|
|
131
132
|
"types": "./dist/index.d.ts",
|
|
132
133
|
"default": "./dist/index.js"
|
|
133
134
|
},
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
"default": "./dist/args.js"
|
|
138
|
-
},
|
|
139
|
-
"./build.task.js": {
|
|
140
|
-
"types": "./dist/build.task.d.ts",
|
|
141
|
-
"default": "./dist/build.task.js"
|
|
142
|
-
},
|
|
143
|
-
"./changelog.js": {
|
|
144
|
-
"types": "./dist/changelog.d.ts",
|
|
145
|
-
"default": "./dist/changelog.js"
|
|
146
|
-
},
|
|
147
|
-
"./changeset_helpers.js": {
|
|
148
|
-
"types": "./dist/changeset_helpers.d.ts",
|
|
149
|
-
"default": "./dist/changeset_helpers.js"
|
|
150
|
-
},
|
|
151
|
-
"./changeset.task.js": {
|
|
152
|
-
"types": "./dist/changeset.task.d.ts",
|
|
153
|
-
"default": "./dist/changeset.task.js"
|
|
154
|
-
},
|
|
155
|
-
"./check.task.js": {
|
|
156
|
-
"types": "./dist/check.task.d.ts",
|
|
157
|
-
"default": "./dist/check.task.js"
|
|
158
|
-
},
|
|
159
|
-
"./child_process_logging.js": {
|
|
160
|
-
"types": "./dist/child_process_logging.d.ts",
|
|
161
|
-
"default": "./dist/child_process_logging.js"
|
|
162
|
-
},
|
|
163
|
-
"./clean_fs.js": {
|
|
164
|
-
"types": "./dist/clean_fs.d.ts",
|
|
165
|
-
"default": "./dist/clean_fs.js"
|
|
166
|
-
},
|
|
167
|
-
"./clean.task.js": {
|
|
168
|
-
"types": "./dist/clean.task.d.ts",
|
|
169
|
-
"default": "./dist/clean.task.js"
|
|
170
|
-
},
|
|
171
|
-
"./cli.js": {
|
|
172
|
-
"types": "./dist/cli.d.ts",
|
|
173
|
-
"default": "./dist/cli.js"
|
|
174
|
-
},
|
|
175
|
-
"./commit.task.js": {
|
|
176
|
-
"types": "./dist/commit.task.d.ts",
|
|
177
|
-
"default": "./dist/commit.task.js"
|
|
178
|
-
},
|
|
179
|
-
"./constants.js": {
|
|
180
|
-
"types": "./dist/constants.d.ts",
|
|
181
|
-
"default": "./dist/constants.js"
|
|
182
|
-
},
|
|
183
|
-
"./deploy.task.js": {
|
|
184
|
-
"types": "./dist/deploy.task.d.ts",
|
|
185
|
-
"default": "./dist/deploy.task.js"
|
|
186
|
-
},
|
|
187
|
-
"./dev.task.js": {
|
|
188
|
-
"types": "./dist/dev.task.d.ts",
|
|
189
|
-
"default": "./dist/dev.task.js"
|
|
190
|
-
},
|
|
191
|
-
"./disknode.js": {
|
|
192
|
-
"types": "./dist/disknode.d.ts",
|
|
193
|
-
"default": "./dist/disknode.js"
|
|
194
|
-
},
|
|
195
|
-
"./env.js": {
|
|
196
|
-
"types": "./dist/env.d.ts",
|
|
197
|
-
"default": "./dist/env.js"
|
|
198
|
-
},
|
|
199
|
-
"./esbuild_helpers.js": {
|
|
200
|
-
"types": "./dist/esbuild_helpers.d.ts",
|
|
201
|
-
"default": "./dist/esbuild_helpers.js"
|
|
202
|
-
},
|
|
203
|
-
"./esbuild_plugin_external_worker.js": {
|
|
204
|
-
"types": "./dist/esbuild_plugin_external_worker.d.ts",
|
|
205
|
-
"default": "./dist/esbuild_plugin_external_worker.js"
|
|
206
|
-
},
|
|
207
|
-
"./esbuild_plugin_svelte.js": {
|
|
208
|
-
"types": "./dist/esbuild_plugin_svelte.d.ts",
|
|
209
|
-
"default": "./dist/esbuild_plugin_svelte.js"
|
|
210
|
-
},
|
|
211
|
-
"./esbuild_plugin_sveltekit_local_imports.js": {
|
|
212
|
-
"types": "./dist/esbuild_plugin_sveltekit_local_imports.d.ts",
|
|
213
|
-
"default": "./dist/esbuild_plugin_sveltekit_local_imports.js"
|
|
214
|
-
},
|
|
215
|
-
"./esbuild_plugin_sveltekit_shim_alias.js": {
|
|
216
|
-
"types": "./dist/esbuild_plugin_sveltekit_shim_alias.d.ts",
|
|
217
|
-
"default": "./dist/esbuild_plugin_sveltekit_shim_alias.js"
|
|
218
|
-
},
|
|
219
|
-
"./esbuild_plugin_sveltekit_shim_app.js": {
|
|
220
|
-
"types": "./dist/esbuild_plugin_sveltekit_shim_app.d.ts",
|
|
221
|
-
"default": "./dist/esbuild_plugin_sveltekit_shim_app.js"
|
|
222
|
-
},
|
|
223
|
-
"./esbuild_plugin_sveltekit_shim_env.js": {
|
|
224
|
-
"types": "./dist/esbuild_plugin_sveltekit_shim_env.d.ts",
|
|
225
|
-
"default": "./dist/esbuild_plugin_sveltekit_shim_env.js"
|
|
226
|
-
},
|
|
227
|
-
"./filer.js": {
|
|
228
|
-
"types": "./dist/filer.d.ts",
|
|
229
|
-
"default": "./dist/filer.js"
|
|
230
|
-
},
|
|
231
|
-
"./format_directory.js": {
|
|
232
|
-
"types": "./dist/format_directory.d.ts",
|
|
233
|
-
"default": "./dist/format_directory.js"
|
|
234
|
-
},
|
|
235
|
-
"./format_file.js": {
|
|
236
|
-
"types": "./dist/format_file.d.ts",
|
|
237
|
-
"default": "./dist/format_file.js"
|
|
238
|
-
},
|
|
239
|
-
"./format.task.js": {
|
|
240
|
-
"types": "./dist/format.task.d.ts",
|
|
241
|
-
"default": "./dist/format.task.js"
|
|
242
|
-
},
|
|
243
|
-
"./fs.js": {
|
|
244
|
-
"types": "./dist/fs.d.ts",
|
|
245
|
-
"default": "./dist/fs.js"
|
|
246
|
-
},
|
|
247
|
-
"./gen.task.js": {
|
|
248
|
-
"types": "./dist/gen.task.d.ts",
|
|
249
|
-
"default": "./dist/gen.task.js"
|
|
250
|
-
},
|
|
251
|
-
"./gen.js": {
|
|
252
|
-
"types": "./dist/gen.d.ts",
|
|
253
|
-
"default": "./dist/gen.js"
|
|
254
|
-
},
|
|
255
|
-
"./git.js": {
|
|
256
|
-
"types": "./dist/git.d.ts",
|
|
257
|
-
"default": "./dist/git.js"
|
|
258
|
-
},
|
|
259
|
-
"./github.js": {
|
|
260
|
-
"types": "./dist/github.d.ts",
|
|
261
|
-
"default": "./dist/github.js"
|
|
262
|
-
},
|
|
263
|
-
"./gro_config.js": {
|
|
264
|
-
"types": "./dist/gro_config.d.ts",
|
|
265
|
-
"default": "./dist/gro_config.js"
|
|
266
|
-
},
|
|
267
|
-
"./gro_helpers.js": {
|
|
268
|
-
"types": "./dist/gro_helpers.d.ts",
|
|
269
|
-
"default": "./dist/gro_helpers.js"
|
|
270
|
-
},
|
|
271
|
-
"./gro_plugin_gen.js": {
|
|
272
|
-
"types": "./dist/gro_plugin_gen.d.ts",
|
|
273
|
-
"default": "./dist/gro_plugin_gen.js"
|
|
274
|
-
},
|
|
275
|
-
"./gro_plugin_server.js": {
|
|
276
|
-
"types": "./dist/gro_plugin_server.d.ts",
|
|
277
|
-
"default": "./dist/gro_plugin_server.js"
|
|
278
|
-
},
|
|
279
|
-
"./gro_plugin_sveltekit_app.js": {
|
|
280
|
-
"types": "./dist/gro_plugin_sveltekit_app.d.ts",
|
|
281
|
-
"default": "./dist/gro_plugin_sveltekit_app.js"
|
|
282
|
-
},
|
|
283
|
-
"./gro_plugin_sveltekit_library.js": {
|
|
284
|
-
"types": "./dist/gro_plugin_sveltekit_library.d.ts",
|
|
285
|
-
"default": "./dist/gro_plugin_sveltekit_library.js"
|
|
286
|
-
},
|
|
287
|
-
"./gro.config.default.js": {
|
|
288
|
-
"types": "./dist/gro.config.default.d.ts",
|
|
289
|
-
"default": "./dist/gro.config.default.js"
|
|
290
|
-
},
|
|
291
|
-
"./gro.js": {
|
|
292
|
-
"types": "./dist/gro.d.ts",
|
|
293
|
-
"default": "./dist/gro.js"
|
|
294
|
-
},
|
|
295
|
-
"./hash.js": {
|
|
296
|
-
"types": "./dist/hash.d.ts",
|
|
297
|
-
"default": "./dist/hash.js"
|
|
298
|
-
},
|
|
299
|
-
"./input_path.js": {
|
|
300
|
-
"types": "./dist/input_path.d.ts",
|
|
301
|
-
"default": "./dist/input_path.js"
|
|
302
|
-
},
|
|
303
|
-
"./invoke_task.js": {
|
|
304
|
-
"types": "./dist/invoke_task.d.ts",
|
|
305
|
-
"default": "./dist/invoke_task.js"
|
|
306
|
-
},
|
|
307
|
-
"./invoke.js": {
|
|
308
|
-
"types": "./dist/invoke.d.ts",
|
|
309
|
-
"default": "./dist/invoke.js"
|
|
310
|
-
},
|
|
311
|
-
"./lint.task.js": {
|
|
312
|
-
"types": "./dist/lint.task.d.ts",
|
|
313
|
-
"default": "./dist/lint.task.js"
|
|
314
|
-
},
|
|
315
|
-
"./loader.js": {
|
|
316
|
-
"types": "./dist/loader.d.ts",
|
|
317
|
-
"default": "./dist/loader.js"
|
|
318
|
-
},
|
|
319
|
-
"./module.js": {
|
|
320
|
-
"types": "./dist/module.d.ts",
|
|
321
|
-
"default": "./dist/module.js"
|
|
322
|
-
},
|
|
323
|
-
"./modules.js": {
|
|
324
|
-
"types": "./dist/modules.d.ts",
|
|
325
|
-
"default": "./dist/modules.js"
|
|
326
|
-
},
|
|
327
|
-
"./package_json.js": {
|
|
328
|
-
"types": "./dist/package_json.d.ts",
|
|
329
|
-
"default": "./dist/package_json.js"
|
|
330
|
-
},
|
|
331
|
-
"./package.gen.js": {
|
|
332
|
-
"types": "./dist/package.gen.d.ts",
|
|
333
|
-
"default": "./dist/package.gen.js"
|
|
334
|
-
},
|
|
335
|
-
"./package.js": {
|
|
336
|
-
"types": "./dist/package.d.ts",
|
|
337
|
-
"default": "./dist/package.js"
|
|
338
|
-
},
|
|
339
|
-
"./parse_exports_context.js": {
|
|
340
|
-
"types": "./dist/parse_exports_context.d.ts",
|
|
341
|
-
"default": "./dist/parse_exports_context.js"
|
|
342
|
-
},
|
|
343
|
-
"./parse_exports.js": {
|
|
344
|
-
"types": "./dist/parse_exports.d.ts",
|
|
345
|
-
"default": "./dist/parse_exports.js"
|
|
346
|
-
},
|
|
347
|
-
"./parse_imports.js": {
|
|
348
|
-
"types": "./dist/parse_imports.d.ts",
|
|
349
|
-
"default": "./dist/parse_imports.js"
|
|
350
|
-
},
|
|
351
|
-
"./path.js": {
|
|
352
|
-
"types": "./dist/path.d.ts",
|
|
353
|
-
"default": "./dist/path.js"
|
|
354
|
-
},
|
|
355
|
-
"./paths.js": {
|
|
356
|
-
"types": "./dist/paths.d.ts",
|
|
357
|
-
"default": "./dist/paths.js"
|
|
358
|
-
},
|
|
359
|
-
"./plugin.js": {
|
|
360
|
-
"types": "./dist/plugin.d.ts",
|
|
361
|
-
"default": "./dist/plugin.js"
|
|
362
|
-
},
|
|
363
|
-
"./publish.task.js": {
|
|
364
|
-
"types": "./dist/publish.task.d.ts",
|
|
365
|
-
"default": "./dist/publish.task.js"
|
|
366
|
-
},
|
|
367
|
-
"./register.js": {
|
|
368
|
-
"types": "./dist/register.d.ts",
|
|
369
|
-
"default": "./dist/register.js"
|
|
370
|
-
},
|
|
371
|
-
"./reinstall.task.js": {
|
|
372
|
-
"types": "./dist/reinstall.task.d.ts",
|
|
373
|
-
"default": "./dist/reinstall.task.js"
|
|
374
|
-
},
|
|
375
|
-
"./release.task.js": {
|
|
376
|
-
"types": "./dist/release.task.d.ts",
|
|
377
|
-
"default": "./dist/release.task.js"
|
|
378
|
-
},
|
|
379
|
-
"./resolve_specifier.js": {
|
|
380
|
-
"types": "./dist/resolve_specifier.d.ts",
|
|
381
|
-
"default": "./dist/resolve_specifier.js"
|
|
382
|
-
},
|
|
383
|
-
"./resolve.task.js": {
|
|
384
|
-
"types": "./dist/resolve.task.d.ts",
|
|
385
|
-
"default": "./dist/resolve.task.js"
|
|
386
|
-
},
|
|
387
|
-
"./run_gen.js": {
|
|
388
|
-
"types": "./dist/run_gen.d.ts",
|
|
389
|
-
"default": "./dist/run_gen.js"
|
|
390
|
-
},
|
|
391
|
-
"./run_task.js": {
|
|
392
|
-
"types": "./dist/run_task.d.ts",
|
|
393
|
-
"default": "./dist/run_task.js"
|
|
394
|
-
},
|
|
395
|
-
"./run.task.js": {
|
|
396
|
-
"types": "./dist/run.task.d.ts",
|
|
397
|
-
"default": "./dist/run.task.js"
|
|
398
|
-
},
|
|
399
|
-
"./search_fs.js": {
|
|
400
|
-
"types": "./dist/search_fs.d.ts",
|
|
401
|
-
"default": "./dist/search_fs.js"
|
|
402
|
-
},
|
|
403
|
-
"./src_json.js": {
|
|
404
|
-
"types": "./dist/src_json.d.ts",
|
|
405
|
-
"default": "./dist/src_json.js"
|
|
406
|
-
},
|
|
407
|
-
"./svelte_config.js": {
|
|
408
|
-
"types": "./dist/svelte_config.d.ts",
|
|
409
|
-
"default": "./dist/svelte_config.js"
|
|
410
|
-
},
|
|
411
|
-
"./sveltekit_helpers.js": {
|
|
412
|
-
"types": "./dist/sveltekit_helpers.d.ts",
|
|
413
|
-
"default": "./dist/sveltekit_helpers.js"
|
|
414
|
-
},
|
|
415
|
-
"./sveltekit_shim_app_environment.js": {
|
|
416
|
-
"types": "./dist/sveltekit_shim_app_environment.d.ts",
|
|
417
|
-
"default": "./dist/sveltekit_shim_app_environment.js"
|
|
418
|
-
},
|
|
419
|
-
"./sveltekit_shim_app_forms.js": {
|
|
420
|
-
"types": "./dist/sveltekit_shim_app_forms.d.ts",
|
|
421
|
-
"default": "./dist/sveltekit_shim_app_forms.js"
|
|
422
|
-
},
|
|
423
|
-
"./sveltekit_shim_app_navigation.js": {
|
|
424
|
-
"types": "./dist/sveltekit_shim_app_navigation.d.ts",
|
|
425
|
-
"default": "./dist/sveltekit_shim_app_navigation.js"
|
|
426
|
-
},
|
|
427
|
-
"./sveltekit_shim_app_paths.js": {
|
|
428
|
-
"types": "./dist/sveltekit_shim_app_paths.d.ts",
|
|
429
|
-
"default": "./dist/sveltekit_shim_app_paths.js"
|
|
430
|
-
},
|
|
431
|
-
"./sveltekit_shim_app_state.js": {
|
|
432
|
-
"types": "./dist/sveltekit_shim_app_state.d.ts",
|
|
433
|
-
"default": "./dist/sveltekit_shim_app_state.js"
|
|
434
|
-
},
|
|
435
|
-
"./sveltekit_shim_app.js": {
|
|
436
|
-
"types": "./dist/sveltekit_shim_app.d.ts",
|
|
437
|
-
"default": "./dist/sveltekit_shim_app.js"
|
|
438
|
-
},
|
|
439
|
-
"./sveltekit_shim_env.js": {
|
|
440
|
-
"types": "./dist/sveltekit_shim_env.d.ts",
|
|
441
|
-
"default": "./dist/sveltekit_shim_env.js"
|
|
442
|
-
},
|
|
443
|
-
"./sync.task.js": {
|
|
444
|
-
"types": "./dist/sync.task.d.ts",
|
|
445
|
-
"default": "./dist/sync.task.js"
|
|
446
|
-
},
|
|
447
|
-
"./task_logging.js": {
|
|
448
|
-
"types": "./dist/task_logging.d.ts",
|
|
449
|
-
"default": "./dist/task_logging.js"
|
|
450
|
-
},
|
|
451
|
-
"./task.js": {
|
|
452
|
-
"types": "./dist/task.d.ts",
|
|
453
|
-
"default": "./dist/task.js"
|
|
454
|
-
},
|
|
455
|
-
"./test_helpers.js": {
|
|
456
|
-
"types": "./dist/test_helpers.d.ts",
|
|
457
|
-
"default": "./dist/test_helpers.js"
|
|
458
|
-
},
|
|
459
|
-
"./test.task.js": {
|
|
460
|
-
"types": "./dist/test.task.d.ts",
|
|
461
|
-
"default": "./dist/test.task.js"
|
|
462
|
-
},
|
|
463
|
-
"./typecheck.task.js": {
|
|
464
|
-
"types": "./dist/typecheck.task.d.ts",
|
|
465
|
-
"default": "./dist/typecheck.task.js"
|
|
466
|
-
},
|
|
467
|
-
"./upgrade.task.js": {
|
|
468
|
-
"types": "./dist/upgrade.task.d.ts",
|
|
469
|
-
"default": "./dist/upgrade.task.js"
|
|
470
|
-
},
|
|
471
|
-
"./watch_dir.js": {
|
|
472
|
-
"types": "./dist/watch_dir.d.ts",
|
|
473
|
-
"default": "./dist/watch_dir.js"
|
|
135
|
+
"./*.js": {
|
|
136
|
+
"types": "./dist/*.d.ts",
|
|
137
|
+
"default": "./dist/*.js"
|
|
474
138
|
}
|
|
475
139
|
}
|
|
476
140
|
}
|
package/src/lib/constants.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const JS_MATCHER = /\.(js|mjs|cjs)$/;
|
|
|
38
38
|
export const JSON_MATCHER = /\.json$/;
|
|
39
39
|
export const SVELTE_MATCHER = /\.svelte$/;
|
|
40
40
|
export const SVELTE_RUNES_MATCHER = /\.svelte\.(js|ts)$/; // TODO probably let `.svelte.` appear anywhere - https://github.com/sveltejs/svelte/issues/11536
|
|
41
|
+
export const CSS_MATCHER = /\.css$/;
|
|
41
42
|
/** Extracts the script content from Svelte files. */
|
|
42
43
|
export const SVELTE_SCRIPT_MATCHER = /<script(?:\s+[^>]*)?>([\s\S]*?)<\/script>/gim; // TODO maybe this shouldnt be global? or make a getter?
|
|
43
44
|
export const SVELTEKIT_ENV_MATCHER = /^\$env\/(static|dynamic)\/(public|private)$/;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {resolve} from 'node:path';
|
|
2
|
-
|
|
3
1
|
import type {Create_Gro_Config} from './gro_config.ts';
|
|
4
2
|
import {gro_plugin_sveltekit_library} from './gro_plugin_sveltekit_library.ts';
|
|
5
3
|
import {has_server, gro_plugin_server} from './gro_plugin_server.ts';
|
|
6
4
|
import {gro_plugin_sveltekit_app} from './gro_plugin_sveltekit_app.ts';
|
|
7
5
|
import {has_sveltekit_app, has_sveltekit_library} from './sveltekit_helpers.ts';
|
|
8
6
|
import {gro_plugin_gen} from './gro_plugin_gen.ts';
|
|
9
|
-
import {
|
|
10
|
-
import {find_first_existing_file} from './search_fs.ts';
|
|
7
|
+
import {load_package_json} from './package_json.ts';
|
|
11
8
|
|
|
12
9
|
// TODO hacky, maybe extract utils?
|
|
13
10
|
|
|
@@ -23,29 +20,16 @@ import {find_first_existing_file} from './search_fs.ts';
|
|
|
23
20
|
const config: Create_Gro_Config = async (cfg, svelte_config) => {
|
|
24
21
|
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`?
|
|
25
22
|
|
|
26
|
-
const [
|
|
23
|
+
const [has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] =
|
|
27
24
|
await Promise.all([
|
|
28
|
-
has_dep('@ryanatkn/moss', package_json),
|
|
29
25
|
has_server(),
|
|
30
26
|
has_sveltekit_library(package_json, svelte_config),
|
|
31
27
|
has_sveltekit_app(),
|
|
32
28
|
]);
|
|
33
29
|
|
|
34
|
-
const local_moss_plugin_path = find_first_existing_file([
|
|
35
|
-
'./src/lib/gro_plugin_moss.ts',
|
|
36
|
-
'./src/gro_plugin_moss.ts',
|
|
37
|
-
'./src/routes/gro_plugin_moss.ts', // TODO probably remove this
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
30
|
// put things that generate files before SvelteKit so it can see them
|
|
41
|
-
cfg.plugins =
|
|
31
|
+
cfg.plugins = () =>
|
|
42
32
|
[
|
|
43
|
-
// TODO probably belongs in the gen system
|
|
44
|
-
local_moss_plugin_path
|
|
45
|
-
? (await import(resolve(local_moss_plugin_path))).gro_plugin_moss()
|
|
46
|
-
: has_moss_dep
|
|
47
|
-
? (await import('@ryanatkn/moss/gro_plugin_moss.js')).gro_plugin_moss()
|
|
48
|
-
: null, // lazy load to avoid errors if it's not installed
|
|
49
33
|
gro_plugin_gen(),
|
|
50
34
|
has_server_result.ok ? gro_plugin_server() : null,
|
|
51
35
|
has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
|
package/src/lib/gro_config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {join, resolve} from 'node:path';
|
|
2
2
|
import {existsSync} from 'node:fs';
|
|
3
|
+
import {identity} from '@ryanatkn/belt/function.js';
|
|
3
4
|
|
|
4
5
|
import {GRO_DIST_DIR, IS_THIS_GRO, paths} from './paths.ts';
|
|
5
6
|
import {
|
|
@@ -76,7 +77,7 @@ export type Create_Gro_Config = (
|
|
|
76
77
|
|
|
77
78
|
export const create_empty_gro_config = (): Gro_Config => ({
|
|
78
79
|
plugins: () => [],
|
|
79
|
-
map_package_json:
|
|
80
|
+
map_package_json: identity,
|
|
80
81
|
task_root_dirs: [
|
|
81
82
|
// TODO maybe disable if no SvelteKit `lib` directory? or other detection to improve defaults
|
|
82
83
|
paths.lib,
|
|
@@ -106,15 +107,6 @@ export const SEARCH_EXCLUDER_DEFAULT = new RegExp(
|
|
|
106
107
|
'u',
|
|
107
108
|
);
|
|
108
109
|
|
|
109
|
-
const default_map_package_json: Map_Package_Json = (package_json) => {
|
|
110
|
-
if (package_json.exports) {
|
|
111
|
-
package_json.exports = Object.fromEntries(
|
|
112
|
-
Object.entries(package_json.exports).filter(([k]) => !EXPORTS_EXCLUDER_DEFAULT.test(k)),
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
return package_json;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
110
|
export const EXPORTS_EXCLUDER_DEFAULT = /(\.md|\.(test|ignore)\.|\/(test|fixtures|ignore)\/)/;
|
|
119
111
|
|
|
120
112
|
/**
|