lvyjs 0.0.2 → 0.0.3
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/README.md +2 -40
- package/lib/index.js +35 -33
- package/lib/loader/esbuild.js +1 -1
- package/lib/loader/index.js +3 -4
- package/lib/store.d.ts +27 -27
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
# LVY
|
|
2
2
|
|
|
3
3
|
长春藤。 一款为 node 构建的开发工具
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
npm install lvyjs -D
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
// lvy.config.ts
|
|
11
|
-
import { defineConfig } from 'lvyjs'
|
|
12
|
-
import { alias, files } from 'lvyjs/plugins'
|
|
13
|
-
import { fileURLToPath } from 'url'
|
|
14
|
-
import { dirname, join } from 'path'
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
16
|
-
const __dirname = dirname(__filename)
|
|
17
|
-
export default defineConfig({
|
|
18
|
-
plugins: [
|
|
19
|
-
{
|
|
20
|
-
name: 'my-app',
|
|
21
|
-
callback: () => {
|
|
22
|
-
// 要执行的会调函数
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
build: {
|
|
27
|
-
plugins: [
|
|
28
|
-
alias({
|
|
29
|
-
entries: [{ find: '@src', replacement: join(__dirname, 'src') }]
|
|
30
|
-
}),
|
|
31
|
-
files({ filter: /\.(png|jpg)$/ })
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
npx lvy dev
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```sh
|
|
42
|
-
npx lvy build
|
|
43
|
-
```
|
|
4
|
+
|
|
5
|
+
https://github.com/lemonade-lab/lvyjs
|
package/lib/index.js
CHANGED
|
@@ -1,46 +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
|
-
|
|
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];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
22
|
+
// 执行loader
|
|
23
|
+
await import('./loader/main.js');
|
|
24
|
+
// 执行callback
|
|
25
|
+
for (const plugin of global.lvyConfig.plugins) {
|
|
26
|
+
if (plugin?.callback)
|
|
27
|
+
await plugin.callback();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
28
30
|
/**
|
|
29
31
|
*
|
|
30
32
|
* @param input
|
|
31
33
|
* @param ouput
|
|
32
34
|
*/
|
|
33
35
|
const onBuild = () => {
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
36
|
+
buildAndRun('src', 'lib');
|
|
37
|
+
};
|
|
37
38
|
const main = async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
39
|
+
if (process.argv.includes('--lvy-dev')) {
|
|
40
|
+
await initConfig();
|
|
41
|
+
onDev();
|
|
42
|
+
}
|
|
43
|
+
else if (process.argv.includes('--lvy-build')) {
|
|
44
|
+
await initConfig();
|
|
45
|
+
onBuild();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
main();
|
package/lib/loader/esbuild.js
CHANGED
|
@@ -138,7 +138,7 @@ const esBuildAsstesFule = () => {
|
|
|
138
138
|
*/
|
|
139
139
|
const handleCSS = (fileUrl) => {
|
|
140
140
|
const hash = getHash(fileUrl);
|
|
141
|
-
const outputDir = join(process.cwd(), 'node_modules', '
|
|
141
|
+
const outputDir = join(process.cwd(), 'node_modules', 'lvyjs', 'assets', `${hash}.css`);
|
|
142
142
|
if (!chache[fileUrl]) {
|
|
143
143
|
startCssPost(fileUrl, outputDir);
|
|
144
144
|
chache[fileUrl] = true;
|
package/lib/loader/index.js
CHANGED
|
@@ -20,11 +20,10 @@ const load = async (url, context, defaultLoad) => {
|
|
|
20
20
|
return defaultLoad(url, context);
|
|
21
21
|
}
|
|
22
22
|
const code = await ESBuild(url.replace(reg, ''));
|
|
23
|
-
return {
|
|
23
|
+
return defaultLoad(url, {
|
|
24
24
|
format: 'module',
|
|
25
|
-
source: code
|
|
26
|
-
|
|
27
|
-
};
|
|
25
|
+
source: code
|
|
26
|
+
});
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export { load };
|
package/lib/store.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { RollupOptions } from 'rollup'
|
|
1
|
+
import { RollupOptions } from 'rollup';
|
|
2
2
|
|
|
3
3
|
type Options = {
|
|
4
|
-
plugins?: {
|
|
5
|
-
name: string
|
|
6
|
-
/**
|
|
7
|
-
* ⚠️直接optoins进行调整
|
|
8
|
-
* @param options
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
config?: (options: Options) => Options
|
|
12
|
-
/**
|
|
13
|
-
* 执行
|
|
14
|
-
*/
|
|
15
|
-
callback?: () => void
|
|
16
|
-
}[]
|
|
17
|
-
build?: {
|
|
18
4
|
plugins?: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* ⚠️直接optoins进行调整
|
|
8
|
+
* @param options
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
config?: (options: Options) => Options;
|
|
12
|
+
/**
|
|
13
|
+
* 执行
|
|
14
|
+
*/
|
|
15
|
+
callback?: () => void;
|
|
16
|
+
}[];
|
|
17
|
+
build?: {
|
|
18
|
+
plugins?: {
|
|
19
|
+
belong: 'rollup' | 'esbuild' | 'other';
|
|
20
|
+
name: string;
|
|
21
|
+
load: any;
|
|
22
|
+
}[];
|
|
23
|
+
rollupOptions?: {
|
|
24
|
+
input?: string | string[];
|
|
25
|
+
} & RollupOptions;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
31
|
declare global {
|
|
32
|
-
|
|
32
|
+
var lvyConfig: Options;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* @param param0
|
|
36
36
|
* @returns
|
|
37
37
|
*/
|
|
38
|
-
declare const defineConfig: (optoins?: Options) => Options
|
|
38
|
+
declare const defineConfig: (optoins?: Options) => Options;
|
|
39
39
|
|
|
40
|
-
export { type Options, defineConfig }
|
|
40
|
+
export { type Options, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lvyjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "tsx compile script",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org",
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"bugs": "https://github.com/
|
|
75
|
+
"bugs": "https://github.com/lemonade-lab/lvy/issues",
|
|
76
76
|
"repository": {
|
|
77
77
|
"type": "git",
|
|
78
|
-
"url": "https://github.com/
|
|
78
|
+
"url": "https://github.com/lemonade-lab/lvy.git"
|
|
79
79
|
}
|
|
80
80
|
}
|