3

Nrwl says ask here. Looks like I'm first!

I goofed. I created a project called Angular with the nx schematics. I want to rename the namespace, if that is possible, so that I can access my libraries like:

import {MyLibrary} from '@MyNamespace/my-library/';

Instead of:

import {MyLibrary} from '../../../../../../../..........';

I tried changing the project name in angular-cli.json and package.json, but I was pretty sure that wasn't the answer.

Also, nx will not work as a tag because it is already used elsewhere. I'm proposing nrwl-nx.

Edit: Scratch that. I don't have enough reputation to create a new tag. Kudos if you want to be the first!

Kim Kern
  • 54,283
  • 17
  • 197
  • 195
wolfhoundjesse
  • 1,085
  • 9
  • 32
  • The tag makes no sense because there's nothing to tag. @nrwl/nx isn't that popular. And it's not obvious that the question is specific to it. See https://stackoverflow.com/questions/41460810/avoiding-relative-paths-in-angular-cli for CLI-specific and https://stackoverflow.com/questions/42749973/es6-import-using-at-sign-in-path-in-a-vue-js-project-using-webpack for Webpack-specific solutions. – Estus Flask Oct 20 '17 at 14:02
  • Possible duplicate of [Avoiding relative paths in Angular CLI](https://stackoverflow.com/questions/41460810/avoiding-relative-paths-in-angular-cli) – Estus Flask Oct 20 '17 at 14:03
  • So, just to be sure I understand: if a question is about something that isn't popular yet, it doesn't need a tag? I'm only following the contribution guidelines by posting here: https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md – wolfhoundjesse Oct 21 '17 at 14:44
  • Considering that there are virtually no existing questions on the subject and no reason to expect them soon, the tag isn't needed. Otherwise the site would be bloated with a million of tags for each and every library that will never be used twice. These guidelines are preemptive and were pasted from some successful library. For smaller projects that don't have the community the maintainers usually don't protest against the appearance of questions in repo issues, since it's the only way for them to provide support for the project and make it user-friendly. – Estus Flask Oct 21 '17 at 15:24

1 Answers1

7

Perhaps it is my question asking skills that need work, as the solution was very simple. Because I named my project Angular, my tsconfig.json file had this entry:

"paths": {
    "@Angular/*": [
        "libs/*"
    ]
}

If you name your project folder one thing, but want to reference your library from another, this is where it is configured. I changed @Angular to @MyLibrary, and now my imports are import {SomeModule} from '@MyLibrary/some-module';

wolfhoundjesse
  • 1,085
  • 9
  • 32