@esportsplus/typescript 0.23.1 → 0.24.2
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/build/compiler/imports.js +1 -1
- package/build/compiler/plugins/index.d.ts +11 -6
- package/build/compiler/plugins/tsc.d.ts +2 -3
- package/build/compiler/plugins/tsc.js +2 -2
- package/build/compiler/plugins/vite.d.ts +15 -9
- package/build/compiler/types.d.ts +1 -7
- package/package.json +1 -1
- package/src/compiler/imports.ts +1 -1
- package/src/compiler/plugins/tsc.ts +3 -9
- package/src/compiler/plugins/vite.ts +20 -4
- package/src/compiler/types.ts +7 -8
|
@@ -18,7 +18,7 @@ const find = (sourceFile, packageName) => {
|
|
|
18
18
|
specifiers.set(propertyName, name);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
imports.push({ end: stmt.end, specifiers, start: stmt.getStart() });
|
|
21
|
+
imports.push({ end: stmt.end, specifiers, start: stmt.getStart(sourceFile) });
|
|
22
22
|
}
|
|
23
23
|
return imports;
|
|
24
24
|
};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
tsc: ({ analyze, transform }: import("../index.js").PluginDefinition) => (program: import("typescript").Program, context: import("../index.js").PluginContext) => {
|
|
3
|
-
analyze
|
|
3
|
+
analyze: ((sourceFile: import("typescript").SourceFile) => void) | undefined;
|
|
4
4
|
transform: import("typescript").TransformerFactory<import("typescript").SourceFile>;
|
|
5
5
|
};
|
|
6
|
-
vite: ({ analyze, name, onWatchChange, transform }:
|
|
6
|
+
vite: ({ analyze, name, onWatchChange, transform }: {
|
|
7
|
+
analyze?: import("../index.js").AnalyzeFn;
|
|
8
|
+
name: string;
|
|
9
|
+
onWatchChange?: () => void;
|
|
10
|
+
transform: import("../index.js").TransformFn;
|
|
11
|
+
}) => ({ root }?: {
|
|
7
12
|
root?: string;
|
|
8
13
|
}) => {
|
|
9
|
-
configResolved(config:
|
|
10
|
-
enforce:
|
|
14
|
+
configResolved: (config: unknown) => void;
|
|
15
|
+
enforce: "pre";
|
|
11
16
|
name: string;
|
|
12
|
-
transform(code: string, id: string)
|
|
17
|
+
transform: (code: string, id: string) => {
|
|
13
18
|
code: string;
|
|
14
19
|
map: null;
|
|
15
20
|
} | null;
|
|
16
|
-
watchChange(id: string)
|
|
21
|
+
watchChange: (id: string) => void;
|
|
17
22
|
};
|
|
18
23
|
};
|
|
19
24
|
export default _default;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { PluginContext, PluginDefinition } from '../types.js';
|
|
2
2
|
import { ts } from '../../index.js';
|
|
3
|
-
|
|
4
|
-
analyze
|
|
3
|
+
declare const _default: ({ analyze, transform }: PluginDefinition) => (program: ts.Program, context: PluginContext) => {
|
|
4
|
+
analyze: ((sourceFile: ts.SourceFile) => void) | undefined;
|
|
5
5
|
transform: ts.TransformerFactory<ts.SourceFile>;
|
|
6
6
|
};
|
|
7
|
-
declare const _default: ({ analyze, transform }: PluginDefinition) => TscPluginFactory;
|
|
8
7
|
export default _default;
|
|
@@ -4,12 +4,12 @@ export default ({ analyze, transform }) => {
|
|
|
4
4
|
analyze: analyze
|
|
5
5
|
? (sourceFile) => analyze(sourceFile, program, context)
|
|
6
6
|
: undefined,
|
|
7
|
-
transform: () => {
|
|
7
|
+
transform: (() => {
|
|
8
8
|
return (sourceFile) => {
|
|
9
9
|
let result = transform(sourceFile, program, context);
|
|
10
10
|
return result.changed ? result.sourceFile : sourceFile;
|
|
11
11
|
};
|
|
12
|
-
}
|
|
12
|
+
})
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) => {
|
|
6
|
-
configResolved(config: ResolvedConfig): void;
|
|
7
|
-
enforce: string;
|
|
1
|
+
import type { AnalyzeFn, TransformFn } from '../types.js';
|
|
2
|
+
type VitePlugin = {
|
|
3
|
+
configResolved: (config: unknown) => void;
|
|
4
|
+
enforce: 'pre';
|
|
8
5
|
name: string;
|
|
9
|
-
transform(code: string, id: string)
|
|
6
|
+
transform: (code: string, id: string) => {
|
|
10
7
|
code: string;
|
|
11
8
|
map: null;
|
|
12
9
|
} | null;
|
|
13
|
-
watchChange(id: string)
|
|
10
|
+
watchChange: (id: string) => void;
|
|
11
|
+
};
|
|
12
|
+
type VitePluginOptions = {
|
|
13
|
+
analyze?: AnalyzeFn;
|
|
14
|
+
name: string;
|
|
15
|
+
onWatchChange?: () => void;
|
|
16
|
+
transform: TransformFn;
|
|
14
17
|
};
|
|
18
|
+
declare const _default: ({ analyze, name, onWatchChange, transform }: VitePluginOptions) => ({ root }?: {
|
|
19
|
+
root?: string;
|
|
20
|
+
}) => VitePlugin;
|
|
15
21
|
export default _default;
|
|
@@ -22,10 +22,4 @@ type TransformResult = {
|
|
|
22
22
|
code: string;
|
|
23
23
|
sourceFile: ts.SourceFile;
|
|
24
24
|
};
|
|
25
|
-
type
|
|
26
|
-
analyze?: AnalyzeFn;
|
|
27
|
-
name: string;
|
|
28
|
-
onWatchChange?: () => void;
|
|
29
|
-
transform: TransformFn;
|
|
30
|
-
};
|
|
31
|
-
export type { AnalyzeFn, PluginContext, PluginDefinition, QuickCheckPattern, Range, Replacement, TransformFn, TransformResult, VitePluginOptions };
|
|
25
|
+
export type { AnalyzeFn, PluginContext, PluginDefinition, QuickCheckPattern, Range, Replacement, TransformFn, TransformResult };
|
package/package.json
CHANGED
package/src/compiler/imports.ts
CHANGED
|
@@ -46,7 +46,7 @@ const find = (sourceFile: ts.SourceFile, packageName: string): ImportInfo[] => {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
imports.push({ end: stmt.end, specifiers, start: stmt.getStart() });
|
|
49
|
+
imports.push({ end: stmt.end, specifiers, start: stmt.getStart(sourceFile) });
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
return imports;
|
|
@@ -2,25 +2,19 @@ import type { PluginContext, PluginDefinition } from '../types';
|
|
|
2
2
|
import { ts } from '../..';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
analyze?: (sourceFile: ts.SourceFile) => void;
|
|
7
|
-
transform: ts.TransformerFactory<ts.SourceFile>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default ({ analyze, transform }: PluginDefinition): TscPluginFactory => {
|
|
5
|
+
export default ({ analyze, transform }: PluginDefinition) => {
|
|
12
6
|
return (program: ts.Program, context: PluginContext) => {
|
|
13
7
|
return {
|
|
14
8
|
analyze: analyze
|
|
15
9
|
? (sourceFile: ts.SourceFile) => analyze(sourceFile, program, context)
|
|
16
10
|
: undefined,
|
|
17
|
-
transform: () => {
|
|
11
|
+
transform: (() => {
|
|
18
12
|
return (sourceFile) => {
|
|
19
13
|
let result = transform(sourceFile, program, context);
|
|
20
14
|
|
|
21
15
|
return result.changed ? result.sourceFile : sourceFile;
|
|
22
16
|
};
|
|
23
|
-
}
|
|
17
|
+
}) as ts.TransformerFactory<ts.SourceFile>
|
|
24
18
|
};
|
|
25
19
|
};
|
|
26
20
|
}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import type { ResolvedConfig } from 'vite';
|
|
2
|
-
import type { PluginContext,
|
|
2
|
+
import type { AnalyzeFn, PluginContext, TransformFn } from '../types';
|
|
3
3
|
import { ts } from '../..';
|
|
4
4
|
import program from '../program';
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
type VitePlugin = {
|
|
8
|
+
configResolved: (config: unknown) => void;
|
|
9
|
+
enforce: 'pre';
|
|
10
|
+
name: string;
|
|
11
|
+
transform: (code: string, id: string) => { code: string; map: null } | null;
|
|
12
|
+
watchChange: (id: string) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type VitePluginOptions = {
|
|
16
|
+
analyze?: AnalyzeFn;
|
|
17
|
+
name: string;
|
|
18
|
+
onWatchChange?: () => void;
|
|
19
|
+
transform: TransformFn;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
7
23
|
const FILE_REGEX = /\.[tj]sx?$/;
|
|
8
24
|
|
|
9
25
|
|
|
@@ -11,10 +27,10 @@ let contexts = new Map<string, PluginContext>();
|
|
|
11
27
|
|
|
12
28
|
|
|
13
29
|
export default ({ analyze, name, onWatchChange, transform }: VitePluginOptions) => {
|
|
14
|
-
return ({ root }: { root?: string } = {}) => {
|
|
30
|
+
return ({ root }: { root?: string } = {}): VitePlugin => {
|
|
15
31
|
return {
|
|
16
|
-
configResolved(config:
|
|
17
|
-
root ??= config.root;
|
|
32
|
+
configResolved(config: unknown) {
|
|
33
|
+
root ??= (config as ResolvedConfig).root;
|
|
18
34
|
},
|
|
19
35
|
enforce: 'pre',
|
|
20
36
|
name: `${name}/plugin-vite`,
|
package/src/compiler/types.ts
CHANGED
|
@@ -32,12 +32,11 @@ type TransformResult = {
|
|
|
32
32
|
sourceFile: ts.SourceFile;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
type VitePluginOptions = {
|
|
36
|
-
analyze?: AnalyzeFn;
|
|
37
|
-
name: string;
|
|
38
|
-
onWatchChange?: () => void;
|
|
39
|
-
transform: TransformFn;
|
|
40
|
-
};
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
export type {
|
|
37
|
+
AnalyzeFn,
|
|
38
|
+
PluginContext, PluginDefinition,
|
|
39
|
+
QuickCheckPattern,
|
|
40
|
+
Range, Replacement,
|
|
41
|
+
TransformFn, TransformResult
|
|
42
|
+
};
|