@powerlines/plugin-babel 0.12.35 → 0.12.37
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/helpers/create-plugin.d.cts +4 -1
- package/dist/helpers/create-plugin.d.ts +4 -1
- package/dist/helpers/filters.d.cts +4 -1
- package/dist/helpers/filters.d.ts +4 -1
- package/dist/helpers/index.d.cts +4 -1
- package/dist/helpers/index.d.ts +4 -1
- package/dist/helpers/module-helpers.d.cts +4 -1
- package/dist/helpers/module-helpers.d.ts +4 -1
- package/dist/helpers/options.d.cts +4 -1
- package/dist/helpers/options.d.ts +4 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/{plugin-BbZeyWyU.d.cts → plugin-DYbsUN3U.d.cts} +118 -39
- package/dist/{plugin-BbZeyWyU.d.ts → plugin-DYbsUN3U.d.ts} +118 -39
- package/dist/types/index.d.cts +4 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/plugin.d.cts +4 -1
- package/dist/types/plugin.d.ts +4 -1
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-
|
|
1
|
+
import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-DYbsUN3U.cjs';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-
|
|
1
|
+
import { C as Context, c as BabelTransformPluginBuilder, D as DeclareBabelTransformPluginReturn } from '../plugin-DYbsUN3U.js';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-
|
|
1
|
+
import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-DYbsUN3U.cjs';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-
|
|
1
|
+
import { B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions, C as Context, a as BabelTransformPluginFilter, b as BabelTransformPlugin } from '../plugin-DYbsUN3U.js';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ export { resolveBabelPlugin, resolvePluginFunction } from './options.cjs';
|
|
|
6
6
|
export { GeneratorResult } from '@babel/generator';
|
|
7
7
|
import '@babel/parser';
|
|
8
8
|
import '@babel/types';
|
|
9
|
-
import '../plugin-
|
|
9
|
+
import '../plugin-DYbsUN3U.cjs';
|
|
10
10
|
import '@stryke/types/base';
|
|
11
11
|
import 'unplugin';
|
|
12
12
|
import '@stryke/types/array';
|
|
@@ -21,7 +21,10 @@ import '@babel/helper-plugin-utils';
|
|
|
21
21
|
import '@stryke/env/get-env-paths';
|
|
22
22
|
import '@stryke/types/package-json';
|
|
23
23
|
import 'jiti';
|
|
24
|
+
import 'magic-string';
|
|
24
25
|
import 'semver';
|
|
26
|
+
import 'ts-morph';
|
|
27
|
+
import '@stryke/fs/resolve';
|
|
25
28
|
import 'node:fs';
|
|
26
29
|
import '@stryke/types/tsconfig';
|
|
27
30
|
import 'typescript';
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { resolveBabelPlugin, resolvePluginFunction } from './options.js';
|
|
|
6
6
|
export { GeneratorResult } from '@babel/generator';
|
|
7
7
|
import '@babel/parser';
|
|
8
8
|
import '@babel/types';
|
|
9
|
-
import '../plugin-
|
|
9
|
+
import '../plugin-DYbsUN3U.js';
|
|
10
10
|
import '@stryke/types/base';
|
|
11
11
|
import 'unplugin';
|
|
12
12
|
import '@stryke/types/array';
|
|
@@ -21,7 +21,10 @@ import '@babel/helper-plugin-utils';
|
|
|
21
21
|
import '@stryke/env/get-env-paths';
|
|
22
22
|
import '@stryke/types/package-json';
|
|
23
23
|
import 'jiti';
|
|
24
|
+
import 'magic-string';
|
|
24
25
|
import 'semver';
|
|
26
|
+
import 'ts-morph';
|
|
27
|
+
import '@stryke/fs/resolve';
|
|
25
28
|
import 'node:fs';
|
|
26
29
|
import '@stryke/types/tsconfig';
|
|
27
30
|
import 'typescript';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodePath } from '@babel/core';
|
|
2
2
|
import { ParseResult } from '@babel/parser';
|
|
3
3
|
import * as t from '@babel/types';
|
|
4
|
-
import { I as ImportSpecifier } from '../plugin-
|
|
4
|
+
import { I as ImportSpecifier } from '../plugin-DYbsUN3U.cjs';
|
|
5
5
|
import '@stryke/types/base';
|
|
6
6
|
import 'unplugin';
|
|
7
7
|
import '@stryke/types/array';
|
|
@@ -15,7 +15,10 @@ import '@babel/helper-plugin-utils';
|
|
|
15
15
|
import '@stryke/env/get-env-paths';
|
|
16
16
|
import '@stryke/types/package-json';
|
|
17
17
|
import 'jiti';
|
|
18
|
+
import 'magic-string';
|
|
18
19
|
import 'semver';
|
|
20
|
+
import 'ts-morph';
|
|
21
|
+
import '@stryke/fs/resolve';
|
|
19
22
|
import 'node:fs';
|
|
20
23
|
import '@stryke/types/tsconfig';
|
|
21
24
|
import 'typescript';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodePath } from '@babel/core';
|
|
2
2
|
import { ParseResult } from '@babel/parser';
|
|
3
3
|
import * as t from '@babel/types';
|
|
4
|
-
import { I as ImportSpecifier } from '../plugin-
|
|
4
|
+
import { I as ImportSpecifier } from '../plugin-DYbsUN3U.js';
|
|
5
5
|
import '@stryke/types/base';
|
|
6
6
|
import 'unplugin';
|
|
7
7
|
import '@stryke/types/array';
|
|
@@ -15,7 +15,10 @@ import '@babel/helper-plugin-utils';
|
|
|
15
15
|
import '@stryke/env/get-env-paths';
|
|
16
16
|
import '@stryke/types/package-json';
|
|
17
17
|
import 'jiti';
|
|
18
|
+
import 'magic-string';
|
|
18
19
|
import 'semver';
|
|
20
|
+
import 'ts-morph';
|
|
21
|
+
import '@stryke/fs/resolve';
|
|
19
22
|
import 'node:fs';
|
|
20
23
|
import '@stryke/types/tsconfig';
|
|
21
24
|
import 'typescript';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginTarget, PluginOptions } from '@babel/core';
|
|
2
|
-
import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-
|
|
2
|
+
import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-DYbsUN3U.cjs';
|
|
3
3
|
import '@stryke/types/base';
|
|
4
4
|
import 'unplugin';
|
|
5
5
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginTarget, PluginOptions } from '@babel/core';
|
|
2
|
-
import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-
|
|
2
|
+
import { C as Context, B as BabelTransformPluginOptions, R as ResolvedBabelTransformPluginOptions } from '../plugin-DYbsUN3U.js';
|
|
3
3
|
import '@stryke/types/base';
|
|
4
4
|
import 'unplugin';
|
|
5
5
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from './plugin-
|
|
1
|
+
import { P as Plugin } from './plugin-DYbsUN3U.cjs';
|
|
2
2
|
import { BabelPluginOptions, BabelPluginContext } from './types/plugin.cjs';
|
|
3
3
|
export { BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from './types/plugin.cjs';
|
|
4
4
|
export { GenerateFromAstOptions, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from './helpers/ast-utils.cjs';
|
|
@@ -21,7 +21,10 @@ import '@babel/helper-plugin-utils';
|
|
|
21
21
|
import '@stryke/env/get-env-paths';
|
|
22
22
|
import '@stryke/types/package-json';
|
|
23
23
|
import 'jiti';
|
|
24
|
+
import 'magic-string';
|
|
24
25
|
import 'semver';
|
|
26
|
+
import 'ts-morph';
|
|
27
|
+
import '@stryke/fs/resolve';
|
|
25
28
|
import 'node:fs';
|
|
26
29
|
import '@stryke/types/tsconfig';
|
|
27
30
|
import 'typescript';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from './plugin-
|
|
1
|
+
import { P as Plugin } from './plugin-DYbsUN3U.js';
|
|
2
2
|
import { BabelPluginOptions, BabelPluginContext } from './types/plugin.js';
|
|
3
3
|
export { BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from './types/plugin.js';
|
|
4
4
|
export { GenerateFromAstOptions, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from './helpers/ast-utils.js';
|
|
@@ -21,7 +21,10 @@ import '@babel/helper-plugin-utils';
|
|
|
21
21
|
import '@stryke/env/get-env-paths';
|
|
22
22
|
import '@stryke/types/package-json';
|
|
23
23
|
import 'jiti';
|
|
24
|
+
import 'magic-string';
|
|
24
25
|
import 'semver';
|
|
26
|
+
import 'ts-morph';
|
|
27
|
+
import '@stryke/fs/resolve';
|
|
25
28
|
import 'node:fs';
|
|
26
29
|
import '@stryke/types/tsconfig';
|
|
27
30
|
import 'typescript';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaybePromise, NonUndefined, FunctionLike } from '@stryke/types/base';
|
|
2
|
-
import { UnpluginContext, UnpluginMessage, UnpluginBuildContext, TransformResult
|
|
2
|
+
import { UnpluginContext, UnpluginMessage, ExternalIdResult, UnpluginBuildContext, TransformResult as TransformResult$1, HookFilter, UnpluginOptions } from 'unplugin';
|
|
3
3
|
import { ArrayValues } from '@stryke/types/array';
|
|
4
4
|
import { PluginItem, PluginObj, PluginPass, transformAsync } from '@babel/core';
|
|
5
5
|
import { Format } from '@storm-software/build-tools/types';
|
|
@@ -12,8 +12,11 @@ import { BabelAPI } from '@babel/helper-plugin-utils';
|
|
|
12
12
|
import { EnvPaths } from '@stryke/env/get-env-paths';
|
|
13
13
|
import { PackageJson } from '@stryke/types/package-json';
|
|
14
14
|
import { Jiti } from 'jiti';
|
|
15
|
+
import { SourceMap } from 'magic-string';
|
|
15
16
|
import { Range } from 'semver';
|
|
16
|
-
import {
|
|
17
|
+
import { Project } from 'ts-morph';
|
|
18
|
+
import { ResolveOptions as ResolveOptions$1 } from '@stryke/fs/resolve';
|
|
19
|
+
import { StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
|
|
17
20
|
import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
|
|
18
21
|
import ts from 'typescript';
|
|
19
22
|
|
|
@@ -290,21 +293,27 @@ interface PowerlinesWriteFileOptions extends ResolveFSOptions {
|
|
|
290
293
|
type NodeWriteFileOptions = WriteFileOptions$1;
|
|
291
294
|
type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
|
|
292
295
|
type WriteFileData = string | NodeJS.ArrayBufferView | VirtualFileData;
|
|
293
|
-
interface
|
|
296
|
+
interface ResolveOptions extends ResolveOptions$1 {
|
|
294
297
|
/**
|
|
295
|
-
*
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
* If true, the module is being resolved as an entry point.
|
|
299
|
+
*/
|
|
300
|
+
isEntry?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* If true, the resolver will skip using the cache when resolving modules.
|
|
303
|
+
*/
|
|
304
|
+
skipCache?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* An array of external modules or patterns to exclude from resolution.
|
|
298
307
|
*/
|
|
299
|
-
|
|
308
|
+
external?: (string | RegExp)[];
|
|
300
309
|
/**
|
|
301
|
-
*
|
|
310
|
+
* An array of modules or patterns to include in the resolution, even if they are marked as external.
|
|
302
311
|
*/
|
|
303
|
-
|
|
312
|
+
noExternal?: (string | RegExp)[];
|
|
304
313
|
/**
|
|
305
|
-
*
|
|
314
|
+
* An array of patterns to match when resolving modules.
|
|
306
315
|
*/
|
|
307
|
-
|
|
316
|
+
skipNodeModulesBundle?: boolean;
|
|
308
317
|
}
|
|
309
318
|
interface VirtualFileSystemInterface {
|
|
310
319
|
/**
|
|
@@ -318,27 +327,33 @@ interface VirtualFileSystemInterface {
|
|
|
318
327
|
/**
|
|
319
328
|
* The underlying file metadata.
|
|
320
329
|
*/
|
|
321
|
-
metadata: Record<string, VirtualFileMetadata
|
|
330
|
+
metadata: Readonly<Record<string, VirtualFileMetadata>>;
|
|
331
|
+
/**
|
|
332
|
+
* A map of file paths to their module ids.
|
|
333
|
+
*/
|
|
334
|
+
ids: Readonly<Record<string, string>>;
|
|
322
335
|
/**
|
|
323
336
|
* A map of module ids to their file paths.
|
|
324
337
|
*/
|
|
325
|
-
|
|
338
|
+
paths: Readonly<Record<string, string>>;
|
|
326
339
|
/**
|
|
327
340
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
328
341
|
*
|
|
329
342
|
* @param pathOrId - The path or id to check.
|
|
343
|
+
* @param importer - The importer path, if any.
|
|
330
344
|
* @param options - Optional parameters for resolving the path.
|
|
331
345
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
332
346
|
*/
|
|
333
|
-
isVirtual: (pathOrId: string, options?:
|
|
347
|
+
isVirtual: (pathOrId: string, importer?: string, options?: ResolveOptions) => boolean;
|
|
334
348
|
/**
|
|
335
349
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
336
350
|
*
|
|
337
351
|
* @param pathOrId - The path or id to check.
|
|
352
|
+
* @param importer - The importer path, if any.
|
|
338
353
|
* @param options - Optional parameters for resolving the path.
|
|
339
354
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
340
355
|
*/
|
|
341
|
-
isPhysical: (pathOrId: string, options?:
|
|
356
|
+
isPhysical: (pathOrId: string, importer?: string, options?: ResolveOptions) => boolean;
|
|
342
357
|
/**
|
|
343
358
|
* Checks if a file exists in the virtual file system (VFS).
|
|
344
359
|
*
|
|
@@ -366,7 +381,7 @@ interface VirtualFileSystemInterface {
|
|
|
366
381
|
* @param pathOrId - The path or id of the file.
|
|
367
382
|
* @returns The metadata of the file if it exists, otherwise undefined.
|
|
368
383
|
*/
|
|
369
|
-
getMetadata: (pathOrId:
|
|
384
|
+
getMetadata: (pathOrId: string) => VirtualFileMetadata | undefined;
|
|
370
385
|
/**
|
|
371
386
|
* Gets the stats of a file in the virtual file system (VFS).
|
|
372
387
|
*
|
|
@@ -439,7 +454,7 @@ interface VirtualFileSystemInterface {
|
|
|
439
454
|
* @param path - The path to the file to remove.
|
|
440
455
|
* @returns A promise that resolves when the file is removed.
|
|
441
456
|
*/
|
|
442
|
-
unlinkSync: (path:
|
|
457
|
+
unlinkSync: (path: string, options?: ResolveFSOptions) => void;
|
|
443
458
|
/**
|
|
444
459
|
* Asynchronously removes a file or symbolic link in the virtual file system (VFS).
|
|
445
460
|
*
|
|
@@ -453,7 +468,7 @@ interface VirtualFileSystemInterface {
|
|
|
453
468
|
* @param path - The path to create the directory at.
|
|
454
469
|
* @param options - Options for creating the directory.
|
|
455
470
|
*/
|
|
456
|
-
rmdirSync: (path:
|
|
471
|
+
rmdirSync: (path: string, options?: RmDirOptions & ResolveFSOptions) => any;
|
|
457
472
|
/**
|
|
458
473
|
* Removes a directory in the virtual file system (VFS).
|
|
459
474
|
*
|
|
@@ -461,7 +476,7 @@ interface VirtualFileSystemInterface {
|
|
|
461
476
|
* @param options - Options for creating the directory.
|
|
462
477
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
463
478
|
*/
|
|
464
|
-
rmdir: (path:
|
|
479
|
+
rmdir: (path: string, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
|
|
465
480
|
/**
|
|
466
481
|
* Removes a file or directory in the virtual file system (VFS).
|
|
467
482
|
*
|
|
@@ -469,14 +484,14 @@ interface VirtualFileSystemInterface {
|
|
|
469
484
|
* @param options - Options for removing the file or directory.
|
|
470
485
|
* @returns A promise that resolves when the file or directory is removed.
|
|
471
486
|
*/
|
|
472
|
-
rm: (path:
|
|
487
|
+
rm: (path: string, options?: RmOptions & ResolveFSOptions) => Promise<void>;
|
|
473
488
|
/**
|
|
474
489
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
475
490
|
*
|
|
476
491
|
* @param path - The path to the file or directory to remove.
|
|
477
492
|
* @param options - Options for removing the file or directory.
|
|
478
493
|
*/
|
|
479
|
-
rmSync: (path:
|
|
494
|
+
rmSync: (path: string, options?: RmOptions & ResolveFSOptions) => void;
|
|
480
495
|
/**
|
|
481
496
|
* Creates a directory in the virtual file system (VFS).
|
|
482
497
|
*
|
|
@@ -484,7 +499,7 @@ interface VirtualFileSystemInterface {
|
|
|
484
499
|
* @param options - Options for creating the directory.
|
|
485
500
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
486
501
|
*/
|
|
487
|
-
mkdirSync: (path:
|
|
502
|
+
mkdirSync: (path: string, options?: MakeDirectoryOptions) => string | undefined;
|
|
488
503
|
/**
|
|
489
504
|
* Creates a directory in the virtual file system (VFS).
|
|
490
505
|
*
|
|
@@ -492,7 +507,7 @@ interface VirtualFileSystemInterface {
|
|
|
492
507
|
* @param options - Options for creating the directory.
|
|
493
508
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
494
509
|
*/
|
|
495
|
-
mkdir: (path:
|
|
510
|
+
mkdir: (path: string, options?: MakeDirectoryOptions) => Promise<string | undefined>;
|
|
496
511
|
/**
|
|
497
512
|
* Reads a file from the virtual file system (VFS).
|
|
498
513
|
*
|
|
@@ -514,7 +529,7 @@ interface VirtualFileSystemInterface {
|
|
|
514
529
|
* @param options - Optional parameters for writing the file.
|
|
515
530
|
* @returns A promise that resolves when the file is written.
|
|
516
531
|
*/
|
|
517
|
-
writeFile: (path:
|
|
532
|
+
writeFile: (path: string, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
|
|
518
533
|
/**
|
|
519
534
|
* Writes a file to the virtual file system (VFS).
|
|
520
535
|
*
|
|
@@ -522,7 +537,7 @@ interface VirtualFileSystemInterface {
|
|
|
522
537
|
* @param data - The contents of the file.
|
|
523
538
|
* @param options - Optional parameters for writing the file.
|
|
524
539
|
*/
|
|
525
|
-
writeFileSync: (path:
|
|
540
|
+
writeFileSync: (path: string, data?: WriteFileData, options?: WriteFileOptions) => void;
|
|
526
541
|
/**
|
|
527
542
|
* Moves a file from one path to another in the virtual file system (VFS).
|
|
528
543
|
*
|
|
@@ -569,24 +584,43 @@ interface VirtualFileSystemInterface {
|
|
|
569
584
|
* Resolves a path or id to a file path in the virtual file system.
|
|
570
585
|
*
|
|
571
586
|
* @param pathOrId - The path or id of the file to resolve.
|
|
572
|
-
* @param options - Optional parameters for resolving the path.
|
|
573
587
|
* @returns The resolved path of the file if it exists, otherwise false.
|
|
574
588
|
*/
|
|
575
|
-
|
|
589
|
+
realpathSync: (pathOrId: string) => string;
|
|
576
590
|
/**
|
|
577
|
-
*
|
|
591
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
578
592
|
*
|
|
579
|
-
* @
|
|
580
|
-
*
|
|
593
|
+
* @remarks
|
|
594
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```ts
|
|
598
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
599
|
+
* ```
|
|
600
|
+
*
|
|
601
|
+
* @param id - The module to resolve.
|
|
602
|
+
* @param importer - An optional path to the importer module.
|
|
603
|
+
* @param options - Additional resolution options.
|
|
604
|
+
* @returns A promise that resolves to the resolved module path.
|
|
581
605
|
*/
|
|
582
|
-
|
|
606
|
+
resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<string | undefined>;
|
|
583
607
|
/**
|
|
584
|
-
*
|
|
608
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
585
609
|
*
|
|
586
|
-
* @
|
|
587
|
-
*
|
|
610
|
+
* @remarks
|
|
611
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```ts
|
|
615
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
616
|
+
* ```
|
|
617
|
+
*
|
|
618
|
+
* @param id - The module to resolve.
|
|
619
|
+
* @param importer - An optional path to the importer module.
|
|
620
|
+
* @param options - Additional resolution options.
|
|
621
|
+
* @returns The resolved module path.
|
|
588
622
|
*/
|
|
589
|
-
|
|
623
|
+
resolveSync: (id: string, importer?: string, options?: ResolveOptions) => string | undefined;
|
|
590
624
|
/**
|
|
591
625
|
* Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
|
|
592
626
|
*/
|
|
@@ -1069,6 +1103,10 @@ interface MetaInfo {
|
|
|
1069
1103
|
interface Resolver extends Jiti {
|
|
1070
1104
|
plugin: Jiti;
|
|
1071
1105
|
}
|
|
1106
|
+
interface TransformResult {
|
|
1107
|
+
code: string;
|
|
1108
|
+
map: SourceMap | null;
|
|
1109
|
+
}
|
|
1072
1110
|
interface InitContextOptions {
|
|
1073
1111
|
/**
|
|
1074
1112
|
* If false, the plugin will be loaded after all other plugins.
|
|
@@ -1203,6 +1241,47 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
1203
1241
|
* The builtin module id that exist in the Powerlines virtual file system
|
|
1204
1242
|
*/
|
|
1205
1243
|
builtins: string[];
|
|
1244
|
+
/**
|
|
1245
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
1246
|
+
*
|
|
1247
|
+
* @see https://ts-morph.com/
|
|
1248
|
+
*
|
|
1249
|
+
* @remarks
|
|
1250
|
+
* This instance is created lazily on first access.
|
|
1251
|
+
*/
|
|
1252
|
+
program: Project;
|
|
1253
|
+
/**
|
|
1254
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
1255
|
+
*
|
|
1256
|
+
* @remarks
|
|
1257
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
* ```ts
|
|
1261
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
1262
|
+
* ```
|
|
1263
|
+
*
|
|
1264
|
+
* @param id - The module to resolve.
|
|
1265
|
+
* @param importer - An optional path to the importer module.
|
|
1266
|
+
* @param options - Additional resolution options.
|
|
1267
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1268
|
+
*/
|
|
1269
|
+
resolveId: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
|
|
1270
|
+
/**
|
|
1271
|
+
* A helper function to load modules using the Jiti resolver
|
|
1272
|
+
*
|
|
1273
|
+
* @remarks
|
|
1274
|
+
* This function can be used to load modules relative to the project root directory.
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```ts
|
|
1278
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
1279
|
+
* ```
|
|
1280
|
+
*
|
|
1281
|
+
* @param id - The module to load.
|
|
1282
|
+
* @returns A promise that resolves to the loaded module.
|
|
1283
|
+
*/
|
|
1284
|
+
load: (id: string) => Promise<TransformResult | undefined>;
|
|
1206
1285
|
/**
|
|
1207
1286
|
* The Powerlines builtin virtual files
|
|
1208
1287
|
*/
|
|
@@ -1372,7 +1451,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
|
|
|
1372
1451
|
* @param id - The identifier of the source code.
|
|
1373
1452
|
* @returns A promise that resolves when the hook is complete.
|
|
1374
1453
|
*/
|
|
1375
|
-
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
|
|
1454
|
+
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>;
|
|
1376
1455
|
/**
|
|
1377
1456
|
* A hook that is called to load the source code.
|
|
1378
1457
|
*
|
|
@@ -1380,7 +1459,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
|
|
|
1380
1459
|
* @param id - The identifier of the source code.
|
|
1381
1460
|
* @returns A promise that resolves when the hook is complete.
|
|
1382
1461
|
*/
|
|
1383
|
-
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
|
|
1462
|
+
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>;
|
|
1384
1463
|
/**
|
|
1385
1464
|
* A hook that is called to resolve the identifier of the source code.
|
|
1386
1465
|
*
|
|
@@ -1430,7 +1509,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
|
|
|
1430
1509
|
* @param id - The identifier of the source code.
|
|
1431
1510
|
* @returns A promise that resolves when the hook is complete.
|
|
1432
1511
|
*/
|
|
1433
|
-
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
|
|
1512
|
+
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>, "code" | "id">;
|
|
1434
1513
|
/**
|
|
1435
1514
|
* A hook that is called to load the source code.
|
|
1436
1515
|
*
|
|
@@ -1438,7 +1517,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
|
|
|
1438
1517
|
* @param id - The identifier of the source code.
|
|
1439
1518
|
* @returns A promise that resolves when the hook is complete.
|
|
1440
1519
|
*/
|
|
1441
|
-
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
|
|
1520
|
+
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>, "id">;
|
|
1442
1521
|
/**
|
|
1443
1522
|
* A hook that is called to resolve the identifier of the source code.
|
|
1444
1523
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaybePromise, NonUndefined, FunctionLike } from '@stryke/types/base';
|
|
2
|
-
import { UnpluginContext, UnpluginMessage, UnpluginBuildContext, TransformResult
|
|
2
|
+
import { UnpluginContext, UnpluginMessage, ExternalIdResult, UnpluginBuildContext, TransformResult as TransformResult$1, HookFilter, UnpluginOptions } from 'unplugin';
|
|
3
3
|
import { ArrayValues } from '@stryke/types/array';
|
|
4
4
|
import { PluginItem, PluginObj, PluginPass, transformAsync } from '@babel/core';
|
|
5
5
|
import { Format } from '@storm-software/build-tools/types';
|
|
@@ -12,8 +12,11 @@ import { BabelAPI } from '@babel/helper-plugin-utils';
|
|
|
12
12
|
import { EnvPaths } from '@stryke/env/get-env-paths';
|
|
13
13
|
import { PackageJson } from '@stryke/types/package-json';
|
|
14
14
|
import { Jiti } from 'jiti';
|
|
15
|
+
import { SourceMap } from 'magic-string';
|
|
15
16
|
import { Range } from 'semver';
|
|
16
|
-
import {
|
|
17
|
+
import { Project } from 'ts-morph';
|
|
18
|
+
import { ResolveOptions as ResolveOptions$1 } from '@stryke/fs/resolve';
|
|
19
|
+
import { StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
|
|
17
20
|
import { TsConfigJson, CompilerOptions } from '@stryke/types/tsconfig';
|
|
18
21
|
import ts from 'typescript';
|
|
19
22
|
|
|
@@ -290,21 +293,27 @@ interface PowerlinesWriteFileOptions extends ResolveFSOptions {
|
|
|
290
293
|
type NodeWriteFileOptions = WriteFileOptions$1;
|
|
291
294
|
type WriteFileOptions = NodeWriteFileOptions | PowerlinesWriteFileOptions;
|
|
292
295
|
type WriteFileData = string | NodeJS.ArrayBufferView | VirtualFileData;
|
|
293
|
-
interface
|
|
296
|
+
interface ResolveOptions extends ResolveOptions$1 {
|
|
294
297
|
/**
|
|
295
|
-
*
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
* If true, the module is being resolved as an entry point.
|
|
299
|
+
*/
|
|
300
|
+
isEntry?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* If true, the resolver will skip using the cache when resolving modules.
|
|
303
|
+
*/
|
|
304
|
+
skipCache?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* An array of external modules or patterns to exclude from resolution.
|
|
298
307
|
*/
|
|
299
|
-
|
|
308
|
+
external?: (string | RegExp)[];
|
|
300
309
|
/**
|
|
301
|
-
*
|
|
310
|
+
* An array of modules or patterns to include in the resolution, even if they are marked as external.
|
|
302
311
|
*/
|
|
303
|
-
|
|
312
|
+
noExternal?: (string | RegExp)[];
|
|
304
313
|
/**
|
|
305
|
-
*
|
|
314
|
+
* An array of patterns to match when resolving modules.
|
|
306
315
|
*/
|
|
307
|
-
|
|
316
|
+
skipNodeModulesBundle?: boolean;
|
|
308
317
|
}
|
|
309
318
|
interface VirtualFileSystemInterface {
|
|
310
319
|
/**
|
|
@@ -318,27 +327,33 @@ interface VirtualFileSystemInterface {
|
|
|
318
327
|
/**
|
|
319
328
|
* The underlying file metadata.
|
|
320
329
|
*/
|
|
321
|
-
metadata: Record<string, VirtualFileMetadata
|
|
330
|
+
metadata: Readonly<Record<string, VirtualFileMetadata>>;
|
|
331
|
+
/**
|
|
332
|
+
* A map of file paths to their module ids.
|
|
333
|
+
*/
|
|
334
|
+
ids: Readonly<Record<string, string>>;
|
|
322
335
|
/**
|
|
323
336
|
* A map of module ids to their file paths.
|
|
324
337
|
*/
|
|
325
|
-
|
|
338
|
+
paths: Readonly<Record<string, string>>;
|
|
326
339
|
/**
|
|
327
340
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
328
341
|
*
|
|
329
342
|
* @param pathOrId - The path or id to check.
|
|
343
|
+
* @param importer - The importer path, if any.
|
|
330
344
|
* @param options - Optional parameters for resolving the path.
|
|
331
345
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
332
346
|
*/
|
|
333
|
-
isVirtual: (pathOrId: string, options?:
|
|
347
|
+
isVirtual: (pathOrId: string, importer?: string, options?: ResolveOptions) => boolean;
|
|
334
348
|
/**
|
|
335
349
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
336
350
|
*
|
|
337
351
|
* @param pathOrId - The path or id to check.
|
|
352
|
+
* @param importer - The importer path, if any.
|
|
338
353
|
* @param options - Optional parameters for resolving the path.
|
|
339
354
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
340
355
|
*/
|
|
341
|
-
isPhysical: (pathOrId: string, options?:
|
|
356
|
+
isPhysical: (pathOrId: string, importer?: string, options?: ResolveOptions) => boolean;
|
|
342
357
|
/**
|
|
343
358
|
* Checks if a file exists in the virtual file system (VFS).
|
|
344
359
|
*
|
|
@@ -366,7 +381,7 @@ interface VirtualFileSystemInterface {
|
|
|
366
381
|
* @param pathOrId - The path or id of the file.
|
|
367
382
|
* @returns The metadata of the file if it exists, otherwise undefined.
|
|
368
383
|
*/
|
|
369
|
-
getMetadata: (pathOrId:
|
|
384
|
+
getMetadata: (pathOrId: string) => VirtualFileMetadata | undefined;
|
|
370
385
|
/**
|
|
371
386
|
* Gets the stats of a file in the virtual file system (VFS).
|
|
372
387
|
*
|
|
@@ -439,7 +454,7 @@ interface VirtualFileSystemInterface {
|
|
|
439
454
|
* @param path - The path to the file to remove.
|
|
440
455
|
* @returns A promise that resolves when the file is removed.
|
|
441
456
|
*/
|
|
442
|
-
unlinkSync: (path:
|
|
457
|
+
unlinkSync: (path: string, options?: ResolveFSOptions) => void;
|
|
443
458
|
/**
|
|
444
459
|
* Asynchronously removes a file or symbolic link in the virtual file system (VFS).
|
|
445
460
|
*
|
|
@@ -453,7 +468,7 @@ interface VirtualFileSystemInterface {
|
|
|
453
468
|
* @param path - The path to create the directory at.
|
|
454
469
|
* @param options - Options for creating the directory.
|
|
455
470
|
*/
|
|
456
|
-
rmdirSync: (path:
|
|
471
|
+
rmdirSync: (path: string, options?: RmDirOptions & ResolveFSOptions) => any;
|
|
457
472
|
/**
|
|
458
473
|
* Removes a directory in the virtual file system (VFS).
|
|
459
474
|
*
|
|
@@ -461,7 +476,7 @@ interface VirtualFileSystemInterface {
|
|
|
461
476
|
* @param options - Options for creating the directory.
|
|
462
477
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
463
478
|
*/
|
|
464
|
-
rmdir: (path:
|
|
479
|
+
rmdir: (path: string, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
|
|
465
480
|
/**
|
|
466
481
|
* Removes a file or directory in the virtual file system (VFS).
|
|
467
482
|
*
|
|
@@ -469,14 +484,14 @@ interface VirtualFileSystemInterface {
|
|
|
469
484
|
* @param options - Options for removing the file or directory.
|
|
470
485
|
* @returns A promise that resolves when the file or directory is removed.
|
|
471
486
|
*/
|
|
472
|
-
rm: (path:
|
|
487
|
+
rm: (path: string, options?: RmOptions & ResolveFSOptions) => Promise<void>;
|
|
473
488
|
/**
|
|
474
489
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
475
490
|
*
|
|
476
491
|
* @param path - The path to the file or directory to remove.
|
|
477
492
|
* @param options - Options for removing the file or directory.
|
|
478
493
|
*/
|
|
479
|
-
rmSync: (path:
|
|
494
|
+
rmSync: (path: string, options?: RmOptions & ResolveFSOptions) => void;
|
|
480
495
|
/**
|
|
481
496
|
* Creates a directory in the virtual file system (VFS).
|
|
482
497
|
*
|
|
@@ -484,7 +499,7 @@ interface VirtualFileSystemInterface {
|
|
|
484
499
|
* @param options - Options for creating the directory.
|
|
485
500
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
486
501
|
*/
|
|
487
|
-
mkdirSync: (path:
|
|
502
|
+
mkdirSync: (path: string, options?: MakeDirectoryOptions) => string | undefined;
|
|
488
503
|
/**
|
|
489
504
|
* Creates a directory in the virtual file system (VFS).
|
|
490
505
|
*
|
|
@@ -492,7 +507,7 @@ interface VirtualFileSystemInterface {
|
|
|
492
507
|
* @param options - Options for creating the directory.
|
|
493
508
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
494
509
|
*/
|
|
495
|
-
mkdir: (path:
|
|
510
|
+
mkdir: (path: string, options?: MakeDirectoryOptions) => Promise<string | undefined>;
|
|
496
511
|
/**
|
|
497
512
|
* Reads a file from the virtual file system (VFS).
|
|
498
513
|
*
|
|
@@ -514,7 +529,7 @@ interface VirtualFileSystemInterface {
|
|
|
514
529
|
* @param options - Optional parameters for writing the file.
|
|
515
530
|
* @returns A promise that resolves when the file is written.
|
|
516
531
|
*/
|
|
517
|
-
writeFile: (path:
|
|
532
|
+
writeFile: (path: string, data?: WriteFileData, options?: WriteFileOptions) => Promise<void>;
|
|
518
533
|
/**
|
|
519
534
|
* Writes a file to the virtual file system (VFS).
|
|
520
535
|
*
|
|
@@ -522,7 +537,7 @@ interface VirtualFileSystemInterface {
|
|
|
522
537
|
* @param data - The contents of the file.
|
|
523
538
|
* @param options - Optional parameters for writing the file.
|
|
524
539
|
*/
|
|
525
|
-
writeFileSync: (path:
|
|
540
|
+
writeFileSync: (path: string, data?: WriteFileData, options?: WriteFileOptions) => void;
|
|
526
541
|
/**
|
|
527
542
|
* Moves a file from one path to another in the virtual file system (VFS).
|
|
528
543
|
*
|
|
@@ -569,24 +584,43 @@ interface VirtualFileSystemInterface {
|
|
|
569
584
|
* Resolves a path or id to a file path in the virtual file system.
|
|
570
585
|
*
|
|
571
586
|
* @param pathOrId - The path or id of the file to resolve.
|
|
572
|
-
* @param options - Optional parameters for resolving the path.
|
|
573
587
|
* @returns The resolved path of the file if it exists, otherwise false.
|
|
574
588
|
*/
|
|
575
|
-
|
|
589
|
+
realpathSync: (pathOrId: string) => string;
|
|
576
590
|
/**
|
|
577
|
-
*
|
|
591
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
578
592
|
*
|
|
579
|
-
* @
|
|
580
|
-
*
|
|
593
|
+
* @remarks
|
|
594
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```ts
|
|
598
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
599
|
+
* ```
|
|
600
|
+
*
|
|
601
|
+
* @param id - The module to resolve.
|
|
602
|
+
* @param importer - An optional path to the importer module.
|
|
603
|
+
* @param options - Additional resolution options.
|
|
604
|
+
* @returns A promise that resolves to the resolved module path.
|
|
581
605
|
*/
|
|
582
|
-
|
|
606
|
+
resolve: (id: string, importer?: string, options?: ResolveOptions) => Promise<string | undefined>;
|
|
583
607
|
/**
|
|
584
|
-
*
|
|
608
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
585
609
|
*
|
|
586
|
-
* @
|
|
587
|
-
*
|
|
610
|
+
* @remarks
|
|
611
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```ts
|
|
615
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
616
|
+
* ```
|
|
617
|
+
*
|
|
618
|
+
* @param id - The module to resolve.
|
|
619
|
+
* @param importer - An optional path to the importer module.
|
|
620
|
+
* @param options - Additional resolution options.
|
|
621
|
+
* @returns The resolved module path.
|
|
588
622
|
*/
|
|
589
|
-
|
|
623
|
+
resolveSync: (id: string, importer?: string, options?: ResolveOptions) => string | undefined;
|
|
590
624
|
/**
|
|
591
625
|
* Disposes of the virtual file system (VFS), writes any virtual file changes to disk, and releases any associated resources.
|
|
592
626
|
*/
|
|
@@ -1069,6 +1103,10 @@ interface MetaInfo {
|
|
|
1069
1103
|
interface Resolver extends Jiti {
|
|
1070
1104
|
plugin: Jiti;
|
|
1071
1105
|
}
|
|
1106
|
+
interface TransformResult {
|
|
1107
|
+
code: string;
|
|
1108
|
+
map: SourceMap | null;
|
|
1109
|
+
}
|
|
1072
1110
|
interface InitContextOptions {
|
|
1073
1111
|
/**
|
|
1074
1112
|
* If false, the plugin will be loaded after all other plugins.
|
|
@@ -1203,6 +1241,47 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
1203
1241
|
* The builtin module id that exist in the Powerlines virtual file system
|
|
1204
1242
|
*/
|
|
1205
1243
|
builtins: string[];
|
|
1244
|
+
/**
|
|
1245
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
1246
|
+
*
|
|
1247
|
+
* @see https://ts-morph.com/
|
|
1248
|
+
*
|
|
1249
|
+
* @remarks
|
|
1250
|
+
* This instance is created lazily on first access.
|
|
1251
|
+
*/
|
|
1252
|
+
program: Project;
|
|
1253
|
+
/**
|
|
1254
|
+
* A helper function to resolve modules using the Jiti resolver
|
|
1255
|
+
*
|
|
1256
|
+
* @remarks
|
|
1257
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
* ```ts
|
|
1261
|
+
* const resolvedPath = await context.resolve("some-module", "/path/to/importer");
|
|
1262
|
+
* ```
|
|
1263
|
+
*
|
|
1264
|
+
* @param id - The module to resolve.
|
|
1265
|
+
* @param importer - An optional path to the importer module.
|
|
1266
|
+
* @param options - Additional resolution options.
|
|
1267
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1268
|
+
*/
|
|
1269
|
+
resolveId: (id: string, importer?: string, options?: ResolveOptions) => Promise<ExternalIdResult | undefined>;
|
|
1270
|
+
/**
|
|
1271
|
+
* A helper function to load modules using the Jiti resolver
|
|
1272
|
+
*
|
|
1273
|
+
* @remarks
|
|
1274
|
+
* This function can be used to load modules relative to the project root directory.
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```ts
|
|
1278
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
1279
|
+
* ```
|
|
1280
|
+
*
|
|
1281
|
+
* @param id - The module to load.
|
|
1282
|
+
* @returns A promise that resolves to the loaded module.
|
|
1283
|
+
*/
|
|
1284
|
+
load: (id: string) => Promise<TransformResult | undefined>;
|
|
1206
1285
|
/**
|
|
1207
1286
|
* The Powerlines builtin virtual files
|
|
1208
1287
|
*/
|
|
@@ -1372,7 +1451,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
|
|
|
1372
1451
|
* @param id - The identifier of the source code.
|
|
1373
1452
|
* @returns A promise that resolves when the hook is complete.
|
|
1374
1453
|
*/
|
|
1375
|
-
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>;
|
|
1454
|
+
transform: (this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>;
|
|
1376
1455
|
/**
|
|
1377
1456
|
* A hook that is called to load the source code.
|
|
1378
1457
|
*
|
|
@@ -1380,7 +1459,7 @@ interface BasePluginHookFunctions<TContext extends PluginContext = PluginContext
|
|
|
1380
1459
|
* @param id - The identifier of the source code.
|
|
1381
1460
|
* @returns A promise that resolves when the hook is complete.
|
|
1382
1461
|
*/
|
|
1383
|
-
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>;
|
|
1462
|
+
load: (this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>;
|
|
1384
1463
|
/**
|
|
1385
1464
|
* A hook that is called to resolve the identifier of the source code.
|
|
1386
1465
|
*
|
|
@@ -1430,7 +1509,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
|
|
|
1430
1509
|
* @param id - The identifier of the source code.
|
|
1431
1510
|
* @returns A promise that resolves when the hook is complete.
|
|
1432
1511
|
*/
|
|
1433
|
-
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult>, "code" | "id">;
|
|
1512
|
+
transform: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, code: string, id: string) => MaybePromise<TransformResult$1>, "code" | "id">;
|
|
1434
1513
|
/**
|
|
1435
1514
|
* A hook that is called to load the source code.
|
|
1436
1515
|
*
|
|
@@ -1438,7 +1517,7 @@ type PluginHooks<TContext extends PluginContext = PluginContext> = {
|
|
|
1438
1517
|
* @param id - The identifier of the source code.
|
|
1439
1518
|
* @returns A promise that resolves when the hook is complete.
|
|
1440
1519
|
*/
|
|
1441
|
-
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult>, "id">;
|
|
1520
|
+
load: PluginHook<(this: BuildPluginContext<TContext["config"]> & TContext, id: string) => MaybePromise<TransformResult$1>, "id">;
|
|
1442
1521
|
/**
|
|
1443
1522
|
* A hook that is called to resolve the identifier of the source code.
|
|
1444
1523
|
*
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from './plugin.cjs';
|
|
2
|
-
import '../plugin-
|
|
2
|
+
import '../plugin-DYbsUN3U.cjs';
|
|
3
3
|
import '@stryke/types/base';
|
|
4
4
|
import 'unplugin';
|
|
5
5
|
import '@stryke/types/array';
|
|
@@ -14,7 +14,10 @@ import '@babel/helper-plugin-utils';
|
|
|
14
14
|
import '@stryke/env/get-env-paths';
|
|
15
15
|
import '@stryke/types/package-json';
|
|
16
16
|
import 'jiti';
|
|
17
|
+
import 'magic-string';
|
|
17
18
|
import 'semver';
|
|
19
|
+
import 'ts-morph';
|
|
20
|
+
import '@stryke/fs/resolve';
|
|
18
21
|
import 'node:fs';
|
|
19
22
|
import '@stryke/types/tsconfig';
|
|
20
23
|
import 'typescript';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from './plugin.js';
|
|
2
|
-
import '../plugin-
|
|
2
|
+
import '../plugin-DYbsUN3U.js';
|
|
3
3
|
import '@stryke/types/base';
|
|
4
4
|
import 'unplugin';
|
|
5
5
|
import '@stryke/types/array';
|
|
@@ -14,7 +14,10 @@ import '@babel/helper-plugin-utils';
|
|
|
14
14
|
import '@stryke/env/get-env-paths';
|
|
15
15
|
import '@stryke/types/package-json';
|
|
16
16
|
import 'jiti';
|
|
17
|
+
import 'magic-string';
|
|
17
18
|
import 'semver';
|
|
19
|
+
import 'ts-morph';
|
|
20
|
+
import '@stryke/fs/resolve';
|
|
18
21
|
import 'node:fs';
|
|
19
22
|
import '@stryke/types/tsconfig';
|
|
20
23
|
import 'typescript';
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-
|
|
1
|
+
import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-DYbsUN3U.cjs';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-
|
|
1
|
+
import { d as BabelUserConfig, e as ResolvedConfig, f as BabelResolvedConfig, g as PluginContext, U as UserConfig } from '../plugin-DYbsUN3U.js';
|
|
2
2
|
import '@stryke/types/base';
|
|
3
3
|
import 'unplugin';
|
|
4
4
|
import '@stryke/types/array';
|
|
@@ -13,7 +13,10 @@ import '@babel/helper-plugin-utils';
|
|
|
13
13
|
import '@stryke/env/get-env-paths';
|
|
14
14
|
import '@stryke/types/package-json';
|
|
15
15
|
import 'jiti';
|
|
16
|
+
import 'magic-string';
|
|
16
17
|
import 'semver';
|
|
18
|
+
import 'ts-morph';
|
|
19
|
+
import '@stryke/fs/resolve';
|
|
17
20
|
import 'node:fs';
|
|
18
21
|
import '@stryke/types/tsconfig';
|
|
19
22
|
import 'typescript';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-babel",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -137,22 +137,22 @@
|
|
|
137
137
|
"@babel/parser": "^7.28.5",
|
|
138
138
|
"@babel/types": "^7.28.5",
|
|
139
139
|
"@storm-software/config-tools": "^1.188.48",
|
|
140
|
-
"@stryke/fs": "^0.
|
|
141
|
-
"@stryke/path": "^0.
|
|
142
|
-
"@stryke/type-checks": "^0.3.
|
|
143
|
-
"@stryke/types": "^0.10.
|
|
140
|
+
"@stryke/fs": "^0.33.0",
|
|
141
|
+
"@stryke/path": "^0.20.0",
|
|
142
|
+
"@stryke/type-checks": "^0.3.15",
|
|
143
|
+
"@stryke/types": "^0.10.5",
|
|
144
144
|
"chalk": "5.6.2",
|
|
145
145
|
"defu": "^6.1.4",
|
|
146
146
|
"jiti": "^2.6.1",
|
|
147
|
-
"powerlines": "^0.
|
|
147
|
+
"powerlines": "^0.24.0",
|
|
148
148
|
"unplugin": "^2.3.10"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
151
151
|
"@babel/plugin-syntax-typescript": "^7.27.1",
|
|
152
|
-
"@powerlines/nx": "^0.10.
|
|
153
|
-
"@powerlines/plugin-plugin": "^0.11.
|
|
152
|
+
"@powerlines/nx": "^0.10.28",
|
|
153
|
+
"@powerlines/plugin-plugin": "^0.11.36",
|
|
154
154
|
"@types/node": "^24.10.1"
|
|
155
155
|
},
|
|
156
156
|
"publishConfig": { "access": "public" },
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "73acce2067b9d81822a59cb03a4b1e7fa8873bf9"
|
|
158
158
|
}
|