You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, I have a file located at '@/server/util/dbUtils' (which is actually a TypeScript file) being imported as follows:
import{toSafeInteger}from'@/server/util/dbUtils';
It is expected that after compilation, the import should be:
var_dbUtils=require("../../util/dbUtils");// or var_dbUtils=require("../../util/dbUtils.js");
However, it is being resolved as:
var_dbUtils=require("../../util/dbUtils.ts");
which causes the service to crash.
For this reason, I think there should be an option to control unnecessary file extensions, or I might try to add a piece of code as follows:
In lib/resolve.js
constresolvePath=(sourceFile,importPath,basePath,extensions,aliases,relative)=>{constresolver=getResolvers(importPath,aliases)if(!resolver)returnconst{ alias, transformers }=resolverfor(consttransformeroftransformers){consttransformedImport=path.join(basePath,importPath.replace(alias,transformer))letcheckImport=transformedImporttry{conststat=fs.statSync(transformedImport)if(stat&&stat.isDirectory()){checkImport=path.join(transformedImport,'index')}}catch(err){// noop}// If the original import has an extension, then check for it, too, when// checking for existence of the fileconstcheckExtensions=[''].concat(extensions)constfileVariations=checkExtensions.map((ext)=>checkImport+ext)constrealFile=fileVariations.find((file)=>fs.existsSync(file))if(realFile){constresolvedPath=(relative
? getRelativePath(sourceFile,realFile)
: realFile).replace(/\\/g,'/')if(resolvedPath.endsWith('.d.ts')){// aviod remove .d.ts extensioncontinue}returnresolvedPath.replace(/\.tsx?$/,'')// here to remove ts or tsx extension}}}
The text was updated successfully, but these errors were encountered:
When using babel-plugin-tsconfig-paths, I found that it could not correctly resolve paths. My tsconfig configuration is as follows:
Then, I have a file located at '@/server/util/dbUtils' (which is actually a TypeScript file) being imported as follows:
It is expected that after compilation, the import should be:
However, it is being resolved as:
which causes the service to crash.
For this reason, I think there should be an option to control unnecessary file extensions, or I might try to add a piece of code as follows:
In lib/resolve.js
The text was updated successfully, but these errors were encountered: