-
Notifications
You must be signed in to change notification settings - Fork 45
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
Typescript Path Mapping #1082
Comments
TypeScript compilation doesn't change the the import's. The path mapping feature is just really a dev time thing, so one needs to do the runtime mapping depending on the platform. In node.js, one way to do would be to use the module.exports = function(wallaby) {
var path = require('path');
process.env.NODE_PATH +=
path.delimiter + path.join(wallaby.projectCacheDir, 'client/components') +
path.delimiter + path.join(wallaby.projectCacheDir, 'domain');
return {
...
}
} |
Thanks for the help! I had to tweak your supplied code to reference the wallaby project cache, instead of the local project directory. My version of what you supplied looked like this:
|
Awesome, thanks for the update! Have updated my answer to use |
I just run on the same issue, and find out more stable solution // ./wallaby-paths.js
const tsConfigPaths = require('tsconfig-paths');
const tsconfig = require('./tsconfig.json');
tsConfigPaths.register({
baseUrl: tsconfig.compilerOptions.baseUrl,
paths: tsconfig.compilerOptions.paths
}); add // ./wallaby.js
...
env: {
type: 'node',
params: {
runner: '-r ' + path.join(__dirname, './wallaby-paths.js')
}
},
... this way you manage your BTW |
@myflowpl Awesome, thanks for the post. We have added the docs section describing various ways to handle the scenario. BTW, I think you can implement your idea without an additional file, just with the |
@ArtemGovorov it's awesome, really clear solution, thanks |
The above solutions didn't seem to work for me in combination with either this workaround that I have implemented or with my setup. After some struggling I came up with this solution, hope it will help anyone:
In short I added 2 new pieces (highlighted with a comment):
This is used to be replaced by the second piece (like the original workaround does with the packages).
This adds the paths (aliases) inside my EDIT: A little off-topic but maybe interesting for those implementing my workaround; To make this work nicely with my IDE I also had to add the following config to my
|
Issue description or question
Since updating my project to use Typescript 2's Path Mapping feature, wallaby reports 'cannot find modules' errors suggesting that the 'paths' part of my tsconfig isn't being used properly (or something like that). In the error below, 'hex' module is on physical path /domain/hex/hex, aliases to /hex/hex in the tsconfig.
Note that if I change the path to 'domain/hex/hex', it works - so 'baseUrl' seems to be working, but not the mapped paths. Details below, thanks!
Wallaby TS version:
the relevant line in the test file:
tsconfig.json configuration file
Wallaby.js configuration file
Code editor or IDE name and version
Sublime Text v3
OS name and version
Windows
The text was updated successfully, but these errors were encountered: