lvyjs 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +6 -1
- package/lib/build/get-files.d.ts +8 -0
- package/lib/build/get-files.js +20 -19
- package/lib/build/rullup.d.ts +17 -0
- package/lib/build/rullup.js +100 -111
- package/lib/index.d.ts +1 -1
- package/lib/index.js +33 -35
- package/lib/loader/esbuild.d.ts +8 -0
- package/lib/loader/esbuild.js +5 -23
- package/lib/loader/index.js +2 -0
- package/lib/plugins/index.d.ts +23 -2
- package/lib/plugins/loader-css.d.ts +7 -5
- package/lib/plugins/loader-files.d.ts +5 -5
- package/lib/store.d.ts +85 -85
- package/lib/store.js +24 -25
- package/package.json +1 -1
- package/lib/loader/index.d.ts +0 -15
package/bin/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { fork } from 'child_process'
|
|
3
3
|
import { join, dirname, relative } from 'path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { existsSync } from 'fs'
|
|
5
6
|
const args = [...process.argv.slice(2)]
|
|
6
7
|
const currentFilePath = fileURLToPath(import.meta.url)
|
|
7
8
|
const currentDirPath = dirname(currentFilePath)
|
|
@@ -35,7 +36,11 @@ if (args.includes('build')) {
|
|
|
35
36
|
jsdir,
|
|
36
37
|
'--lvy-dev'
|
|
37
38
|
]
|
|
38
|
-
|
|
39
|
+
let tsxDir = join(currentDirPath, '../../tsx/dist/cli.mjs')
|
|
40
|
+
if (!existsSync(tsxDir)) {
|
|
41
|
+
tsxDir = join(currentDirPath, '../node_modules/tsx/dist/cli.mjs')
|
|
42
|
+
}
|
|
43
|
+
const msg = fork(tsxDir, [...argv, ...argsx], {
|
|
39
44
|
stdio: 'inherit',
|
|
40
45
|
env: Object.assign({}, process.env, {
|
|
41
46
|
PKG_DIR: pkgFilr
|
package/lib/build/get-files.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
import { readdirSync } from 'fs'
|
|
1
|
+
import { join } from 'path'
|
|
2
|
+
import { readdirSync } from 'fs'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 获取指定目录下的所有 ts、js、jsx、tsx 文件
|
|
6
6
|
* @param dir 目录路径
|
|
7
7
|
* @returns 文件路径数组
|
|
8
8
|
*/
|
|
9
|
-
const getFiles =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
const getFiles = dir => {
|
|
10
|
+
const results = []
|
|
11
|
+
const list = readdirSync(dir, { withFileTypes: true })
|
|
12
|
+
list.forEach(item => {
|
|
13
|
+
const fullPath = join(dir, item.name)
|
|
14
|
+
if (item.isDirectory()) {
|
|
15
|
+
results.push(...getFiles(fullPath))
|
|
16
|
+
} else if (
|
|
17
|
+
item.isFile() &&
|
|
18
|
+
/\.(ts|js|jsx|tsx)$/.test(item.name) &&
|
|
19
|
+
!item.name.endsWith('.d.ts')
|
|
20
|
+
) {
|
|
21
|
+
results.push(fullPath)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
return results
|
|
25
|
+
}
|
|
25
26
|
|
|
26
|
-
export { getFiles }
|
|
27
|
+
export { getFiles }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 打包 JS
|
|
3
|
+
* *** 注意 **
|
|
4
|
+
* 和initConfig配合使用
|
|
5
|
+
* **
|
|
6
|
+
* 确保已经初始化了配置
|
|
7
|
+
* @param inputs
|
|
8
|
+
* @param output
|
|
9
|
+
*/
|
|
10
|
+
declare const buildJS: (inputs: string[], output: string) => Promise<void>
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param script
|
|
14
|
+
*/
|
|
15
|
+
declare function buildAndRun(input: string, output: string): Promise<void>
|
|
16
|
+
|
|
17
|
+
export { buildAndRun, buildJS }
|
package/lib/build/rullup.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { rollup } from 'rollup'
|
|
2
|
-
import { join } from 'path'
|
|
3
|
-
import typescript from '@rollup/plugin-typescript'
|
|
4
|
-
import commonjs from '@rollup/plugin-commonjs'
|
|
5
|
-
import json from '@rollup/plugin-json'
|
|
6
|
-
import styles from 'rollup-plugin-styles'
|
|
7
|
-
import { getFiles } from './get-files.js'
|
|
8
|
-
import alias from '@rollup/plugin-alias'
|
|
9
|
-
import { rollupStylesCSSImport } from '../plugins/loader-css.js'
|
|
10
|
-
import { rollupAssets } from '../plugins/loader-files.js'
|
|
1
|
+
import { rollup } from 'rollup'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import typescript from '@rollup/plugin-typescript'
|
|
4
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
5
|
+
import json from '@rollup/plugin-json'
|
|
6
|
+
import styles from 'rollup-plugin-styles'
|
|
7
|
+
import { getFiles } from './get-files.js'
|
|
8
|
+
import alias from '@rollup/plugin-alias'
|
|
9
|
+
import { rollupStylesCSSImport } from '../plugins/loader-css.js'
|
|
10
|
+
import { rollupAssets } from '../plugins/loader-files.js'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 用于忽略警告
|
|
@@ -15,10 +15,9 @@ import { rollupAssets } from '../plugins/loader-files.js';
|
|
|
15
15
|
* @param warn
|
|
16
16
|
*/
|
|
17
17
|
const onwarn = (warning, warn) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
18
|
+
if (warning.code === 'UNRESOLVED_IMPORT') return
|
|
19
|
+
warn(warning)
|
|
20
|
+
}
|
|
22
21
|
/**
|
|
23
22
|
* 打包 JS
|
|
24
23
|
* *** 注意 **
|
|
@@ -29,109 +28,99 @@ const onwarn = (warning, warn) => {
|
|
|
29
28
|
* @param output
|
|
30
29
|
*/
|
|
31
30
|
const buildJS = async (inputs, output) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (typeof global.lvyConfig.build[key] == 'boolean') {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (key === 'alias' && !global.lvyConfig.build['@rollup/plugin-alias']) {
|
|
43
|
-
plugins.push(alias(global.lvyConfig.build[key]));
|
|
44
|
-
}
|
|
45
|
-
else if (key === 'assets') {
|
|
46
|
-
plugins.push(rollupAssets(global.lvyConfig.build[key]));
|
|
47
|
-
}
|
|
48
|
-
else if (key === 'styles') {
|
|
49
|
-
plugins.push(styles({
|
|
50
|
-
mode: ['inject', () => '']
|
|
51
|
-
}));
|
|
52
|
-
plugins.push(rollupStylesCSSImport(global.lvyConfig.build[key]));
|
|
53
|
-
}
|
|
54
|
-
else if (key === 'commonjs' && !global.lvyConfig.build['@rollup/plugin-commonjs']) {
|
|
55
|
-
plugins.push(commonjs(global.lvyConfig.build[key]));
|
|
56
|
-
}
|
|
57
|
-
else if (key === 'json' && !global.lvyConfig.build['@rollup/plugin-json']) {
|
|
58
|
-
plugins.push(json(global.lvyConfig.build[key]));
|
|
59
|
-
}
|
|
60
|
-
else if (key === 'typescript' && !global.lvyConfig.build['@rollup/plugin-typescript']) {
|
|
61
|
-
plugins.push(typescript(global.lvyConfig.build[key]));
|
|
62
|
-
}
|
|
63
|
-
else if (key === 'plugins') {
|
|
64
|
-
if (Array.isArray(global.lvyConfig.build[key])) {
|
|
65
|
-
for (const plugin of global.lvyConfig.build[key]) {
|
|
66
|
-
plugins.push(plugin);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
const plugin = (await import(key)).default;
|
|
72
|
-
plugins.push(plugin(global.lvyConfig.build[key]));
|
|
73
|
-
}
|
|
31
|
+
if (!global.lvyConfig) global.lvyConfig = {}
|
|
32
|
+
if (!global.lvyConfig.build) global.lvyConfig.build = {}
|
|
33
|
+
// 插件
|
|
34
|
+
const plugins = []
|
|
35
|
+
for (const key in global.lvyConfig.build) {
|
|
36
|
+
if (typeof global.lvyConfig.build[key] == 'boolean') {
|
|
37
|
+
continue
|
|
74
38
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
39
|
+
if (key === 'alias' && !global.lvyConfig.build['@rollup/plugin-alias']) {
|
|
40
|
+
plugins.push(alias(global.lvyConfig.build[key]))
|
|
41
|
+
} else if (key === 'assets') {
|
|
42
|
+
plugins.push(rollupAssets(global.lvyConfig.build[key]))
|
|
43
|
+
} else if (key === 'styles') {
|
|
44
|
+
plugins.push(
|
|
45
|
+
styles({
|
|
46
|
+
mode: ['inject', () => '']
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
plugins.push(rollupStylesCSSImport(global.lvyConfig.build[key]))
|
|
50
|
+
} else if (key === 'commonjs' && !global.lvyConfig.build['@rollup/plugin-commonjs']) {
|
|
51
|
+
plugins.push(commonjs(global.lvyConfig.build[key]))
|
|
52
|
+
} else if (key === 'json' && !global.lvyConfig.build['@rollup/plugin-json']) {
|
|
53
|
+
plugins.push(json(global.lvyConfig.build[key]))
|
|
54
|
+
} else if (key === 'typescript' && !global.lvyConfig.build['@rollup/plugin-typescript']) {
|
|
55
|
+
plugins.push(typescript(global.lvyConfig.build[key]))
|
|
56
|
+
} else if (key === 'plugins') {
|
|
57
|
+
if (Array.isArray(global.lvyConfig.build[key])) {
|
|
58
|
+
for (const plugin of global.lvyConfig.build[key]) {
|
|
59
|
+
plugins.push(plugin)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
const plugin = (await import(key)).default
|
|
64
|
+
plugins.push(plugin(global.lvyConfig.build[key]))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// 如果不存在这些配置
|
|
68
|
+
const keys = ['assets', 'styles', 'commonjs', 'json', 'typescript']
|
|
69
|
+
for (const key of keys) {
|
|
70
|
+
// 如果是布尔值
|
|
71
|
+
if (typeof global.lvyConfig.build[key] == 'boolean') {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
// 存在这些配置
|
|
75
|
+
if (global.lvyConfig.build[key]) {
|
|
76
|
+
continue
|
|
108
77
|
}
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
78
|
+
//
|
|
79
|
+
if (key == 'assets') {
|
|
80
|
+
plugins.push(rollupAssets())
|
|
81
|
+
} else if (key == 'styles') {
|
|
82
|
+
plugins.push(
|
|
83
|
+
styles({
|
|
84
|
+
mode: ['inject', () => '']
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
plugins.push(rollupStylesCSSImport())
|
|
88
|
+
} else if (key === 'commonjs') {
|
|
89
|
+
plugins.push(commonjs())
|
|
90
|
+
} else if (key === 'json') {
|
|
91
|
+
plugins.push(json())
|
|
92
|
+
} else if (key === 'typescript') {
|
|
93
|
+
plugins.push(typescript())
|
|
94
|
+
} else if (key === 'plugins') {
|
|
95
|
+
plugins.push(alias())
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// rollup 配置
|
|
99
|
+
const Options = global.lvyConfig.build?.rollupOptions ?? {}
|
|
100
|
+
// rollup 配置
|
|
101
|
+
const rollupOptions = {
|
|
102
|
+
input: inputs,
|
|
103
|
+
plugins: plugins,
|
|
104
|
+
onwarn: onwarn,
|
|
105
|
+
...Options
|
|
106
|
+
}
|
|
107
|
+
// build
|
|
108
|
+
const bundle = await rollup(rollupOptions)
|
|
109
|
+
// 写入输出文件
|
|
110
|
+
await bundle.write({
|
|
111
|
+
dir: output,
|
|
112
|
+
format: 'es',
|
|
113
|
+
sourcemap: false,
|
|
114
|
+
preserveModules: true
|
|
115
|
+
})
|
|
116
|
+
}
|
|
128
117
|
/**
|
|
129
118
|
*
|
|
130
119
|
* @param script
|
|
131
120
|
*/
|
|
132
121
|
async function buildAndRun(input, output) {
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
const inputFiles = getFiles(join(process.cwd(), input))
|
|
123
|
+
await buildJS(inputFiles, output)
|
|
135
124
|
}
|
|
136
125
|
|
|
137
|
-
export { buildAndRun, buildJS }
|
|
126
|
+
export { buildAndRun, buildJS }
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defineConfig, initConfig } from './store.js'
|
|
1
|
+
export { defineConfig, initConfig } from './store.js'
|
package/lib/index.js
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
import { buildAndRun } from './build/rullup.js'
|
|
2
|
-
import { initConfig } from './store.js'
|
|
3
|
-
export { defineConfig } from './store.js'
|
|
1
|
+
import { buildAndRun } from './build/rullup.js'
|
|
2
|
+
import { initConfig } from './store.js'
|
|
3
|
+
export { defineConfig } from './store.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param input
|
|
7
7
|
*/
|
|
8
8
|
const onDev = async () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
9
|
+
// 修改config
|
|
10
|
+
for (const plugin of global.lvyConfig.plugins) {
|
|
11
|
+
if (plugin?.config) {
|
|
12
|
+
const cfg = await plugin.config(global.lvyConfig)
|
|
13
|
+
for (const key in cfg) {
|
|
14
|
+
// 不能覆盖plugins
|
|
15
|
+
if (cfg[key] != 'plugins') {
|
|
16
|
+
// 覆盖
|
|
17
|
+
global.lvyConfig[key] = cfg[key]
|
|
20
18
|
}
|
|
19
|
+
}
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
21
|
+
}
|
|
22
|
+
// 执行loader
|
|
23
|
+
await import('./loader/main.js')
|
|
24
|
+
// 执行 useApp
|
|
25
|
+
for (const plugin of global.lvyConfig.plugins) {
|
|
26
|
+
if (plugin?.useApp) await plugin.useApp()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
30
29
|
/**
|
|
31
30
|
*
|
|
32
31
|
* @param input
|
|
33
32
|
* @param ouput
|
|
34
33
|
*/
|
|
35
34
|
const onBuild = () => {
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
buildAndRun('src', 'lib')
|
|
36
|
+
}
|
|
38
37
|
const main = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
main();
|
|
38
|
+
if (process.argv.includes('--lvy-dev')) {
|
|
39
|
+
await initConfig()
|
|
40
|
+
onDev()
|
|
41
|
+
} else if (process.argv.includes('--lvy-build')) {
|
|
42
|
+
await initConfig()
|
|
43
|
+
onBuild()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
main()
|
|
49
47
|
|
|
50
|
-
export { initConfig }
|
|
48
|
+
export { initConfig }
|
package/lib/loader/esbuild.js
CHANGED
|
@@ -7,29 +7,11 @@ const plugins = [];
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
const initPlugins = async () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
10
|
+
if (typeof global.lvyConfig?.esbuild?.assets != 'boolean') {
|
|
11
|
+
plugins.push(esBuildAsstes(global.lvyConfig.esbuild.assets));
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (const key of keys) {
|
|
18
|
-
// 如果是布尔值
|
|
19
|
-
if (typeof global.lvyConfig.esbuild[key] == 'boolean') {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
// 存在这些配置
|
|
23
|
-
if (global.lvyConfig.esbuild[key]) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
//
|
|
27
|
-
if (key == 'assets') {
|
|
28
|
-
plugins.push(esBuildAsstes());
|
|
29
|
-
}
|
|
30
|
-
else if (key === 'styles') {
|
|
31
|
-
plugins.push(esBuildCSS());
|
|
32
|
-
}
|
|
13
|
+
if (typeof global.lvyConfig?.esbuild?.styles != 'boolean') {
|
|
14
|
+
plugins.push(esBuildCSS(global.lvyConfig.esbuild.styles));
|
|
33
15
|
}
|
|
34
16
|
};
|
|
35
17
|
/**
|
|
@@ -43,7 +25,7 @@ const ESBuild = async (input) => {
|
|
|
43
25
|
global.lvyConfig = {};
|
|
44
26
|
if (!global.lvyConfig.esbuild)
|
|
45
27
|
global.lvyConfig.esbuild = {};
|
|
46
|
-
//
|
|
28
|
+
// 没有插件时,检查是否有可用插件。
|
|
47
29
|
if (plugins.length === 0) {
|
|
48
30
|
// init plugisn
|
|
49
31
|
await initPlugins();
|
package/lib/loader/index.js
CHANGED
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Plugin } from 'esbuild'
|
|
2
|
+
|
|
3
|
+
type ESBuildAsstesOptions = {
|
|
4
|
+
filter?: RegExp
|
|
5
|
+
namespace?: string
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param param0
|
|
10
|
+
*/
|
|
11
|
+
declare const esBuildAsstes: (optoins?: ESBuildAsstesOptions) => Plugin
|
|
12
|
+
type ESBuildCSSOptions = {
|
|
13
|
+
filter?: RegExp
|
|
14
|
+
namespace?: string
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* css资源处理插件
|
|
18
|
+
* @param param0
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
declare const esBuildCSS: (optoins?: ESBuildCSSOptions) => Plugin
|
|
22
|
+
|
|
23
|
+
export { type ESBuildAsstesOptions, type ESBuildCSSOptions, esBuildAsstes, esBuildCSS }
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { InputPluginOption } from 'rollup'
|
|
1
|
+
import { InputPluginOption } from 'rollup'
|
|
2
2
|
|
|
3
3
|
type RollupStylesCSSImportOptions = {
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
include?: RegExp
|
|
5
|
+
}
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
declare const rollupStylesCSSImport: ({
|
|
10
|
+
declare const rollupStylesCSSImport: ({
|
|
11
|
+
include
|
|
12
|
+
}?: RollupStylesCSSImportOptions) => InputPluginOption
|
|
11
13
|
|
|
12
|
-
export { type RollupStylesCSSImportOptions, rollupStylesCSSImport }
|
|
14
|
+
export { type RollupStylesCSSImportOptions, rollupStylesCSSImport }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { InputPluginOption } from 'rollup'
|
|
1
|
+
import { InputPluginOption } from 'rollup'
|
|
2
2
|
|
|
3
3
|
type RollupAssetsOptions = {
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
filter?: RegExp
|
|
5
|
+
}
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} options
|
|
8
8
|
* @returns {Object}
|
|
9
9
|
*/
|
|
10
|
-
declare const rollupAssets: ({ filter }?: RollupAssetsOptions) => InputPluginOption
|
|
10
|
+
declare const rollupAssets: ({ filter }?: RollupAssetsOptions) => InputPluginOption
|
|
11
11
|
|
|
12
|
-
export { type RollupAssetsOptions, rollupAssets }
|
|
12
|
+
export { type RollupAssetsOptions, rollupAssets }
|
package/lib/store.d.ts
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { RollupAliasOptions } from '@rollup/plugin-alias'
|
|
2
|
-
import { RollupOptions } from 'rollup'
|
|
3
|
-
import { RollupStylesCSSImportOptions } from './plugins/loader-css.js'
|
|
4
|
-
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs'
|
|
5
|
-
import { RollupJsonOptions } from '@rollup/plugin-json'
|
|
6
|
-
import { RollupTypescriptOptions } from '@rollup/plugin-typescript'
|
|
7
|
-
import { SameShape, BuildOptions } from 'esbuild'
|
|
8
|
-
import { RollupAssetsOptions } from './plugins/loader-files.js'
|
|
9
|
-
import { ESBuildAsstesOptions, ESBuildCSSOptions } from './loader/plugins.js'
|
|
1
|
+
import { RollupAliasOptions } from '@rollup/plugin-alias'
|
|
2
|
+
import { RollupOptions } from 'rollup'
|
|
3
|
+
import { RollupStylesCSSImportOptions } from './plugins/loader-css.js'
|
|
4
|
+
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs'
|
|
5
|
+
import { RollupJsonOptions } from '@rollup/plugin-json'
|
|
6
|
+
import { RollupTypescriptOptions } from '@rollup/plugin-typescript'
|
|
7
|
+
import { SameShape, BuildOptions } from 'esbuild'
|
|
8
|
+
import { RollupAssetsOptions } from './plugins/loader-files.js'
|
|
9
|
+
import { ESBuildAsstesOptions, ESBuildCSSOptions } from './loader/plugins.js'
|
|
10
10
|
|
|
11
11
|
type Options = {
|
|
12
|
+
/**
|
|
13
|
+
* 配置调整机及其回调插件
|
|
14
|
+
*/
|
|
15
|
+
plugins?: {
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
17
|
+
* 应用名
|
|
14
18
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 应用名
|
|
18
|
-
*/
|
|
19
|
-
name: string;
|
|
20
|
-
/**
|
|
21
|
-
* ⚠️直接optoins进行调整
|
|
22
|
-
* @param options
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
config?: (options: Options) => Options;
|
|
26
|
-
/**
|
|
27
|
-
* 执行
|
|
28
|
-
*/
|
|
29
|
-
useApp?: () => void;
|
|
30
|
-
}[];
|
|
19
|
+
name: string
|
|
31
20
|
/**
|
|
32
|
-
*
|
|
21
|
+
* ⚠️直接optoins进行调整
|
|
22
|
+
* @param options
|
|
23
|
+
* @returns
|
|
33
24
|
*/
|
|
34
|
-
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
/**
|
|
37
|
-
* 资源
|
|
38
|
-
*/
|
|
39
|
-
assets?: ESBuildAsstesOptions | false;
|
|
40
|
-
/**
|
|
41
|
-
* 样式处理
|
|
42
|
-
*/
|
|
43
|
-
styles?: ESBuildCSSOptions | false;
|
|
44
|
-
/**
|
|
45
|
-
* ⚠️ 直接覆盖esbuild配置
|
|
46
|
-
*/
|
|
47
|
-
options?: SameShape<BuildOptions, BuildOptions>;
|
|
48
|
-
};
|
|
25
|
+
config?: (options: Options) => Options
|
|
49
26
|
/**
|
|
50
|
-
*
|
|
27
|
+
* 执行
|
|
51
28
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
29
|
+
useApp?: () => void
|
|
30
|
+
}[]
|
|
31
|
+
/**
|
|
32
|
+
* 运行时配置
|
|
33
|
+
*/
|
|
34
|
+
esbuild?: {
|
|
35
|
+
[key: string]: any
|
|
36
|
+
/**
|
|
37
|
+
* 资源
|
|
38
|
+
*/
|
|
39
|
+
assets?: ESBuildAsstesOptions | false
|
|
40
|
+
/**
|
|
41
|
+
* 样式处理
|
|
42
|
+
*/
|
|
43
|
+
styles?: ESBuildCSSOptions | false
|
|
44
|
+
/**
|
|
45
|
+
* ⚠️ 直接覆盖esbuild配置
|
|
46
|
+
*/
|
|
47
|
+
options?: SameShape<BuildOptions, BuildOptions>
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 打包时配置
|
|
51
|
+
*/
|
|
52
|
+
build?: {
|
|
53
|
+
[key: string]: any
|
|
54
|
+
/**
|
|
55
|
+
* 别名
|
|
56
|
+
*/
|
|
57
|
+
alias?: RollupAliasOptions | false
|
|
58
|
+
/**
|
|
59
|
+
* 文件过滤
|
|
60
|
+
*/
|
|
61
|
+
assets?: RollupAssetsOptions | false
|
|
62
|
+
/**
|
|
63
|
+
* 样式处理配置
|
|
64
|
+
*/
|
|
65
|
+
styles?: RollupStylesCSSImportOptions | false
|
|
66
|
+
/**
|
|
67
|
+
* cjs文件处理
|
|
68
|
+
*/
|
|
69
|
+
commonjs?: RollupCommonJSOptions | false
|
|
70
|
+
/**
|
|
71
|
+
* josn文件处理
|
|
72
|
+
*/
|
|
73
|
+
json?: RollupJsonOptions | false
|
|
74
|
+
/**
|
|
75
|
+
* ts配置
|
|
76
|
+
*/
|
|
77
|
+
typescript?: RollupTypescriptOptions | false
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
plugins?: any[]
|
|
82
|
+
/**
|
|
83
|
+
* ⚠️ 直接覆盖build配置
|
|
84
|
+
*/
|
|
85
|
+
rollupOptions?: {
|
|
86
|
+
input?: string | string[]
|
|
87
|
+
} & RollupOptions
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
90
|
/**
|
|
91
91
|
*
|
|
92
92
|
*/
|
|
93
93
|
declare global {
|
|
94
|
-
|
|
94
|
+
var lvyConfig: Options
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
*
|
|
98
98
|
*/
|
|
99
|
-
declare const initConfig: () => Promise<void
|
|
99
|
+
declare const initConfig: () => Promise<void>
|
|
100
100
|
/**
|
|
101
101
|
* @param param0
|
|
102
102
|
* @returns
|
|
103
103
|
*/
|
|
104
|
-
declare const defineConfig: (optoins?: Options) => Options
|
|
104
|
+
declare const defineConfig: (optoins?: Options) => Options
|
|
105
105
|
|
|
106
|
-
export { type Options, defineConfig, initConfig }
|
|
106
|
+
export { type Options, defineConfig, initConfig }
|
package/lib/store.js
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { existsSync } from 'fs'
|
|
2
|
-
import { join } from 'path'
|
|
1
|
+
import { existsSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
const initConfig = async () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
8
|
+
if (!global.lvyConfig) global.lvyConfig = {}
|
|
9
|
+
const files = [
|
|
10
|
+
'lvy.config.ts',
|
|
11
|
+
'lvy.config.js',
|
|
12
|
+
'lvy.config.mjs',
|
|
13
|
+
'lvy.config.cjs',
|
|
14
|
+
'lvy.config.tsx'
|
|
15
|
+
]
|
|
16
|
+
let configDir = ''
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
if (existsSync(file)) {
|
|
19
|
+
configDir = file
|
|
20
|
+
break
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
}
|
|
23
|
+
if (configDir !== '') {
|
|
24
|
+
const v = await import(`file://${join(process.cwd(), configDir)}`)
|
|
25
|
+
if (v?.default) {
|
|
26
|
+
global.lvyConfig = v.default
|
|
29
27
|
}
|
|
30
|
-
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
31
30
|
/**
|
|
32
31
|
* @param param0
|
|
33
32
|
* @returns
|
|
34
33
|
*/
|
|
35
|
-
const defineConfig =
|
|
34
|
+
const defineConfig = optoins => optoins
|
|
36
35
|
|
|
37
|
-
export { defineConfig, initConfig }
|
|
36
|
+
export { defineConfig, initConfig }
|
package/package.json
CHANGED
package/lib/loader/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type LoaderResult = {
|
|
2
|
-
format?: string;
|
|
3
|
-
source?: string;
|
|
4
|
-
shortCircuit?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param url
|
|
9
|
-
* @param context
|
|
10
|
-
* @param defaultLoad
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
declare const load: (url: string, context: any, defaultLoad: (url: string, context: any) => Promise<LoaderResult>) => Promise<LoaderResult>;
|
|
14
|
-
|
|
15
|
-
export { load };
|