Skip to content

Stub dist link your project based on package.json during the development

License

Notifications You must be signed in to change notification settings

zhengyuzi/stubb

Repository files navigation

stubb

npm NPM

Stub dist link your project based on package.json during the development.

Install

npm install --save-dev stubb

Usage

In the 'package.json' of the package in need:

{
  "main": "dist/index.cjs",
  "module": "dist/index.mjs",
  "types": "dist/index.d.ts",
  "scripts": {
    "stub": "stubb"
  }
}

Generate folders and files based on the main, module, types and exports in package.json.

Default project structure:

|-- package
    |-- dist/
        |-- index.cjs
        |-- index.mjs
        |-- index.d.ts
    |-- src/
        |-- index.ts
    |-- package.json

Add entry in the exports field to modify the entry file:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs",
      "entry": "./test/index.ts"
    }
  },
  "main": "dist/index.cjs",
  "module": "dist/index.mjs",
  "types": "dist/index.d.ts",
  "scripts": {
    "stub": "stubb"
  }
}

if exposing multiple entry points:

{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    },
    "./plugins": {
      "types": "./dist/plugins.d.ts",
      "import": "./dist/plugins.mjs",
      "require": "./dist/plugins.cjs"
    }
  },
  "main": "dist/index.cjs",
  "module": "dist/index.mjs",
  "types": "dist/index.d.ts",
  "scripts": {
    "stub": "stubb"
  }
}

About

Stub dist link your project based on package.json during the development

Resources

License

Stars

Watchers

Forks

Packages

No packages published