Skip to content

Commit 5c1e808

Browse files
authored
Add options to wildcard
1 parent ff3ade3 commit 5c1e808

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/VueProgram.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ class VueProgram {
3131
}
3232

3333
/**
34-
* Since 99.9% of Vue projects use the wildcard '@/*', we only search for that in tsconfig CompilerOptions.paths.
34+
* Search for default wildcard or wildcard from options, we only search for that in tsconfig CompilerOptions.paths.
3535
* The path is resolved with thie given substitution and includes the CompilerOptions.baseUrl (if given).
3636
* If no paths given in tsconfig, then the default substitution is '[tsconfig directory]/src'.
3737
* (This is a fast, simplified inspiration of what's described here: https://github.com/Microsoft/TypeScript/issues/5039)
3838
*/
3939
public static resolveNonTsModuleName(moduleName: string, containingFile: string, basedir: string, options: ts.CompilerOptions) {
4040
const baseUrl = options.baseUrl ? options.baseUrl : basedir;
41-
const pattern = options.paths ? options.paths['@/*'] : undefined;
42-
const substitution = pattern ? options.paths['@/*'][0].replace('*', '') : 'src';
43-
const isWildcard = moduleName.substr(0, 2) === '@/';
41+
const wildcard = options.wildcard ? options.wildcard : '@';
42+
const pattern = options.paths ? options.paths[`${wildcard}/*`] : undefined;
43+
const substitution = pattern ? options.paths[`${wildcard}/*`][0].replace('*', '') : 'src';
44+
const isWildcard = moduleName.substr(0, 2) === `${wildcard}/`;
4445
const isRelative = !path.isAbsolute(moduleName);
4546

4647
if (isWildcard) {

0 commit comments

Comments
 (0)