Skip to content

Commit 0cc0b9f

Browse files
committed
feat: prepare for pre-extract common vender
1 parent eac66ed commit 0cc0b9f

File tree

10 files changed

+44
-18
lines changed

10 files changed

+44
-18
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"dayjs": "^1.11.2",
4+
"lodash": "^4.17.21",
5+
"wx-server-sdk": "^2.6.1"
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"external": ["dayjs", "lodash", "wx-server-sdk"]
3+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"main": "dist/index.js",
66
"types": "dist/types/index.d.ts",
77
"scripts": {
8+
"dev": "yarn clear && cross-env SOURCEMAP=1 rollup -cw",
89
"build": "yarn clear && rollup -c",
9-
"build:map": "yarn clear && cross-env SOURCEMAP=1 rollup -c",
1010
"build:tsc": "tsc -p tsconfig.build.json",
1111
"watch": "tsc -w -p tsconfig.build.json --sourcemap",
1212
"test": "yarn build && jest",

src/extract.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { promises as fs } from 'fs'
2+
import path from 'path'
3+
import { log } from './util'
4+
async function extractNodeModules (dependencies: string[], cwd = process.cwd()) {
5+
const tempDir = path.resolve(cwd, '.stcb')
6+
try {
7+
await fs.access(tempDir)
8+
} catch (error) {
9+
log.success(
10+
'create temp dir [.stcb] , you should add this dir to your .gitignore'
11+
)
12+
await fs.mkdir(tempDir)
13+
}
14+
}
15+
16+
export { extractNodeModules }

src/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async function copyAllTemplete(dest: string, projectName?: string) {
6969
r('./src/common/simple.json'),
7070
jsonStringify({
7171
ignore: true,
72-
externals: [],
72+
external: [],
7373
})
7474
);
7575
}

src/templete/cloudbaserc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getFunctions, jsonStringify, log } from '../util'
88

99
export interface ISimpleJsonConfig {
1010
ignore?: boolean
11-
externals?: []
11+
external?: []
1212
}
1313

1414
export const baseOption: ICloudBaseConfig & { version: string } = {

src/type.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export interface ISimpleJsonConfig {
2+
ignore?: boolean
3+
external?: []
4+
}
5+
6+
export type IBuiltinOption = {
7+
path: string
8+
name: string
9+
extra?: ISimpleJsonConfig & {
10+
[key: string]: any
11+
}
12+
}

src/util.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
import fs, { promises as fsp } from 'fs'
22
import path from 'path'
33
import consola from 'consola'
4-
4+
import type { IBuiltinOption, ISimpleJsonConfig } from './type'
55
export const log = consola
6-
export interface ISimpleJsonConfig {
7-
ignore?: boolean
8-
externals?: []
9-
}
10-
11-
export type IBuiltinOption = {
12-
path: string
13-
name: string
14-
extra?: ISimpleJsonConfig & {
15-
[key: string]: any
16-
}
17-
}
186

197
export function resolve (...pathSegments: string[]) {
208
return path.resolve(...pathSegments)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"ignore": true,
3-
"externals": []
3+
"external": []
44
}

website

0 commit comments

Comments
 (0)