Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseUrl value is not accurately recognized #208

Open
RHIE-coder opened this issue Jan 15, 2024 · 0 comments
Open

baseUrl value is not accurately recognized #208

RHIE-coder opened this issue Jan 15, 2024 · 0 comments

Comments

@RHIE-coder
Copy link

RHIE-coder commented Jan 15, 2024

There is an error in not parsing the path accurately, depending on the baseUrl value in tsconfig.json.

Error Case

  • tsconfig.json
{
    ...
    "compilerOptions": {
        "baseUrl": "./src/jslib",
        "paths": { "@/crypto/*": ["crypto/*"], "@/utils/*": ["utils/*"] }
        "outDir": "./build"
     }
    ...
}

Problem found with debug

Correctly find the file to replace and read the baseUrl and path values in tsconfig.json correctly.

However, the .replace('---', '') function does not seem to work.

tsc-alias debug: default replacer - absoluteAliasPath:  '---/Users/rhiemh/Workspace/@demo/test-sandbox/build'
tsc-alias debug: default replacer - Invalid path
tsc-alias debug: base-url replacer - requiredModule:  '@/utils/math'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/index.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/crypto/decrypt.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/crypto/encrypt.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/utils/math.js'

Success Case

  • tsconfig.json
{
    ...
    "compilerOptions": {
        "baseUrl": "./",
        "paths": { "@/crypto/*": ["./src/jslib/crypto/*"], "@/utils/*": ["./src/jslib/utils/*"] },
        "outDir": "./build"
     }
    ...
}

Debug result

tsc-alias debug: default replacer - absoluteAliasPath:  '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/utils'
tsc-alias debug: default replacer - relativeAliasPath:  './jslib/utils'
tsc-alias debug: default replacer - newImportScript:  'require("./jslib/utils/math")'
tsc-alias debug: default replacer - modulePath:  './jslib/utils/math'
tsc-alias debug: base-url replacer - requiredModule:  './jslib/utils/math'
tsc-alias debug: base-url replacer - already resolved
tsc-alias debug: replaced file with changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/index.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/utils/math.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/crypto/decrypt.js'
tsc-alias debug: replaced file without changes: '/Users/rhiemh/Workspace/@demo/test-sandbox/build/src/jslib/crypto/encrypt.js'

Issue Conclusion

As you can see, both 'Error Case' and 'Success Case' have the same path, but they behave differently depending on the combination of baseUrl and path.

Am I doing something wrong or is it a bug?

Thanks!

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant