@lynxwall/cucumber-tsflow 7.3.0 → 7.3.1
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/lib/transpilers/esm/loader-utils.mjs +87 -9
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -79,21 +79,57 @@ export async function resolveWithExtensions(specifier, parentURL, extensions = C
|
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
const pathResolutionCache = new Map();
|
|
83
|
+
|
|
83
84
|
export function resolveTsconfigPaths(specifier) {
|
|
85
|
+
// Fast path: skip what we know won't match
|
|
86
|
+
if (
|
|
87
|
+
specifier.startsWith('.') ||
|
|
88
|
+
specifier.startsWith('/') ||
|
|
89
|
+
specifier.startsWith('file:') ||
|
|
90
|
+
specifier.startsWith('node:')
|
|
91
|
+
) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Check cache
|
|
96
|
+
if (pathResolutionCache.has(specifier)) {
|
|
97
|
+
return pathResolutionCache.get(specifier);
|
|
98
|
+
}
|
|
99
|
+
|
|
84
100
|
const matchPath = initializeTsconfigPaths();
|
|
101
|
+
if (!matchPath) {
|
|
102
|
+
pathResolutionCache.set(specifier, null);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
85
105
|
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
// Try direct match first
|
|
107
|
+
const mapped = matchPath(specifier);
|
|
108
|
+
if (mapped) {
|
|
109
|
+
const result = {
|
|
110
|
+
url: pathToFileURL(mapped).href,
|
|
111
|
+
shortCircuit: true
|
|
112
|
+
};
|
|
113
|
+
pathResolutionCache.set(specifier, result);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
88
116
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
117
|
+
// Try with extensions if no extension present
|
|
118
|
+
if (!path.extname(specifier)) {
|
|
119
|
+
for (const ext of ['.ts', '.js', '.mjs', '.vue']) {
|
|
120
|
+
const mappedWithExt = matchPath(specifier + ext);
|
|
121
|
+
if (mappedWithExt) {
|
|
122
|
+
const result = {
|
|
123
|
+
url: pathToFileURL(mappedWithExt).href,
|
|
124
|
+
shortCircuit: true
|
|
125
|
+
};
|
|
126
|
+
pathResolutionCache.set(specifier, result);
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
94
129
|
}
|
|
95
130
|
}
|
|
96
131
|
|
|
132
|
+
pathResolutionCache.set(specifier, null);
|
|
97
133
|
return null;
|
|
98
134
|
}
|
|
99
135
|
|
|
@@ -118,6 +154,45 @@ export function shouldEnableVueStyle() {
|
|
|
118
154
|
);
|
|
119
155
|
}
|
|
120
156
|
|
|
157
|
+
async function transformImports(code, parentURL) {
|
|
158
|
+
// Match various import patterns
|
|
159
|
+
const importRegex =
|
|
160
|
+
/(?:import|export)\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+|type\s+\{[^}]*\}|type\s+\w+)\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
161
|
+
|
|
162
|
+
const matches = [...code.matchAll(importRegex)];
|
|
163
|
+
let transformed = code;
|
|
164
|
+
|
|
165
|
+
for (const match of matches) {
|
|
166
|
+
const specifier = match[1];
|
|
167
|
+
|
|
168
|
+
// Skip if it's already a relative path or absolute URL
|
|
169
|
+
if (specifier.startsWith('.') || specifier.startsWith('/') || specifier.startsWith('file:')) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Try to resolve with tsconfig paths
|
|
174
|
+
const resolved = resolveTsconfigPaths(specifier);
|
|
175
|
+
if (resolved) {
|
|
176
|
+
// Convert the resolved path to a relative import from the parent file
|
|
177
|
+
const parentDir = path.dirname(fileURLToPath(parentURL));
|
|
178
|
+
const resolvedPath = fileURLToPath(resolved.url);
|
|
179
|
+
let relativePath = path.relative(parentDir, resolvedPath).replace(/\\/g, '/');
|
|
180
|
+
|
|
181
|
+
// Ensure it starts with ./ or ../
|
|
182
|
+
if (!relativePath.startsWith('.')) {
|
|
183
|
+
relativePath = './' + relativePath;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Replace the specifier in the import statement
|
|
187
|
+
const originalImport = match[0];
|
|
188
|
+
const newImport = originalImport.replace(specifier, relativePath);
|
|
189
|
+
transformed = transformed.replace(originalImport, newImport);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return transformed;
|
|
194
|
+
}
|
|
195
|
+
|
|
121
196
|
export async function loadVue(url, context, nextLoad) {
|
|
122
197
|
const { source } = await nextLoad(url, { ...context, format: 'module' });
|
|
123
198
|
const code = source.toString();
|
|
@@ -127,9 +202,12 @@ export async function loadVue(url, context, nextLoad) {
|
|
|
127
202
|
enableStyle: shouldEnableVueStyle()
|
|
128
203
|
});
|
|
129
204
|
|
|
205
|
+
// Transform imports to resolve path aliases
|
|
206
|
+
const transformed = await transformImports(compiled.code, url);
|
|
207
|
+
|
|
130
208
|
return {
|
|
131
209
|
format: 'module',
|
|
132
|
-
source:
|
|
210
|
+
source: transformed,
|
|
133
211
|
shortCircuit: true
|
|
134
212
|
};
|
|
135
213
|
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "7.3.
|
|
1
|
+
export declare const version = "7.3.1";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '7.3.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '7.3.1'\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynxwall/cucumber-tsflow",
|
|
3
3
|
"description": "Provides 'specflow' like bindings for CucumberJS 11.2.0 in TypeScript 5.8+.",
|
|
4
|
-
"version": "7.3.
|
|
4
|
+
"version": "7.3.1",
|
|
5
5
|
"author": "Lonnie Wall <lynxdev@lynxwall.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|