lvyjs 0.0.1 → 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 CHANGED
@@ -1,3 +1,5 @@
1
1
  # LVY
2
2
 
3
- 一款为 node 构建的开发工具
3
+ 长春藤。 一款为 node 构建的开发工具
4
+
5
+ https://github.com/lemonade-lab/lvyjs
package/bin/index.js CHANGED
@@ -7,22 +7,7 @@ const currentFilePath = fileURLToPath(import.meta.url)
7
7
  const currentDirPath = dirname(currentFilePath)
8
8
  const pkgFilr = join(currentDirPath, '../package.json')
9
9
  // 启动模式
10
- if (args.includes('start')) {
11
- const jsFile = join(currentDirPath, '../lib/index.js')
12
- const jsdir = relative(process.cwd(), jsFile)
13
- const argsx = args.filter(arg => arg !== 'start')
14
- const msg = spawn('node', [jsdir, '--lvy-start', ...argsx], {
15
- stdio: 'inherit',
16
- env: Object.assign({}, process.env, {
17
- PKG_DIR: pkgFilr
18
- }),
19
- shell: process.platform === 'win32'
20
- })
21
- if (msg.error) {
22
- console.error(msg.error)
23
- process.exit()
24
- }
25
- } else if (args.includes('build')) {
10
+ if (args.includes('build')) {
26
11
  const jsFile = join(currentDirPath, '../lib/index.js')
27
12
  const jsdir = relative(process.cwd(), jsFile)
28
13
  const argsx = args.filter(arg => arg !== 'build')
package/lib/index.js CHANGED
@@ -6,24 +6,25 @@ export { defineConfig } from './store.js';
6
6
  * @param input
7
7
  */
8
8
  const onDev = async () => {
9
- const apps = [];
10
9
  // 修改config
11
10
  for (const plugin of global.lvyConfig.plugins) {
12
11
  if (plugin?.config) {
13
12
  const cfg = await plugin.config(global.lvyConfig);
14
- global.lvyConfig = {
15
- ...global.lvyConfig,
16
- ...cfg
17
- };
13
+ for (const key in cfg) {
14
+ // 不能覆盖plugins
15
+ if (cfg[key] != 'plugins') {
16
+ // 覆盖
17
+ global.lvyConfig[key] = cfg[key];
18
+ }
19
+ }
18
20
  }
19
- apps.push(plugin);
20
21
  }
21
22
  // 执行loader
22
23
  await import('./loader/main.js');
23
24
  // 执行callback
24
- for (const app of apps) {
25
- if (app?.callback)
26
- await app.callback();
25
+ for (const plugin of global.lvyConfig.plugins) {
26
+ if (plugin?.callback)
27
+ await plugin.callback();
27
28
  }
28
29
  };
29
30
  /**
@@ -34,13 +35,6 @@ const onDev = async () => {
34
35
  const onBuild = () => {
35
36
  buildAndRun('src', 'lib');
36
37
  };
37
- /**
38
- *
39
- */
40
- const onStart = async () => {
41
- // 运行模式
42
- console.log('暂不支持');
43
- };
44
38
  const main = async () => {
45
39
  if (process.argv.includes('--lvy-dev')) {
46
40
  await initConfig();
@@ -50,8 +44,5 @@ const main = async () => {
50
44
  await initConfig();
51
45
  onBuild();
52
46
  }
53
- else if (process.argv.includes('--lvy-start')) {
54
- onStart();
55
- }
56
47
  };
57
48
  main();
@@ -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', 'alemonjs', 'assets', `${hash}.css`);
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;
@@ -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
- shortCircuit: true
27
- };
25
+ source: code
26
+ });
28
27
  };
29
28
 
30
29
  export { load };
package/lib/store.d.ts CHANGED
@@ -8,7 +8,7 @@ type Options = {
8
8
  * @param options
9
9
  * @returns
10
10
  */
11
- config: (options: Options) => Options;
11
+ config?: (options: Options) => Options;
12
12
  /**
13
13
  * 执行
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lvyjs",
3
- "version": "0.0.1",
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/ningmengchongshui/alemonjs/issues",
75
+ "bugs": "https://github.com/lemonade-lab/lvy/issues",
76
76
  "repository": {
77
77
  "type": "git",
78
- "url": "https://github.com/ningmengchongshui/alemonjs.git"
78
+ "url": "https://github.com/lemonade-lab/lvy.git"
79
79
  }
80
80
  }