-
Notifications
You must be signed in to change notification settings - Fork 16
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
[FEATURE REQUEST] Support typescript path mapping #137
Comments
Shouldn't that read |
Hi @texttechne, Actual it needs to work together with baseUrl parameter. In a UI5 app, the configuration may look like this:
|
Hi @slin-sap, actually your issue is not related to this babel plugin in any case. If you would have an issue with this plugin you would need to show that the transpilation fails or that the transpiled result is wrong... So you're actually fighting with UI5 here. When I generate a new ts-app with easy-ui5 I already get what you want. I named the app "myapp" and the generated {
"compilerOptions": {
...
"paths": {
"myapp/*": ["./webapp/*"],
"unit/*": ["./webapp/test/unit/*"],
"integration/*": ["./webapp/test/integration/*"]
}
}
...
} However, this only works in combination with
In other word, you have to maintain that mapping in two places. But then it works. Regarding
|
Hi @texttechne This still doesn't work as I expected.
E.g. In a folder When I need to import function from module |
Yes, UI5 requires you to put this one mapping from app name to
Can you import from index files in UI5 in plain JS? How would that look like? As second step, check the result of the transpilation process for yourself: Execute a build and look into the transpiled JS files of your webapp. By the way, you can use a path mapping as workaround in this case 😁 |
In tsconfig.json, it is possible to add a path mapping configuration like this.
It help to avoid writing deep relative import path. E.g.
import { getMyUtility } from "@/utils";
instead ofimport { getMyUtility } from "../../../../utils";
But this feature is not supported by babel-plugin-transform-modules-ui5 at runtime when running ui5 serve on dev mode. The transpiled UI5 code resource treats such imports as an url path that contains '@/utils' and thus failed to load the resource.
It would be great to support path mapping for both dev mode and production bundling.
The text was updated successfully, but these errors were encountered: