powerlines 0.27.0 → 0.28.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/{api-CHbGX3BG.d.ts → api-BgDfE1J3.d.ts} +2 -2
- package/dist/{api-DGMQopJ5.d.cts → api-D-3EvHyy.d.cts} +2 -2
- package/dist/api.cjs +2 -2
- package/dist/api.d.cts +5 -2
- package/dist/api.d.ts +5 -2
- package/dist/api.js +1 -1
- package/dist/astro.cjs +4 -4
- package/dist/astro.d.cts +4 -1
- package/dist/astro.d.ts +4 -1
- package/dist/astro.js +3 -3
- package/dist/{chunk-PYID3NKT.js → chunk-5CV2NNIR.js} +6 -5
- package/dist/chunk-C3APS65S.cjs +12 -0
- package/dist/{chunk-HG7JY6AQ.cjs → chunk-DD4XJNKQ.cjs} +7 -6
- package/dist/{chunk-RCYXXBJ3.cjs → chunk-ERZWC77E.cjs} +272 -117
- package/dist/{chunk-KW66GUWJ.cjs → chunk-FJ67PPIW.cjs} +4 -4
- package/dist/{chunk-YULFP33E.cjs → chunk-MRHWIMY2.cjs} +2 -2
- package/dist/{chunk-CSJMUAPJ.js → chunk-NHZBSVDJ.js} +3 -3
- package/dist/{chunk-2DWFEC7G.js → chunk-QRE6JMCD.js} +271 -116
- package/dist/{chunk-P647W2BA.js → chunk-UMZ2WNMA.js} +2 -2
- package/dist/{chunk-ISPXQBOL.js → chunk-VJ26HHRE.js} +3 -3
- package/dist/{chunk-CF7B5HOG.cjs → chunk-XMYY4XUM.cjs} +4 -4
- package/dist/{chunk-BH4JSKPK.js → chunk-Z3HPP53Q.js} +3 -3
- package/dist/{context-BjOICcQB.d.cts → context-CDZY3RHt.d.cts} +80 -21
- package/dist/{context-BqTYt9FC.d.ts → context-CcPf9RC_.d.ts} +80 -21
- package/dist/esbuild.cjs +6 -6
- package/dist/esbuild.d.cts +4 -1
- package/dist/esbuild.d.ts +4 -1
- package/dist/esbuild.js +3 -3
- package/dist/farm.cjs +3 -3
- package/dist/farm.d.cts +4 -1
- package/dist/farm.d.ts +4 -1
- package/dist/farm.js +2 -2
- package/dist/index.cjs +18 -18
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +10 -7
- package/dist/lib/{api-_rRpguWX.d.cts → api-BIHEKpyq.d.ts} +2 -2
- package/dist/lib/{api-Cxmk8sFc.d.ts → api-Wawenasn.d.cts} +2 -2
- package/dist/lib/build/esbuild.cjs +6 -5
- package/dist/lib/build/esbuild.d.cts +4 -1
- package/dist/lib/build/esbuild.d.ts +4 -1
- package/dist/lib/build/esbuild.js +3 -2
- package/dist/lib/build/index.cjs +13 -12
- package/dist/lib/build/index.d.cts +6 -3
- package/dist/lib/build/index.d.ts +6 -3
- package/dist/lib/build/index.js +5 -4
- package/dist/lib/build/rolldown.d.cts +4 -1
- package/dist/lib/build/rolldown.d.ts +4 -1
- package/dist/lib/build/rollup.d.cts +4 -1
- package/dist/lib/build/rollup.d.ts +4 -1
- package/dist/lib/build/rspack.d.cts +4 -1
- package/dist/lib/build/rspack.d.ts +4 -1
- package/dist/lib/build/tsup.cjs +7 -6
- package/dist/lib/build/tsup.d.cts +4 -1
- package/dist/lib/build/tsup.d.ts +4 -1
- package/dist/lib/build/tsup.js +4 -3
- package/dist/lib/build/unbuild.d.cts +6 -3
- package/dist/lib/build/unbuild.d.ts +6 -3
- package/dist/lib/build/vite.cjs +6 -5
- package/dist/lib/build/vite.d.cts +4 -1
- package/dist/lib/build/vite.d.ts +4 -1
- package/dist/lib/build/vite.js +4 -3
- package/dist/lib/build/webpack.d.cts +4 -1
- package/dist/lib/build/webpack.d.ts +4 -1
- package/dist/lib/{chunk-UNUP4XMO.cjs → chunk-3Y4F37CB.cjs} +2 -2
- package/dist/lib/{chunk-Q4D2L67H.cjs → chunk-7VRXU4F7.cjs} +2 -2
- package/dist/lib/{chunk-N5YLKWC2.js → chunk-DYGQQI74.js} +2 -10
- package/dist/lib/{chunk-HM52GHX3.js → chunk-GD7KTLPU.js} +2 -2
- package/dist/lib/{chunk-CU23POMD.js → chunk-GLWPZDAR.js} +1 -1
- package/dist/lib/{chunk-HE6HOGLS.js → chunk-GSGF6RL2.js} +154 -26
- package/dist/lib/{chunk-4SULM54S.js → chunk-KG4HFVJU.js} +55 -44
- package/dist/lib/{chunk-ZDBHX3VV.cjs → chunk-LBR46BPB.cjs} +72 -35
- package/dist/lib/{chunk-YB54H3SQ.js → chunk-N22WOZ3U.js} +3 -1
- package/dist/lib/{chunk-QR2N3DPP.js → chunk-NZ6NCXM2.js} +1 -1
- package/dist/lib/{chunk-AFLI3CLM.js → chunk-OKXWWMEF.js} +1 -1
- package/dist/lib/{chunk-R3E56AJ4.cjs → chunk-OYLWPIBP.cjs} +2 -2
- package/dist/lib/{chunk-I76RI47U.cjs → chunk-PURLNHXG.cjs} +3 -1
- package/dist/lib/{chunk-N5XEKCVW.cjs → chunk-QF3UTBJE.cjs} +2 -11
- package/dist/lib/{chunk-QDRITYHV.cjs → chunk-R3XAVNPY.cjs} +2 -2
- package/dist/lib/{chunk-Z5JKSYRP.cjs → chunk-S4OH7KW6.cjs} +165 -37
- package/dist/lib/{chunk-YGSXCTX2.js → chunk-S6WYOXLM.js} +1 -1
- package/dist/lib/chunk-T35JQHYE.js +12 -0
- package/dist/lib/{chunk-GKCWJVF7.cjs → chunk-TWABN364.cjs} +10 -10
- package/dist/lib/{chunk-UJYCAW2D.cjs → chunk-V2523R33.cjs} +4 -4
- package/dist/lib/{chunk-KJDASLW3.js → chunk-VKFXVPY6.js} +1 -1
- package/dist/lib/{chunk-AJDYMANR.cjs → chunk-XBSGDSV3.cjs} +2 -2
- package/dist/lib/{chunk-7GCAHOJK.js → chunk-XIK3Y6BP.js} +1 -1
- package/dist/lib/{chunk-CP77I6WM.js → chunk-Y2DPOC4G.js} +65 -28
- package/dist/lib/chunk-YXJJCE6V.cjs +14 -0
- package/dist/lib/{chunk-4V5OI73E.cjs → chunk-Z6BSDYUR.cjs} +55 -44
- package/dist/lib/{config-DMXVnKGF.d.cts → config-D2dTFLlQ.d.cts} +76 -6
- package/dist/lib/{config-B2q8Me0M.d.ts → config-Dzk6j2mr.d.ts} +76 -6
- package/dist/lib/config-file.d.cts +4 -1
- package/dist/lib/config-file.d.ts +4 -1
- package/dist/lib/contexts/api-context.cjs +7 -6
- package/dist/lib/contexts/api-context.d.cts +7 -3
- package/dist/lib/contexts/api-context.d.ts +7 -3
- package/dist/lib/contexts/api-context.js +6 -5
- package/dist/lib/contexts/context.cjs +5 -4
- package/dist/lib/contexts/context.d.cts +64 -10
- package/dist/lib/contexts/context.d.ts +64 -10
- package/dist/lib/contexts/context.js +4 -3
- package/dist/lib/contexts/environment-context.cjs +6 -5
- package/dist/lib/contexts/environment-context.d.cts +7 -3
- package/dist/lib/contexts/environment-context.d.ts +7 -3
- package/dist/lib/contexts/environment-context.js +5 -4
- package/dist/lib/contexts/index.cjs +9 -8
- package/dist/lib/contexts/index.d.cts +7 -3
- package/dist/lib/contexts/index.d.ts +7 -3
- package/dist/lib/contexts/index.js +6 -5
- package/dist/lib/contexts/plugin-context.d.cts +6 -3
- package/dist/lib/contexts/plugin-context.d.ts +6 -3
- package/dist/lib/entry.cjs +10 -9
- package/dist/lib/entry.d.cts +4 -1
- package/dist/lib/entry.d.ts +4 -1
- package/dist/lib/entry.js +2 -1
- package/dist/lib/fs/index.cjs +3 -2
- package/dist/lib/fs/index.d.cts +4 -1
- package/dist/lib/fs/index.d.ts +4 -1
- package/dist/lib/fs/index.js +2 -1
- package/dist/lib/fs/vfs.cjs +3 -2
- package/dist/lib/fs/vfs.d.cts +4 -1
- package/dist/lib/fs/vfs.d.ts +4 -1
- package/dist/lib/fs/vfs.js +2 -1
- package/dist/lib/index.cjs +32 -31
- package/dist/lib/index.d.cts +8 -5
- package/dist/lib/index.d.ts +8 -5
- package/dist/lib/index.js +12 -11
- package/dist/lib/{internal-CGIi3MOX.d.ts → internal-Cgp0NF-t.d.ts} +2 -2
- package/dist/lib/{internal-CfIJWv8T.d.cts → internal-DC9vYMIn.d.cts} +2 -2
- package/dist/lib/logger.d.cts +4 -1
- package/dist/lib/logger.d.ts +4 -1
- package/dist/lib/typescript/import-transformer.d.cts +4 -1
- package/dist/lib/typescript/import-transformer.d.ts +4 -1
- package/dist/lib/typescript/index.d.cts +4 -1
- package/dist/lib/typescript/index.d.ts +4 -1
- package/dist/lib/typescript/ts-morph.d.cts +4 -1
- package/dist/lib/typescript/ts-morph.d.ts +4 -1
- package/dist/lib/unplugin/factory.cjs +8 -8
- package/dist/lib/unplugin/factory.d.cts +6 -3
- package/dist/lib/unplugin/factory.d.ts +6 -3
- package/dist/lib/unplugin/factory.js +7 -7
- package/dist/lib/unplugin/helpers.d.cts +4 -1
- package/dist/lib/unplugin/helpers.d.ts +4 -1
- package/dist/lib/unplugin/index.cjs +10 -10
- package/dist/lib/unplugin/index.d.cts +7 -4
- package/dist/lib/unplugin/index.d.ts +7 -4
- package/dist/lib/unplugin/index.js +8 -8
- package/dist/lib/unplugin/plugin.cjs +2 -2
- package/dist/lib/unplugin/plugin.d.cts +8 -18
- package/dist/lib/unplugin/plugin.d.ts +8 -18
- package/dist/lib/unplugin/plugin.js +1 -1
- package/dist/lib/{unplugin-B_F1TZK4.d.cts → unplugin-CvYjC7ZL.d.cts} +2 -2
- package/dist/lib/{unplugin-Da9GAj4a.d.ts → unplugin-D7lpyIpN.d.ts} +2 -2
- package/dist/lib/utilities/bundle.cjs +5 -4
- package/dist/lib/utilities/bundle.d.cts +4 -1
- package/dist/lib/utilities/bundle.d.ts +4 -1
- package/dist/lib/utilities/bundle.js +4 -3
- package/dist/lib/utilities/cache.d.cts +4 -1
- package/dist/lib/utilities/cache.d.ts +4 -1
- package/dist/lib/utilities/file-header.d.cts +4 -1
- package/dist/lib/utilities/file-header.d.ts +4 -1
- package/dist/lib/utilities/index.cjs +12 -11
- package/dist/lib/utilities/index.d.cts +4 -1
- package/dist/lib/utilities/index.d.ts +4 -1
- package/dist/lib/utilities/index.js +6 -5
- package/dist/lib/utilities/meta.d.cts +4 -1
- package/dist/lib/utilities/meta.d.ts +4 -1
- package/dist/lib/utilities/resolve.cjs +6 -5
- package/dist/lib/utilities/resolve.d.cts +4 -1
- package/dist/lib/utilities/resolve.d.ts +4 -1
- package/dist/lib/utilities/resolve.js +5 -4
- package/dist/lib/utilities/source-file.d.cts +4 -1
- package/dist/lib/utilities/source-file.d.ts +4 -1
- package/dist/lib/utilities/source-map.d.cts +4 -1
- package/dist/lib/utilities/source-map.d.ts +4 -1
- package/dist/lib/utilities/worker.d.cts +4 -1
- package/dist/lib/utilities/worker.d.ts +4 -1
- package/dist/lib/utilities/write-file.d.cts +4 -1
- package/dist/lib/utilities/write-file.d.ts +4 -1
- package/dist/next.cjs +4 -4
- package/dist/next.js +3 -3
- package/dist/nuxt.cjs +6 -6
- package/dist/nuxt.js +4 -4
- package/dist/plugin-utils/chunk-DCJAIIJ5.cjs +14 -0
- package/dist/plugin-utils/chunk-FBLNGP3S.js +12 -0
- package/dist/plugin-utils/context-helpers.d.cts +4 -1
- package/dist/plugin-utils/context-helpers.d.ts +4 -1
- package/dist/plugin-utils/{context-y3G_SQPM.d.cts → context-iOcgJtAf.d.cts} +75 -5
- package/dist/plugin-utils/{context-y3G_SQPM.d.ts → context-iOcgJtAf.d.ts} +75 -5
- package/dist/plugin-utils/enforce.d.cts +4 -1
- package/dist/plugin-utils/enforce.d.ts +4 -1
- package/dist/plugin-utils/extend.d.cts +4 -1
- package/dist/plugin-utils/extend.d.ts +4 -1
- package/dist/plugin-utils/get-config-path.d.cts +4 -1
- package/dist/plugin-utils/get-config-path.d.ts +4 -1
- package/dist/plugin-utils/helpers.d.cts +14 -11
- package/dist/plugin-utils/helpers.d.ts +14 -11
- package/dist/plugin-utils/index.cjs +2 -2
- package/dist/plugin-utils/index.d.cts +4 -1
- package/dist/plugin-utils/index.d.ts +4 -1
- package/dist/plugin-utils/index.js +1 -1
- package/dist/plugin-utils/merge.d.cts +4 -1
- package/dist/plugin-utils/merge.d.ts +4 -1
- package/dist/plugin-utils/paths.cjs +2 -2
- package/dist/plugin-utils/paths.d.cts +5 -1
- package/dist/plugin-utils/paths.d.ts +5 -1
- package/dist/plugin-utils/paths.js +1 -1
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.d.cts +4 -1
- package/dist/rolldown.d.ts +4 -1
- package/dist/rolldown.js +2 -2
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +4 -1
- package/dist/rollup.d.ts +4 -1
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +4 -1
- package/dist/rspack.d.ts +4 -1
- package/dist/rspack.js +2 -2
- package/dist/tsup.cjs +4 -4
- package/dist/tsup.js +3 -3
- package/dist/types/api.d.cts +5 -2
- package/dist/types/api.d.ts +5 -2
- package/dist/types/babel.d.cts +4 -1
- package/dist/types/babel.d.ts +4 -1
- package/dist/types/commands.d.cts +4 -1
- package/dist/types/commands.d.ts +4 -1
- package/dist/types/config.d.cts +4 -1
- package/dist/types/config.d.ts +4 -1
- package/dist/types/context.cjs +2 -2
- package/dist/types/context.d.cts +4 -1
- package/dist/types/context.d.ts +4 -1
- package/dist/types/context.js +1 -1
- package/dist/types/hooks.d.cts +4 -1
- package/dist/types/hooks.d.ts +4 -1
- package/dist/types/index.cjs +3 -3
- package/dist/types/index.d.cts +5 -2
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.js +2 -2
- package/dist/types/internal.d.cts +5 -2
- package/dist/types/internal.d.ts +5 -2
- package/dist/types/plugin.d.cts +4 -1
- package/dist/types/plugin.d.ts +4 -1
- package/dist/types/resolved.d.cts +4 -1
- package/dist/types/resolved.d.ts +4 -1
- package/dist/types/unplugin.d.cts +5 -2
- package/dist/types/unplugin.d.ts +5 -2
- package/dist/unloader.cjs +3 -3
- package/dist/unloader.d.cts +4 -1
- package/dist/unloader.d.ts +4 -1
- package/dist/unloader.js +2 -2
- package/dist/unplugin.cjs +8 -6
- package/dist/unplugin.d.cts +7 -17
- package/dist/unplugin.d.ts +7 -17
- package/dist/unplugin.js +6 -4
- package/dist/vite.cjs +6 -6
- package/dist/vite.d.cts +4 -1
- package/dist/vite.d.ts +4 -1
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.d.cts +4 -1
- package/dist/webpack.d.ts +4 -1
- package/dist/webpack.js +3 -3
- package/package.json +24 -21
- package/dist/babel-types.d.ts +0 -292
- package/dist/chunk-GBIIAZH5.cjs +0 -13
- package/dist/chunk-QXHINXRM.js +0 -11
- package/dist/chunk-UWLQNNZE.cjs +0 -12
- package/dist/config.cjs +0 -13
- package/dist/config.d.cts +0 -45
- package/dist/config.d.ts +0 -45
- package/dist/config.js +0 -4
- package/dist/plugin-utils/chunk-K2GWRZPV.js +0 -12
- package/dist/plugin-utils/chunk-VWFJOPKC.cjs +0 -14
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash } from './chunk-OEF6EHQV.js';
|
|
2
|
-
import { VirtualFileSystem } from './chunk-
|
|
2
|
+
import { VirtualFileSystem } from './chunk-KG4HFVJU.js';
|
|
3
3
|
import { createProgram } from './chunk-4W6WV35V.js';
|
|
4
4
|
import { getTsconfigFilePath } from './chunk-ZGMEHSNN.js';
|
|
5
5
|
import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-XBM7FHNK.js';
|
|
6
6
|
import { createLog, extendLog } from './chunk-ENRLU4UR.js';
|
|
7
|
-
import { resolveEntriesSync, getUniqueEntries
|
|
7
|
+
import { resolveEntriesSync, getUniqueEntries } from './chunk-DYGQQI74.js';
|
|
8
|
+
import { replacePathTokens } from './chunk-T35JQHYE.js';
|
|
8
9
|
import { __name } from './chunk-SHUYVCID.js';
|
|
9
10
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
10
11
|
import { toArray } from '@stryke/convert/to-array';
|
|
@@ -17,6 +18,7 @@ import { hashDirectory } from '@stryke/hash/hash-files';
|
|
|
17
18
|
import { murmurhash } from '@stryke/hash/murmurhash';
|
|
18
19
|
import { getUnique } from '@stryke/helpers/get-unique';
|
|
19
20
|
import { omit } from '@stryke/helpers/omit';
|
|
21
|
+
import { fetchRequest } from '@stryke/http/fetch';
|
|
20
22
|
import { StormJSON } from '@stryke/json/storm-json';
|
|
21
23
|
import { appendPath } from '@stryke/path/append';
|
|
22
24
|
import { isAbsolute } from '@stryke/path/is-type';
|
|
@@ -30,6 +32,9 @@ import { isString } from '@stryke/type-checks/is-string';
|
|
|
30
32
|
import { uuid } from '@stryke/unique-id/uuid';
|
|
31
33
|
import { tsconfigPathsToRegExp, match } from 'bundle-require';
|
|
32
34
|
import defu2 from 'defu';
|
|
35
|
+
import { create } from 'flat-cache';
|
|
36
|
+
import { parse } from 'oxc-parser';
|
|
37
|
+
import { Response } from 'undici';
|
|
33
38
|
import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
|
|
34
39
|
import { createJiti } from 'jiti';
|
|
35
40
|
import { isFunction } from '@stryke/type-checks/is-function';
|
|
@@ -145,7 +150,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
145
150
|
#fs;
|
|
146
151
|
#tsconfig;
|
|
147
152
|
#program;
|
|
148
|
-
#
|
|
153
|
+
#parserCache;
|
|
154
|
+
#requestCache;
|
|
149
155
|
#getConfigProps(config = {}) {
|
|
150
156
|
return {
|
|
151
157
|
variant: config.build?.variant,
|
|
@@ -169,7 +175,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
169
175
|
lint: config.lint,
|
|
170
176
|
transform: config.transform,
|
|
171
177
|
build: config.build,
|
|
172
|
-
framework: config.framework
|
|
178
|
+
framework: config.framework,
|
|
179
|
+
...config
|
|
173
180
|
};
|
|
174
181
|
}
|
|
175
182
|
/**
|
|
@@ -217,6 +224,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
217
224
|
*/
|
|
218
225
|
resolver;
|
|
219
226
|
/**
|
|
227
|
+
* The resolved configuration options
|
|
228
|
+
*/
|
|
229
|
+
resolvePatterns = [];
|
|
230
|
+
/**
|
|
220
231
|
* Internal context fields and methods
|
|
221
232
|
*
|
|
222
233
|
* @internal
|
|
@@ -248,7 +259,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
248
259
|
*/
|
|
249
260
|
set tsconfig(value) {
|
|
250
261
|
this.#tsconfig = value;
|
|
251
|
-
this
|
|
262
|
+
this.resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
252
263
|
}
|
|
253
264
|
/**
|
|
254
265
|
* The virtual file system interface for the project
|
|
@@ -389,6 +400,123 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
389
400
|
return this.#program;
|
|
390
401
|
}
|
|
391
402
|
/**
|
|
403
|
+
* Gets the parser cache.
|
|
404
|
+
*/
|
|
405
|
+
get parserCache() {
|
|
406
|
+
if (!this.#parserCache) {
|
|
407
|
+
this.#parserCache = create({
|
|
408
|
+
cacheId: "parser",
|
|
409
|
+
cacheDir: this.cachePath,
|
|
410
|
+
ttl: 2 * 60 * 60 * 1e3,
|
|
411
|
+
lruSize: 5e3,
|
|
412
|
+
persistInterval: 250
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return this.#parserCache;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Gets the request cache.
|
|
419
|
+
*/
|
|
420
|
+
get requestCache() {
|
|
421
|
+
if (!this.#requestCache) {
|
|
422
|
+
this.#requestCache = create({
|
|
423
|
+
cacheId: "http",
|
|
424
|
+
cacheDir: this.cachePath,
|
|
425
|
+
ttl: 5 * 60 * 1e3,
|
|
426
|
+
lruSize: 5e3,
|
|
427
|
+
persistInterval: 250
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
return this.#requestCache;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A function to perform HTTP fetch requests
|
|
434
|
+
*
|
|
435
|
+
* @remarks
|
|
436
|
+
* This function uses a caching layer to avoid duplicate requests during the Powerlines process.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```ts
|
|
440
|
+
* const response = await context.fetch("https://api.example.com/data");
|
|
441
|
+
* const data = await response.json();
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @see https://github.com/nodejs/undici
|
|
445
|
+
*
|
|
446
|
+
* @param input - The URL to fetch.
|
|
447
|
+
* @param options - The fetch request options.
|
|
448
|
+
* @returns A promise that resolves to a response returned by the fetch.
|
|
449
|
+
*/
|
|
450
|
+
async fetch(input, options = {}) {
|
|
451
|
+
const cacheKey = murmurhash({
|
|
452
|
+
input: input.toString(),
|
|
453
|
+
options: JSON.stringify(options)
|
|
454
|
+
});
|
|
455
|
+
if (!this.config.skipCache && !options.skipCache) {
|
|
456
|
+
const cached = this.requestCache.get(cacheKey);
|
|
457
|
+
if (cached) {
|
|
458
|
+
return new Response(cached.body, {
|
|
459
|
+
status: cached.status,
|
|
460
|
+
statusText: cached.statusText,
|
|
461
|
+
headers: cached.headers
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const result = await fetchRequest(input, options);
|
|
466
|
+
if (!this.config.skipCache && !options.skipCache) {
|
|
467
|
+
try {
|
|
468
|
+
this.requestCache.set(cacheKey, {
|
|
469
|
+
body: await result.text(),
|
|
470
|
+
status: result.status,
|
|
471
|
+
statusText: result.statusText,
|
|
472
|
+
headers: Object.fromEntries(result.headers.entries())
|
|
473
|
+
});
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return result;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
481
|
+
*
|
|
482
|
+
* @remarks
|
|
483
|
+
* This function can be used to parse TypeScript code into an AST for further analysis or transformation.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```ts
|
|
487
|
+
* const ast = context.parse("const x: number = 42;");
|
|
488
|
+
* ```
|
|
489
|
+
*
|
|
490
|
+
* @see https://rollupjs.org/plugin-development/#this-parse
|
|
491
|
+
* @see https://github.com/oxc/oxc
|
|
492
|
+
*
|
|
493
|
+
* @param code - The source code to parse.
|
|
494
|
+
* @param options - The options to pass to the parser.
|
|
495
|
+
* @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
|
|
496
|
+
*/
|
|
497
|
+
async parse(code, options = {}) {
|
|
498
|
+
const cacheKey = murmurhash({
|
|
499
|
+
code,
|
|
500
|
+
options
|
|
501
|
+
});
|
|
502
|
+
let result;
|
|
503
|
+
if (!this.config.skipCache) {
|
|
504
|
+
result = this.parserCache.get(cacheKey);
|
|
505
|
+
if (result) {
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
result = await parse(`source.${options.lang || "ts"}`, code, {
|
|
510
|
+
...options,
|
|
511
|
+
sourceType: "module",
|
|
512
|
+
showSemanticErrors: this.config.mode === "development"
|
|
513
|
+
});
|
|
514
|
+
if (!this.config.skipCache) {
|
|
515
|
+
this.parserCache.set(cacheKey, result);
|
|
516
|
+
}
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
392
520
|
* A helper function to resolve modules in the Virtual File System
|
|
393
521
|
*
|
|
394
522
|
* @remarks
|
|
@@ -433,7 +561,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
433
561
|
};
|
|
434
562
|
}
|
|
435
563
|
if (this.config.build.skipNodeModulesBundle) {
|
|
436
|
-
if (match(moduleId, this
|
|
564
|
+
if (match(moduleId, this.resolvePatterns) || match(moduleId, this.config.build.noExternal)) {
|
|
437
565
|
return void 0;
|
|
438
566
|
}
|
|
439
567
|
if (match(moduleId, this.config.build.external) || moduleId.startsWith("node:")) {
|
|
@@ -627,6 +755,26 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
627
755
|
return extendLog(this.log, name);
|
|
628
756
|
}
|
|
629
757
|
/**
|
|
758
|
+
* Generates a checksum representing the current context state
|
|
759
|
+
*
|
|
760
|
+
* @param root - The root directory of the project to generate the checksum for
|
|
761
|
+
* @returns A promise that resolves to a string representing the checksum
|
|
762
|
+
*/
|
|
763
|
+
async generateChecksum(root = this.config.projectRoot) {
|
|
764
|
+
this.#checksum = await hashDirectory(root, {
|
|
765
|
+
ignore: [
|
|
766
|
+
"node_modules",
|
|
767
|
+
".git",
|
|
768
|
+
".nx",
|
|
769
|
+
".cache",
|
|
770
|
+
".storm",
|
|
771
|
+
"tmp",
|
|
772
|
+
"dist"
|
|
773
|
+
]
|
|
774
|
+
});
|
|
775
|
+
return this.#checksum;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
630
778
|
* Creates a new StormContext instance.
|
|
631
779
|
*
|
|
632
780
|
* @param workspaceConfig - The workspace configuration.
|
|
@@ -648,26 +796,6 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
648
796
|
*/
|
|
649
797
|
logFn;
|
|
650
798
|
/**
|
|
651
|
-
* Generates a checksum representing the current context state
|
|
652
|
-
*
|
|
653
|
-
* @param root - The root directory of the project to generate the checksum for
|
|
654
|
-
* @returns A promise that resolves to a string representing the checksum
|
|
655
|
-
*/
|
|
656
|
-
async generateChecksum(root = this.config.projectRoot) {
|
|
657
|
-
this.#checksum = await hashDirectory(root, {
|
|
658
|
-
ignore: [
|
|
659
|
-
"node_modules",
|
|
660
|
-
".git",
|
|
661
|
-
".nx",
|
|
662
|
-
".cache",
|
|
663
|
-
".storm",
|
|
664
|
-
"tmp",
|
|
665
|
-
"dist"
|
|
666
|
-
]
|
|
667
|
-
});
|
|
668
|
-
return this.#checksum;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
799
|
* Initialize the context with the provided configuration options
|
|
672
800
|
*
|
|
673
801
|
* @param config - The partial user configuration to use for initialization.
|
|
@@ -2,6 +2,7 @@ import { FileSystemStorageAdapter } from './chunk-L56XA427.js';
|
|
|
2
2
|
import { VirtualStorageAdapter } from './chunk-ONETLSPO.js';
|
|
3
3
|
import { normalizeId, normalizePath, normalizeKey, filterKeyByBase } from './chunk-KFDNKOXM.js';
|
|
4
4
|
import { extendLog } from './chunk-ENRLU4UR.js';
|
|
5
|
+
import { replacePathTokens } from './chunk-T35JQHYE.js';
|
|
5
6
|
import { __name } from './chunk-SHUYVCID.js';
|
|
6
7
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
7
8
|
import * as $ from '@stryke/capnp';
|
|
@@ -11,7 +12,6 @@ import { existsSync } from '@stryke/fs/exists';
|
|
|
11
12
|
import { getResolutionCombinations, resolve, resolveSync } from '@stryke/fs/resolve';
|
|
12
13
|
import { murmurhash } from '@stryke/hash/murmurhash';
|
|
13
14
|
import { appendPath } from '@stryke/path/append';
|
|
14
|
-
import { toAbsolutePath } from '@stryke/path/correct-path';
|
|
15
15
|
import { hasFileExtension, findFilePath, findFileName } from '@stryke/path/file-path-fns';
|
|
16
16
|
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
17
17
|
import { isAbsolutePath } from '@stryke/path/is-type';
|
|
@@ -302,7 +302,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
302
302
|
* @returns The normalized module id.
|
|
303
303
|
*/
|
|
304
304
|
#normalizeId(id) {
|
|
305
|
-
|
|
305
|
+
let normalized = id;
|
|
306
|
+
if (isParentPath(normalized, this.#context.builtinsPath)) {
|
|
307
|
+
normalized = replacePath(normalized, this.#context.builtinsPath);
|
|
308
|
+
}
|
|
309
|
+
return normalizeId(normalized, this.#context.config.output.builtinPrefix);
|
|
306
310
|
}
|
|
307
311
|
/**
|
|
308
312
|
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
@@ -311,7 +315,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
311
315
|
* @returns The normalized path.
|
|
312
316
|
*/
|
|
313
317
|
#normalizePath(path) {
|
|
314
|
-
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
318
|
+
return normalizePath(path.includes("{") || path.includes("}") ? replacePathTokens(this.#context, path) : path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
315
319
|
}
|
|
316
320
|
/**
|
|
317
321
|
* Builds a regular expression from a string pattern for path matching.
|
|
@@ -816,15 +820,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
816
820
|
}
|
|
817
821
|
}
|
|
818
822
|
const { relativeKey, adapter } = this.#getStorage(path);
|
|
819
|
-
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(
|
|
820
|
-
const id = options?.meta?.id || this.#normalizeId(
|
|
823
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(relativeKey)} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
824
|
+
const id = options?.meta?.id || this.#normalizeId(relativeKey);
|
|
821
825
|
this.#metadata[id] = {
|
|
822
826
|
variant: "normal",
|
|
823
827
|
timestamp: Date.now(),
|
|
824
828
|
...options.meta ?? {}
|
|
825
829
|
};
|
|
826
|
-
this.#paths[id] = this.#normalizePath(
|
|
827
|
-
this.#ids[this.#normalizePath(
|
|
830
|
+
this.#paths[id] = this.#normalizePath(relativeKey);
|
|
831
|
+
this.#ids[this.#normalizePath(relativeKey)] = id;
|
|
828
832
|
return adapter.set(relativeKey, code);
|
|
829
833
|
}
|
|
830
834
|
/**
|
|
@@ -836,15 +840,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
836
840
|
*/
|
|
837
841
|
writeSync(path, data = "", options = {}) {
|
|
838
842
|
const { relativeKey, adapter } = this.#getStorage(path);
|
|
839
|
-
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(
|
|
840
|
-
const id = options?.meta?.id || this.#normalizeId(
|
|
843
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(relativeKey)} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
|
|
844
|
+
const id = options?.meta?.id || this.#normalizeId(relativeKey);
|
|
841
845
|
this.#metadata[id] = {
|
|
842
846
|
variant: "normal",
|
|
843
847
|
timestamp: Date.now(),
|
|
844
848
|
...options.meta ?? {}
|
|
845
849
|
};
|
|
846
|
-
this.#paths[id] = this.#normalizePath(
|
|
847
|
-
this.#ids[this.#normalizePath(
|
|
850
|
+
this.#paths[id] = this.#normalizePath(relativeKey);
|
|
851
|
+
this.#ids[this.#normalizePath(relativeKey)] = id;
|
|
848
852
|
return adapter.setSync(relativeKey, data);
|
|
849
853
|
}
|
|
850
854
|
/**
|
|
@@ -877,11 +881,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
877
881
|
* @returns A promise that resolves to the resolved module path.
|
|
878
882
|
*/
|
|
879
883
|
async resolve(id, importer, options = {}) {
|
|
880
|
-
|
|
881
|
-
|
|
884
|
+
let path = id;
|
|
885
|
+
if (path.includes("{") || path.includes("}")) {
|
|
886
|
+
path = replacePathTokens(this.#context, path);
|
|
887
|
+
}
|
|
888
|
+
if (isAbsolutePath(path)) {
|
|
889
|
+
return path;
|
|
882
890
|
}
|
|
883
891
|
const resolverCacheKey = murmurhash({
|
|
884
|
-
|
|
892
|
+
path: this.#normalizeId(path),
|
|
885
893
|
importer,
|
|
886
894
|
options
|
|
887
895
|
});
|
|
@@ -892,7 +900,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
892
900
|
return result;
|
|
893
901
|
}
|
|
894
902
|
}
|
|
895
|
-
result = this.paths[this.#normalizeId(
|
|
903
|
+
result = this.paths[this.#normalizeId(path)];
|
|
896
904
|
if (!result) {
|
|
897
905
|
const paths = options.paths ?? [];
|
|
898
906
|
if (importer && !paths.includes(importer)) {
|
|
@@ -901,8 +909,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
901
909
|
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
902
910
|
paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
903
911
|
paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
904
|
-
paths.push(...Object.keys(this.#context.tsconfig
|
|
905
|
-
for (const combination of getResolutionCombinations(
|
|
912
|
+
paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
913
|
+
for (const combination of getResolutionCombinations(path, {
|
|
906
914
|
paths
|
|
907
915
|
})) {
|
|
908
916
|
const { relativeKey, adapter } = this.#getStorage(combination);
|
|
@@ -911,19 +919,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
911
919
|
break;
|
|
912
920
|
}
|
|
913
921
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
922
|
+
if (!result) {
|
|
923
|
+
try {
|
|
924
|
+
result = await resolve(path, {
|
|
925
|
+
...options,
|
|
926
|
+
paths
|
|
927
|
+
});
|
|
928
|
+
} catch {
|
|
929
|
+
}
|
|
920
930
|
}
|
|
921
931
|
}
|
|
922
|
-
if (result) {
|
|
923
|
-
|
|
924
|
-
if (!this.#context.config.skipCache) {
|
|
925
|
-
this.resolverCache.set(resolverCacheKey, result);
|
|
926
|
-
}
|
|
932
|
+
if (result && !this.#context.config.skipCache) {
|
|
933
|
+
this.resolverCache.set(resolverCacheKey, result);
|
|
927
934
|
}
|
|
928
935
|
return result;
|
|
929
936
|
}
|
|
@@ -944,17 +951,21 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
944
951
|
* @returns The resolved module path.
|
|
945
952
|
*/
|
|
946
953
|
resolveSync(id, importer, options = {}) {
|
|
947
|
-
|
|
948
|
-
|
|
954
|
+
let path = id;
|
|
955
|
+
if (path.includes("{") || path.includes("}")) {
|
|
956
|
+
path = replacePathTokens(this.#context, path);
|
|
957
|
+
}
|
|
958
|
+
if (isAbsolutePath(path)) {
|
|
959
|
+
return path;
|
|
949
960
|
}
|
|
950
961
|
let result;
|
|
951
962
|
if (!this.#context.config.skipCache) {
|
|
952
|
-
result = this.resolverCache.get(this.#normalizeId(
|
|
963
|
+
result = this.resolverCache.get(this.#normalizeId(path));
|
|
953
964
|
if (result) {
|
|
954
965
|
return result;
|
|
955
966
|
}
|
|
956
967
|
}
|
|
957
|
-
result = this.paths[this.#normalizeId(
|
|
968
|
+
result = this.paths[this.#normalizeId(path)];
|
|
958
969
|
if (!result) {
|
|
959
970
|
const paths = options.paths ?? [];
|
|
960
971
|
if (importer && !paths.includes(importer)) {
|
|
@@ -963,8 +974,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
963
974
|
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
964
975
|
paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
965
976
|
paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
966
|
-
paths.push(...Object.keys(this.#context.tsconfig
|
|
967
|
-
for (const combination of getResolutionCombinations(
|
|
977
|
+
paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
978
|
+
for (const combination of getResolutionCombinations(path, {
|
|
968
979
|
paths
|
|
969
980
|
})) {
|
|
970
981
|
const { relativeKey, adapter } = this.#getStorage(combination);
|
|
@@ -973,18 +984,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
973
984
|
break;
|
|
974
985
|
}
|
|
975
986
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
987
|
+
if (!result) {
|
|
988
|
+
try {
|
|
989
|
+
result = resolveSync(path, {
|
|
990
|
+
...options,
|
|
991
|
+
paths
|
|
992
|
+
});
|
|
993
|
+
} catch {
|
|
994
|
+
}
|
|
981
995
|
}
|
|
982
996
|
}
|
|
983
|
-
if (result) {
|
|
984
|
-
|
|
985
|
-
if (!this.#context.config.skipCache) {
|
|
986
|
-
this.resolverCache.set(this.#normalizeId(id), result);
|
|
987
|
-
}
|
|
997
|
+
if (result && !this.#context.config.skipCache) {
|
|
998
|
+
this.resolverCache.set(this.#normalizeId(path), result);
|
|
988
999
|
}
|
|
989
1000
|
return result;
|
|
990
1001
|
}
|