-
-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Thanks for this plugin!
I noticed that I have to add a dummy "paths": { "*": ["*"] }
entry to tsconfig to make the transformer work. Without it, the module does nothing:
// tsconfig.json (no "paths" at all)
"baseUrl": "src"
"plugins": [{ "transform": "typescript-transform-paths" }],
// src/main.ts
import { app } from "electron"; // a module in node_modules
import { setMenu } from "main/menu"; // src/main/menu.ts; no syntax errors for tsc/vscode
// output:
const electron_1 = require("electron"); // correct
const menu_1 = require("main/menu"); // <-- INCORRECT, NOT ./main/menu
Adding a dummy entry "paths": { "*": ["*"] }
solves the problem.
My IMHO is following: it's a little strange to require "paths" to be present in tsconfig.json. I think in an ideal world, the transform plugin should do exactly the same as TS does when it interprets the entire configuration. If TS understands just baseUrl and shows no syntax errors in both tsc and in VSCode, if it allows to do import from "xyz/abc" where xyz is located in baseUrl, then the transform plugin should do no worse than that. (And I also think that in an ideal world, tsc should have a config option to alter paths natively; although I read their arguments, they still look very weak to me.)