TeamMaestro / angular-native-seed

Build web apps and NativeScript applications from one codebase using the AngularCLI.
265 stars 71 forks source link

Unable to create absolute path or alias on import. #52

Closed bori87 closed 7 years ago

bori87 commented 7 years ago

I am trying to set up an alias for my common module directory. I want import { RouterModule } from '~app/common'; instead of import { RouterModule } from '../common'; How can i achieve this? I have tried to add alias in webpack.config.js but compiler is looking for module relative to "app/tns_modules/". emu

sean-perkins commented 7 years ago

The tilde on an import will signify importing a module from node_modules, not your app directory. You should be able to create a webpack alias and import from app/common, assuming you have an index.ts in that file location.

Take a peak at this issue for more information: https://github.com/angular/angular-cli/issues/5031

Let me know if that help resolves your question.

donburgess commented 7 years ago

Currently the tsconfig we have for ~ is set to recognize ~/ in webpack. Perhaps this should not include the / though?