Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xhmm/funpack
Funpack is a bundler specifically for better writing cloud functions(aka, a project that has multi entrypoints).
https://github.com/xhmm/funpack
cloudfunction wechat-mini-program
Last synced: 24 days ago
JSON representation
Funpack is a bundler specifically for better writing cloud functions(aka, a project that has multi entrypoints).
- Host: GitHub
- URL: https://github.com/xhmm/funpack
- Owner: XHMM
- Created: 2022-08-23T11:57:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-23T18:13:59.000Z (over 2 years ago)
- Last Synced: 2024-08-09T07:32:13.740Z (5 months ago)
- Topics: cloudfunction, wechat-mini-program
- Language: TypeScript
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
FunPack
Funpack is a bundler specifically for better writing cloud functions(aka, a project that has multi entrypoints). It allows you to share common logic between isolated functions, and have a better development experience.
## Basic
Your project folder should follow this structure:
```
root
├── funpack.config.js
├── package.json
├── src
│ ├── functions
│ │ ├── register
│ │ │ ├── config.json
│ │ │ └── index.ts
│ │ └── user-info
│ │ ├── config.json
│ │ └── index.ts
│ ├── types.ts
│ └── utils.ts
└── tsconfig.json```
- `funpack.config.js`: config file for `funpack`
- `src/functions`: all your functions are under this folder
- `src/functions/[fnName]/index.ts`: function entry file
- `src/functions/[fnName]/[non-ts-file]`: any non-ts file will be copied to output without modify
- `src/[shardFile].ts`: shard files should be outside of functions folder## Install
Install with npm:
```shell
npm install --save-dev @funpack/cli
```Install with yarn:
```shell
yarn add @funpack/cli --dev
```## Templates
- [wxmini-cloud](/packages/create-funpack/template-wxmini-cloud): a template for wechat miniprogram cloud functions development## References
### Commands
- `funpack --watch`: Build and watch functions
- `funpack`: Build functions (Set `process.env.NODE_ENV` to 'production' if you want production build)### `funpack.config.js`
This file need export default a config object:
```typescript
interface UserFunpackConfig {
output?: {
/**
* functions will output to `projectRoot/[dir]/functions`
*
* default: dist
*/
dir?: string;
/**
* soucemap config, check https://webpack.js.org/configuration/devtool/#devtool for available values
*
* default: NODE_ENV == 'production' ? "hidden-source-map" : "eval-source-map"
* */
sourceMap?: string | false;
};
bundle: {
/**
* config output strategy
* if true, node modules used by function will be bundled,
* if false, package.json will be generated under every function
*
* default: true
*/
singleFile?: boolean;
};
}
```