@esportsplus/typescript 0.27.4 → 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.
|
@@ -2,6 +2,7 @@ import { ts } from '../../index.js';
|
|
|
2
2
|
import coordinator from '../coordinator.js';
|
|
3
3
|
import program from '../program.js';
|
|
4
4
|
const FILE_REGEX = /\.[tj]sx?$/;
|
|
5
|
+
const DIRECTORY_SEPARATOR_REGEX = /\\/g;
|
|
5
6
|
let contexts = new Map();
|
|
6
7
|
export default ({ name, onWatchChange, plugins }) => {
|
|
7
8
|
return ({ root } = {}) => {
|
|
@@ -16,7 +17,11 @@ export default ({ name, onWatchChange, plugins }) => {
|
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
19
|
try {
|
|
19
|
-
let
|
|
20
|
+
let prog = program.get(root || ''), sourceFile = prog.getSourceFile(id.replace(DIRECTORY_SEPARATOR_REGEX, '/')) || prog.getSourceFile(id);
|
|
21
|
+
if (!sourceFile || sourceFile.getText() !== code) {
|
|
22
|
+
sourceFile = ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true);
|
|
23
|
+
}
|
|
24
|
+
let result = coordinator.transform(plugins, code, sourceFile, prog, contexts.get(root || '') ?? contexts.set(root || '', new Map()).get(root || ''));
|
|
20
25
|
if (!result.changed) {
|
|
21
26
|
return null;
|
|
22
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "ICJR",
|
|
3
3
|
"bin": {
|
|
4
|
+
"esportsplus-tsc": "./bin/tsc",
|
|
5
|
+
"esportsplus-tsc-alias": "./bin/tsc-alias",
|
|
4
6
|
"tsc": "./bin/tsc",
|
|
5
7
|
"tsc-alias": "./bin/tsc-alias"
|
|
6
8
|
},
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
},
|
|
38
40
|
"type": "module",
|
|
39
41
|
"types": "build/index.d.ts",
|
|
40
|
-
"version": "0.
|
|
42
|
+
"version": "0.28.0",
|
|
41
43
|
"scripts": {
|
|
42
44
|
"build": "tsc && tsc-alias",
|
|
43
45
|
"-": "-"
|
|
@@ -22,6 +22,8 @@ type VitePluginOptions = {
|
|
|
22
22
|
|
|
23
23
|
const FILE_REGEX = /\.[tj]sx?$/;
|
|
24
24
|
|
|
25
|
+
const DIRECTORY_SEPARATOR_REGEX = /\\/g;
|
|
26
|
+
|
|
25
27
|
|
|
26
28
|
let contexts = new Map<string, SharedContext>();
|
|
27
29
|
|
|
@@ -40,11 +42,18 @@ export default ({ name, onWatchChange, plugins }: VitePluginOptions) => {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
try {
|
|
45
|
+
let prog = program.get(root || ''),
|
|
46
|
+
sourceFile = prog.getSourceFile(id.replace(DIRECTORY_SEPARATOR_REGEX, '/')) || prog.getSourceFile(id);
|
|
47
|
+
|
|
48
|
+
if (!sourceFile || sourceFile.getText() !== code) {
|
|
49
|
+
sourceFile = ts.createSourceFile(id, code, ts.ScriptTarget.Latest, true);
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
let result = coordinator.transform(
|
|
44
53
|
plugins,
|
|
45
54
|
code,
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
sourceFile,
|
|
56
|
+
prog,
|
|
48
57
|
contexts.get(root || '') ?? contexts.set(root || '', new Map()).get(root || '')!
|
|
49
58
|
);
|
|
50
59
|
|