-
Notifications
You must be signed in to change notification settings - Fork 23
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
Aliases import in types definition isn't resolved on the build result #137
Comments
you'll need to config aliases in the rollup config. |
my 3rd try in my description was customizing rollup config. not sure what's wrong since i don't have experience with rollup. do you have your own configuration that support this aliases import ? |
I've tested on my local(https://github.com/weiran-zsd/dts-cli/tree/issue137), it seems working(you'll still need to config jest aliases). it's less ideal, but a good improvement is to read tsconfig.paths, and apply the aliases to rollup & jest. So, users do not have to add multi configs.:) |
I have cloned and https://github.com/weiran-zsd/dts-cli/tree/issue137 but still not working with my case.
export interface FooInterface {
name: string;
}
import * as React from 'react';
import { foo } from '@Components/foo';
import { FooInterface } from '@Components/foo.interface';
console.log(foo);
// Delete me
export const Thing = () => {
return <div>Welcome to your first test package.</div>;
};
export const FooComponent = (props: FooInterface) => {
return <div>FooComponent</div>;
}; build result |
I see. it's expected, as it won't transform the paths to relative. maybe bundling types with |
not really sure what that means. but i try to add "scripts": {
"analyze": "size-limit --why",
"build": "dts build --rollupTypes",
"lint": "dts lint",
"prepare": "dts build",
"size": "size-limit",
"start": "dts watch",
"test": "dts test --passWithNoTests"
}, but the import issue still there and the difference is just the build result remove the |
well, it sounds a bug to me! |
Current Behavior
I added absolute import aliases configuration in
tsconfig.json
and using that aliases import in one of my interfaces file
but when running
dts build
which will bundle the component. the import still not updated to relative import and cause the types not detected and the component will lose the ability of the types since it's refer to the incorrect path.Expected behavior
Expected behavior is that when build the app it will resolve all aliases import into relative import so that it refers to the correct path
Suggested solution(s)
None at the moment,
My temporary workaround is just to update all import to relative import. but it will be a mess if in the future i have deeper nested folder with
../../../
importAdditional context
Since this lib based on
tsdx
. I have tried many things from the github issue ontsdx
library but nothing seems to workjaredpalmer#91
What i have tried
src
are treated as external: support TS Paths aliases jaredpalmer/tsdx#91 (comment)Your environment
The text was updated successfully, but these errors were encountered: