A scaffolding for generating a framework of npm module.
The module is based on template, welcome to add more templates.
Integrated:
- Code lint (eslint + prettier)
- Unit test support, there is a basic test file
./test/index.spec.js
- Rollup configured (So you don't worry about the code compiling)
- Typescript support,
index.d.ts
will be generate by run commandnpm run build:dts
- Demo support, you can modify it or src code and see the changes in real time by running command
cross-env PORT=3000 npm run dev
- Vue/React component development support
https://github.com/livelybone/-livelybone-npm-module-generator.git
npx Recommend
npx @livelybone/npm-module-generator [directory] [--template] [cmd]
If you've previously installed @livelybone/npm-module-generator globally via
npm install -g @livelybone/npm-module-generator
, we recommend you uninstall the package usingnpm uninstall -g @livelybone/npm-module-generator
to ensure that npx always uses the latest version.
npm
# npm global install
npm i -g @livelybone/npm-module-generator
module-generator [directory] [--template] [cmd]
This can not ensure that the module is up to date
npx @livelybone/npm-module-generator vue-component-dir --vue
npx @livelybone/npm-module-generator vue-component-dir --vue-ts
npx @livelybone/npm-module-generator react-component-dir --react
npx @livelybone/npm-module-generator react-component-dir --react-ts
npx @livelybone/npm-module-generator module-dir --js
npx @livelybone/npm-module-generator module-dir --ts
npx @livelybone/npm-module-generator -v
Argument | Default | Description |
---|---|---|
directory |
none | Optional. Dirname of the module |
template |
js |
Optional. Chose template, options: ['js', 'vue', 'react', 'ts', 'vue-ts', 'react-ts'] |
cmd |
none | Optional. -v --v -version --version -> version; --un-git -un-git -> disabled git init; -i --i -install --install -> enable npm install |
project-name
: The name of the module will be used in npm, likenpm i [your-preject-name]
global-name
: The variable the module exported inumd
bundle
description
: Description of the module
repository
: Repository of the module
keywords
: Keywords of the module
bugsUrl
: Where to submit bugs of the module
author
: Author of the module
homepage
: The url of the demo or homepage. We may prefer demo address
Use the command npm run dev
in the module you generated to develop it,you can see the changes by refreshing the demo page
- I modified the source code, but never see the changes in the demo page in running
npm run dev
Maybe you should open the chrome dev-tool,and check
Disable cache
option
- The module I generated has no command
npm run build:dts
, so I cannot generateindex.d.ts
The three templates
'js', 'vue', 'react'
do not support for generatingindex.d.ts
temporarily,please update youindex.d.ts
file manually
- update typescript version to support optional chaining
- add es6 building support