lvyjs 0.1.1 → 0.1.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/bin/index.js +6 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/lib/loader/esbuild.js +5 -23
- package/lib/loader/plugins.js +9 -9
- package/lib/{store.d.ts → loader/store.d.ts} +3 -3
- package/lib/{store.js → loader/store.js} +1 -6
- package/lib/{loader/index.js → loader.js} +3 -1
- package/lib/main.js +3 -0
- package/package.json +5 -5
- package/lib/loader/main.js +0 -3
- /package/lib/{loader/index.d.ts → loader.d.ts} +0 -0
- /package/lib/{loader/main.d.ts → main.d.ts} +0 -0
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/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { defineConfig, initConfig } from './store.js';
|
|
1
|
+
export { defineConfig, initConfig } from './loader/store.js';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildAndRun } from './build/rullup.js';
|
|
2
|
-
import { initConfig } from './store.js';
|
|
3
|
-
export { defineConfig } from './store.js';
|
|
2
|
+
import { initConfig } from './loader/store.js';
|
|
3
|
+
export { defineConfig } from './loader/store.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param input
|
|
@@ -20,7 +20,7 @@ const onDev = async () => {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
// 执行loader
|
|
23
|
-
await import('./
|
|
23
|
+
await import('./main.js');
|
|
24
24
|
// 执行 useApp
|
|
25
25
|
for (const plugin of global.lvyConfig.plugins) {
|
|
26
26
|
if (plugin?.useApp)
|
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/plugins.js
CHANGED
|
@@ -46,6 +46,14 @@ const startCssPost = (input, output) => {
|
|
|
46
46
|
cssPostProcess.kill();
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param inputPath
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
const convertPath = (inputPath) => {
|
|
55
|
+
return process.platform === 'win32' ? inputPath.replace(/\\/g, '/') : inputPath;
|
|
56
|
+
};
|
|
49
57
|
/**
|
|
50
58
|
* 生成模块内容
|
|
51
59
|
* @param {string} relativePath 相对路径
|
|
@@ -58,7 +66,7 @@ const generateModuleContent = (relativePath) => {
|
|
|
58
66
|
'const reg = T ? /^file:\\/\\// : /^file:\\/\\/\\//;',
|
|
59
67
|
"return new URL(path, basePath).href.replace(reg, '');",
|
|
60
68
|
'};',
|
|
61
|
-
`const fileUrl = createUrl(import.meta.url, '${relativePath}');`,
|
|
69
|
+
`const fileUrl = createUrl(import.meta.url, '${convertPath(relativePath)}');`,
|
|
62
70
|
'export default fileUrl;'
|
|
63
71
|
].join('\n');
|
|
64
72
|
return contents;
|
|
@@ -71,14 +79,6 @@ const getHash = (str) => {
|
|
|
71
79
|
hash.update(str);
|
|
72
80
|
return hash.digest('hex');
|
|
73
81
|
};
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @param inputPath
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
const convertPath = (inputPath) => {
|
|
80
|
-
return process.platform === 'win32' ? inputPath.replace(/\\/g, '/') : inputPath;
|
|
81
|
-
};
|
|
82
82
|
const handleAsstesFile = (url) => {
|
|
83
83
|
for (const alias in aliases) {
|
|
84
84
|
const aliasPattern = alias.replace('/*', '');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { RollupAliasOptions } from '@rollup/plugin-alias';
|
|
2
2
|
import { RollupOptions } from 'rollup';
|
|
3
|
-
import { RollupStylesCSSImportOptions } from '
|
|
3
|
+
import { RollupStylesCSSImportOptions } from '../plugins/loader-css.js';
|
|
4
4
|
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
|
|
5
5
|
import { RollupJsonOptions } from '@rollup/plugin-json';
|
|
6
6
|
import { RollupTypescriptOptions } from '@rollup/plugin-typescript';
|
|
7
7
|
import { SameShape, BuildOptions } from 'esbuild';
|
|
8
|
-
import { RollupAssetsOptions } from '
|
|
9
|
-
import { ESBuildAsstesOptions, ESBuildCSSOptions } from './
|
|
8
|
+
import { RollupAssetsOptions } from '../plugins/loader-files.js';
|
|
9
|
+
import { ESBuildAsstesOptions, ESBuildCSSOptions } from './plugins.js';
|
|
10
10
|
|
|
11
11
|
type Options = {
|
|
12
12
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ESBuild } from './esbuild.js';
|
|
1
|
+
import { ESBuild } from './loader/esbuild.js';
|
|
2
|
+
import { initConfig } from './loader/store.js';
|
|
2
3
|
|
|
4
|
+
await initConfig();
|
|
3
5
|
const platform = ['linux', 'android', 'darwin'];
|
|
4
6
|
const T = platform.includes(process.platform);
|
|
5
7
|
const reg = T ? /^file:\/\// : /^file:\/\/\//;
|
package/lib/main.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lvyjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "tsx compile script",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"types": "./lib/index.d.ts"
|
|
43
43
|
},
|
|
44
44
|
"./loader": {
|
|
45
|
-
"import": "./lib/loader
|
|
46
|
-
"types": "./lib/loader
|
|
45
|
+
"import": "./lib/loader.js",
|
|
46
|
+
"types": "./lib/loader.d.ts"
|
|
47
47
|
},
|
|
48
48
|
"./register": {
|
|
49
|
-
"import": "./lib/
|
|
50
|
-
"types": "./lib/
|
|
49
|
+
"import": "./lib/main.js",
|
|
50
|
+
"types": "./lib/main.d.ts"
|
|
51
51
|
},
|
|
52
52
|
"./env": {
|
|
53
53
|
"types": "./env.d.ts"
|
package/lib/loader/main.js
DELETED
|
File without changes
|
|
File without changes
|