Git Product home page Git Product logo

example-yarn-package's Introduction

This is an example package that can be used to test Yarn.

It has the common default fields in its package.json, along with production and development dependencies as well that are specific to the package we have created.

The package.json

Default Package Fields

yarn init produces a default package.json similar to:

{
  "name": "example-yarn-package",
  "version": "1.0.0",
  "description": "An example package to demonstrate Yarn",
  "main": "index.js",
  "repository": {
    "url": "github.com/yarnpkg/example-yarn-package",
    "type": "git"
  },
  "author": "Yarn Contributors",
  "license": "BSD-2-Clause",
}

Custom Package Fields

You can add custom fields to your package.json as well. In our case, we have added 4 custom fields.

The scripts field are for any special scripts that you want to use when running yarn. For example, here we add a script called test that calls the Jest test runner because we added Jest tests to our Yarn package.

"scripts": {
  "test": "jest"
},

The dependencies field lists the other packages that this package is dependent upon. Our example package is dependent on Lodash since we use its multiply function.

"dependencies": {
  "lodash": "^4.16.2"
},

The devDependencies field lists the other packages that this package is dependent upon during development. Our example package is dependent on Jest since we created some Jest-enabled tests for our package.

"devDependencies": {
  "jest-cli": "15.1.1"
},

The jest field is a custom field specific to the Jest package we included as a dev dependency. In this case, we are testing in a node environment at the command-line.

"jest": {
  "testEnvironment": "node"
}

It is important to note that Lodash and Jest are not required for Yarn. They are just examples of what can be used when you are creating the code for your Yarn package.

Development

$ yarn install
$ yarn run test

Production

$ yarn install --production

example-yarn-package's People

Contributors

jamiebuilds avatar joelmarcey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.