Skip to content
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

Add sections on creating an npm package and overriding a published one #381

Merged
merged 4 commits into from Apr 16, 2016

Conversation

@lorensr
Copy link
Collaborator

commented Apr 16, 2016

The previously linked npm explanation of creating an npm package is heavyweight for a Meteor dev's purposes (and doesn't cover the common case of private code). Using their method, you need to publish and update after each change. A Meteor dev is usually creating a package in support of their app, and is usually developing it inside the app, so using source control makes more sense. Also, the source control way is more familiar coming from packages/.

Also fixes #378

git add -f node_modules/left_pad/
```

Now you can edit the package, commit, and push, and your teammates will get your version of the package. To ensure that your package doesn't get overwritten during an `npm update`, change the default caret version range in your `package.json` to an exact version. Before:

This comment has been minimized.

Copy link
@lorensr

lorensr Apr 16, 2016

Author Collaborator

Should the package name be changed instead of using exact version?

This comment has been minimized.

Copy link
@tmeasday

tmeasday Apr 16, 2016

Contributor

Alternatively the package could be removed completely from the package.json (although that won't help with dependencies)

This comment has been minimized.

Copy link
@tmeasday

tmeasday Apr 16, 2016

Contributor

Another option is to set it to a path. Maybe this is better?

https://docs.npmjs.com/files/package.json#local-paths

When you are developing a new npm package for your app, there are a couple ways to include the package in your app:

1. Place the package in your app's `node_modules/` directory, and add the package to source control. Do this when you want everything in a single repository.
1. Place the package outside your app's directory in a separate repository and use `npm link`. Do this when you want to use the package in multiple apps.

This comment has been minimized.

Copy link
@tmeasday

tmeasday Apr 16, 2016

Contributor

Can we link to the docs for npm link? Also I think it's important to mention this won't go out to others developing your app.


To publish publicly, [follow these instructions](https://docs.npmjs.com/getting-started/publishing-npm-packages). When you're done, anyone can add your package to their app with `npm install --save your-package`.

If you want to share packages during development, we recommend using source control instead of the registry. If you use the registry, then every time you change the package, you need to increment the version number, publish, and then `npm update my-package` inside your app.

This comment has been minimized.

Copy link
@tmeasday

This comment has been minimized.

Copy link
@lorensr

lorensr Apr 16, 2016

Author Collaborator

I was actually referring to the two inclusion methods explained above. Will clarify

@tmeasday

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2016

Thanks a lot @lorensr! I think this is useful stuff.

I made a few comments. I do just wonder if the best practice is to commit things in node_modules/ or a file:// dependency to another directory.

@lorensr

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 16, 2016

Thanks! That would be better for avoiding npm overwriting, but where should they go? packages/? In which case the dependency would be "my-package": "file:packages/my-package"

They shouldn't interfere w/ atmo packages because they don't have a package.js? But it might be nice for a dev to be able to know which type of package they are without looking for a package.js. Maybe packages/npm/my-package/ or private/npm/? Will meteor follow a file dep in package.json into private/*?

@tmeasday

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2016

Oh, yeah, putting in another directory is a bad idea because it'll stuff up node's loading (like you'll need to require('path/to/package') rather than require('package')). Scratch that.

@lorensr

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 16, 2016

Ah, got it.

Finished changes.

@tmeasday

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2016

Great work!

@tmeasday tmeasday merged commit 763fb95 into meteor:master Apr 16, 2016

2 checks passed

CLA Author has signed the Meteor CLA.
Details
ci/circleci Your tests passed on CircleCI!
Details
@stubailo

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2016

Awesome contribution!

@lorensr

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 16, 2016

Thanks!

On Saturday, April 16, 2016, Sashko Stubailo notifications@github.com
wrote:

Awesome contribution!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#381 (comment)

@lorensr lorensr deleted the lorensr:creating-npm branch Apr 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.