@openrewrite/rewrite 8.66.0-20251028-141506 → 8.66.0-20251029-101717
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/java/type.d.ts +2 -0
- package/dist/java/type.d.ts.map +1 -1
- package/dist/java/type.js +5 -0
- package/dist/java/type.js.map +1 -1
- package/dist/javascript/format.d.ts.map +1 -1
- package/dist/javascript/format.js +33 -27
- package/dist/javascript/format.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +82 -1
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +12 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +114 -0
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/rpc/server.js +0 -0
- package/dist/version.txt +1 -1
- package/package.json +1 -1
- package/src/java/type.ts +6 -0
- package/src/javascript/format.ts +38 -29
- package/src/javascript/parser.ts +61 -1
- package/src/javascript/type-mapping.ts +125 -0
- package/src/rpc/server.ts +0 -0
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
36
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
4
37
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
@@ -33,6 +66,7 @@ exports.JavaScriptParserVisitor = exports.JavaScriptParser = void 0;
|
|
|
33
66
|
* limitations under the License.
|
|
34
67
|
*/
|
|
35
68
|
const typescript_1 = __importDefault(require("typescript"));
|
|
69
|
+
const path = __importStar(require("path"));
|
|
36
70
|
const java_1 = require("../java");
|
|
37
71
|
const _1 = require(".");
|
|
38
72
|
const markers_1 = require("../markers");
|
|
@@ -93,7 +127,11 @@ class JavaScriptParser extends parser_1.Parser {
|
|
|
93
127
|
const inputFiles = new Map();
|
|
94
128
|
// Populate inputFiles map and remove from cache if necessary
|
|
95
129
|
for (const input of inputs) {
|
|
96
|
-
|
|
130
|
+
let sourcePath = (0, parser_1.parserInputFile)(input);
|
|
131
|
+
// If relativeTo is set and path is not absolute, make it absolute
|
|
132
|
+
if (this.relativeTo && !path.isAbsolute(sourcePath)) {
|
|
133
|
+
sourcePath = path.join(this.relativeTo, sourcePath);
|
|
134
|
+
}
|
|
97
135
|
inputFiles.set(sourcePath, input);
|
|
98
136
|
// Remove from cache if previously cached
|
|
99
137
|
this.sourceFileCache && this.sourceFileCache.delete(sourcePath);
|
|
@@ -154,6 +192,49 @@ class JavaScriptParser extends parser_1.Parser {
|
|
|
154
192
|
const input = inputFiles.get(fileName);
|
|
155
193
|
return input ? (0, parser_1.parserInputRead)(input) : typescript_1.default.sys.readFile(fileName);
|
|
156
194
|
};
|
|
195
|
+
// Custom module resolution to handle in-memory imports
|
|
196
|
+
// This is required because TypeScript's default module resolution looks for files on disk,
|
|
197
|
+
// but our source files only exist in memory (in the inputFiles map)
|
|
198
|
+
host.resolveModuleNameLiterals = (moduleLiterals, containingFile) => {
|
|
199
|
+
const resolvedModules = [];
|
|
200
|
+
const containingDir = path.dirname(containingFile);
|
|
201
|
+
for (const moduleLiteral of moduleLiterals) {
|
|
202
|
+
const moduleName = moduleLiteral.text;
|
|
203
|
+
// For relative imports, try to find in inputFiles first
|
|
204
|
+
if (moduleName.startsWith('.')) {
|
|
205
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js', '.mts', '.cts'];
|
|
206
|
+
let resolved;
|
|
207
|
+
for (const ext of extensions) {
|
|
208
|
+
// Try with extension
|
|
209
|
+
const candidate = path.join(containingDir, moduleName + ext);
|
|
210
|
+
if (inputFiles.has(candidate)) {
|
|
211
|
+
resolved = candidate;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
// Also try exact match (if moduleName already has extension)
|
|
215
|
+
const exactCandidate = path.join(containingDir, moduleName);
|
|
216
|
+
if (inputFiles.has(exactCandidate)) {
|
|
217
|
+
resolved = exactCandidate;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (resolved) {
|
|
222
|
+
resolvedModules.push({
|
|
223
|
+
resolvedModule: {
|
|
224
|
+
resolvedFileName: resolved,
|
|
225
|
+
extension: path.extname(resolved),
|
|
226
|
+
isExternalLibraryImport: false,
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Fall back to TypeScript's default resolution for node_modules and absolute paths
|
|
233
|
+
const result = typescript_1.default.resolveModuleName(moduleName, containingFile, this.compilerOptions, host);
|
|
234
|
+
resolvedModules.push(result);
|
|
235
|
+
}
|
|
236
|
+
return resolvedModules;
|
|
237
|
+
};
|
|
157
238
|
// Create a new Program, passing the oldProgram for incremental parsing
|
|
158
239
|
const program = typescript_1.default.createProgram([...inputFiles.keys()], this.compilerOptions, host, this.oldProgram);
|
|
159
240
|
// Update the oldProgram reference
|