-
Notifications
You must be signed in to change notification settings - Fork 9
Dont use package scope everywhere #59
Comments
I can fix it and send you a pull request, but expect it this evening, since I'm currently in the middle of sth. |
Ah, yes, I wasn't originally supporting scoped packages, but this is the 3rd or 4th person to mention it, so looks like it's worth investing time in. Also #58 looks related. |
@nvdnkpr I'm going to take this one because I think there are a few more things to consider than just how the package name is utilized for building the scaffolded module. Just an FYI, we'll still be using the right side of the The build for scoped packages will be slightly different. And it would provide the following to consumers of the package:
The entry points & typings in {
"es2015": "./bundles/cool-package.js",
"main": "./bundles/cool-package.umd.js",
"module": "./@myScope/cool-package.es5.js",
"typings": "./@myScope/cool-package.d.ts"
} Where a unscoped package (e.g. in the
The entry points & typings in {
"es2015": "./bundles/cool-package.js",
"main": "./bundles/cool-package.umd.js",
"module": "./cool-package.es5.js",
"typings": "./cool-package.d.ts"
} This seems to be inline with how the APF is spec'd. |
This is good, too, because it takes the project in a direction to be able to support monorepos! |
No migration strategy yet...now libraries can have a scoped package name (a la @myscope/my-package) and the library will build in line with the APF
@nvdnkpr & @tommueller, would either (or both) of you be interested in testing the feature before I publish it? It's a significant change, so I want to make sure it works. |
I will help wherever I can! I cannot really follow the code here though, so I don't know how much I can assist you, but I can test if my project works with the fixed version. |
@gonzofish Hello Matt, So please first fix the error and then we can all help you make your library capable of multi-modules, sth that I the other libraries struggle with. |
@nvdnkpr my fix is purely aimed at fixing the error you described! I was just mentioning that it is a step towards multi-modules & monorepo support. Also thank you for the offer to help get If either of you are interested in helping, here's how you can test! Install the Branch Version
npm rm angular-librarian
{
"devDependencies": {
"angular-librarian": "https://github.com/gonzofish/angular-librarian.git#scoped",
}
}
Verify the Branch is InstalledYour project should now be set up to use the scoped branch version of
const checkIsDashFormat = (value) =>
!!value && typeof value === 'string' &&
value.length > 0 &&
value.match(/^[a-z][a-z0-9]*(\-[a-z0-9]+)*$/i);
exports.checkIsDashFormat = checkIsDashFormat;
exports.checkIsScopedName = (name) =>
// @
// followed by 1+ non-/
// followed by /
// folloer by 1+ non-/
/^@[^/]+[/][^/]+$/.test(name); If so, you have the branch version! If not, let me know and I'll try to help. Use the LibraryRun Now try the same commands you're used to using with To test that a build works without publishing run: npm run build If it succeeds, that's a good indicator that the code is working. Check the files output in |
Ok I just did that with a copy of my project and here are my results ;) :
Thanks a lot! |
@tommueller Ah, great to hear! Sorry for omitting such a critical step in getting it usable. The output is exactly what we're looking for, too. That lines up with how the Angular Package Format is described. Were you able to use it in a CLI project by any chance? @nvdnkpr were you going to take a stab at it? If so, let me know if it worked. If not, let me know, too, so I can close this issue. Thanks! |
I will try to use it in a CLI project tomorrow and let you know! |
Thanks, @tommueller, it's worked for me, hopefully it'll work for you too! |
A second issue is, that the |
Ok let me look into this. You're being a massive help by testing this for me. Your reports are very nicely detailed, too. |
Sure, now worries. You created a great tool that I can use ... ;) I will be off for holidays by this evening, so I will only be back to investigate further on this by Monday the 7th! |
Is Enjoy your holiday! |
that means that if I used
That is working, when I installed the #scoped-branch and ran |
Ah, shoot, yes. Take a look at the Also, good to hear about |
Okay one step further :) The Also I have one last entry in my package.json which contains an old link to |
Can I see the generated
I just did this and I was able to run |
I just tried to |
Oh no :) Btw. I get a lot of these warnings while building the project
|
This is the
|
I bet what happened is this: the What you can do is modify the real
|
I was just editing the comment: |
Those If you open |
Here's why: when we publish a library, we want to consuming app/library to be in charge of the versions of dependencies so that project-wide, all other libraries/dependencies use the same version. We wouldn't want to specify However, when we're developing, we need those dependencies installed, so the root The advice of using |
Ok. I was just able (after dirty-fixing the peerDependencies) to import the lib into CLI-project and successfully run |
concerning the peerDependencies. As far as I understood, you have to have them both as dependencies and peerDependencies because npm does not install peerDependencies automatically anymore. And that solves my problem, because then can just remove my peerDepencies entry, because they are duplicated in depencies anyway. So instead of replacing dependecies with peerDependencies you should copy it, I think! edit: This article was what I read about it back then: https://codingwithspike.wordpress.com/2016/01/21/dealing-with-the-deprecation-of-peerdependencies-in-npm-3/ |
What are you suggesting be copied? |
Copy the dependencies and insert them both as |
allright. my project is up and running again (right now I still have to manually repair the thanks a lot for the support! and see you in 2 weeks! |
also failed for me 😭 The package name is without the |
Heya, just wanted to chime in: you definitely don't want to add This is important because you really don't want to ever have two copies of them. It's true that if you don't have them in dependencies you aren't guaranteed to have them installed in the consuming package... but that is the point. You don't want to install them. You want to assert they already exist - and that's what Also, there's a detailed guide in https://github.com/angular/angular-cli/wiki/stories-linked-library about how to link libraries. Hope it helps. |
Hey @filipesilva, thanks for chiming in! The idea is that the published module will have |
Heya @gonzofish 👋 I think your approach is good, I was replying to @tommueller's #59 (comment). |
Got it, by the way, thanks for that document as well as your filipesilva/angular-quickstart-lib those two things helped me big time in better understanding how to structure Angular library projects |
Very happy to hear you found it useful! It took me a while to get my head around it as well, it's not very straightforward but there's definitely a reason for everything. |
@gonzofish Sorry for my late reply, I'm currently finishing a project so if I get to it in time I'll rework through the work you and @tommueller have done so far to give you feedback. |
Hey, no problem @nvdnkpr! You're doing me a favor. Any additional feedback is great, but no worries |
@tommueller I've just discovered what the issue was with running The |
For anyone interested, the following package--produced using Angular Librarian--works with the CLI: https://www.npmjs.com/package/@angular-librarian/scoped-lib |
I'm confident this is working, so I'm going to close. If anyone would be interested in testing for me, please point your angular-librarian install to the master branch: {
"devDependencies": {
"angular-librarian": "https://github.com/gonzofish/angular-librarian.git",
}
} And run through the motions. If you reinitialize your project, make sure that you set angular-librarian back to the master branch and redo |
Sorry I have not been online the last 2 weeks! Thanks for the great work and finishing up on this! I will go on trying the upgrading ASAP. |
When initializing with npm one can have an (optional) scope along side the command.
e.g. running
npm init -f --scope myScope
in a directoryMyPackageName
leads then to a package name@myScope/MyPackageName
which is also used for the main module's class name when running the followingngl i
Unfortunately this includes the leading @ from the Scope and the seperator / which Typescript both doesn't allow for class names.
But the solution is easy: Drop the / and the @ and capitalize (I mean the lodash function) the rest which then would lead to a class name
MyScopeMyPackageName
The text was updated successfully, but these errors were encountered: