Skip to content

Add npm package cookbook entry #664

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

Closed
wants to merge 13 commits into from
Closed

Add npm package cookbook entry #664

wants to merge 13 commits into from

Conversation

sdras
Copy link
Member

@sdras sdras commented Oct 31, 2020

Reworked some of this during the migration- will likely take another pass at updating it soon as well :)

@sdras sdras added content Issues / PRs related to docs content cookbook and removed review-alert-box labels Oct 31, 2020
@subdavis
Copy link

subdavis commented Oct 31, 2020

Would adding a section about typescript be out of scope here? "Packaging your typescript SFCs for NPM" is still a little hard to find details about, and this guide is already like 80% of the way there.

https://github.com/politico/vue-accessible-selects/blob/main/rollup.config.js is a great minimal example that was shared with me recently.

Another section with an updated rollup config that basically explains how types/index.d.tsgets created and some other nuance could be handy?

If this is out of scope for this cookbook, what would be the best place to put this info, and would a PR be welcome?

}),
buble() // Transpile to ES5
]
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about mentioning the external configuration param here? At a minimum, almost all users are going to want external: ['vue'], right? The ESM guide on freecodecamp above also doesn't mention this.

Because this guide covers all types of builds, I'm not sure how to best mention this, but I can see it being a stumbling block for readers of this guide.

Copy link
Contributor

@skirtles-code skirtles-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware that this is mostly just copied from the Vue 2 docs but I've provided feedback on anything that caught my eye.


### How does npm know which version to serve to a browser/build process?

The `package.json` file used by npm really only requires one version (`main`), but as it turns out, we aren't limited to that. We can address the most common use cases by specifying 2 additional versions (`module` and `unpkg`), and provide access to the `.vue` file itself using the `browser` field. A sample package.json would look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear what the convention is for putting filenames in backticks. package.json is mentioned several times in this page, sometimes with backticks and sometimes without.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried catching them all, can give it another lookthrough. It's a good point we should make a convention around this and put it in the writing guide. In this case, I felt like it was hard to read without the distinction but could be persuaded.

@sdras
Copy link
Member Author

sdras commented Nov 1, 2020

Would adding a section about typescript be out of scope here? "Packaging your typescript SFCs for NPM" is still a little hard to find details about, and this guide is already like 80% of the way there.

https://github.com/politico/vue-accessible-selects/blob/main/rollup.config.js is a great minimal example that was shared with me recently.

Another section with an updated rollup config that basically explains how types/index.d.tsgets created and some other nuance could be handy?

If this is out of scope for this cookbook, what would be the best place to put this info, and would a PR be welcome?

@subdavis, we would love a PR for this! I mentioned to the team that I was bringing this over as a first pass, to then be refactored and reworked. What works best for you? I guess my preference is to work iteratively, where we PR this first pass in and you follow it up with improvements and new sections, but I'm flexible.

@subdavis
Copy link

subdavis commented Nov 1, 2020

Adding a typescript section as an independent PR sounds great since it's new content. I'll follow up with something after this merges. Thank you.

install
}

// Auto-install when vue is found (eg. in browser via <script> tag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Vue now provides its global API for component registration etc. on an app instance, not the constructor, auto-install is no longer possible in Vue 3

@sdras
Copy link
Member Author

sdras commented Dec 26, 2020

I've thought a lot about this entry, and I think enough has changed is new, that it can't simply be migrated, we need to rewrite it. I'm going to close it out now.

@sdras sdras closed this Dec 26, 2020
@NataliaTepluhina NataliaTepluhina deleted the sd/npm-cookbook branch February 24, 2021 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues / PRs related to docs content cookbook
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants