lvyjs 0.1.2 → 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.
@@ -1,27 +1,26 @@
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 = 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
- }
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
+ }
17
+ else if (item.isFile() &&
18
+ /\.(ts|js|jsx|tsx)$/.test(item.name) &&
19
+ !item.name.endsWith('.d.ts')) {
20
+ results.push(fullPath);
21
+ }
22
+ });
23
+ return results;
24
+ };
26
25
 
27
- export { getFiles }
26
+ export { getFiles };
@@ -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,9 +15,10 @@ import { rollupAssets } from '../plugins/loader-files.js'
15
15
  * @param warn
16
16
  */
17
17
  const onwarn = (warning, warn) => {
18
- if (warning.code === 'UNRESOLVED_IMPORT') return
19
- warn(warning)
20
- }
18
+ if (warning.code === 'UNRESOLVED_IMPORT')
19
+ return;
20
+ warn(warning);
21
+ };
21
22
  /**
22
23
  * 打包 JS
23
24
  * *** 注意 **
@@ -28,99 +29,109 @@ const onwarn = (warning, warn) => {
28
29
  * @param output
29
30
  */
30
31
  const buildJS = async (inputs, output) => {
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
38
- }
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
32
+ if (!global.lvyConfig)
33
+ global.lvyConfig = {};
34
+ if (!global.lvyConfig.build)
35
+ global.lvyConfig.build = {};
36
+ // 插件
37
+ const plugins = [];
38
+ for (const key in global.lvyConfig.build) {
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
+ }
77
74
  }
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())
75
+ // 如果不存在这些配置
76
+ const keys = ['assets', 'styles', 'commonjs', 'json', 'typescript'];
77
+ for (const key of keys) {
78
+ // 如果是布尔值
79
+ if (typeof global.lvyConfig.build[key] == 'boolean') {
80
+ continue;
81
+ }
82
+ // 存在这些配置
83
+ if (global.lvyConfig.build[key]) {
84
+ continue;
85
+ }
86
+ //
87
+ if (key == 'assets') {
88
+ plugins.push(rollupAssets());
89
+ }
90
+ else if (key == 'styles') {
91
+ plugins.push(styles({
92
+ mode: ['inject', () => '']
93
+ }));
94
+ plugins.push(rollupStylesCSSImport());
95
+ }
96
+ else if (key === 'commonjs') {
97
+ plugins.push(commonjs());
98
+ }
99
+ else if (key === 'json') {
100
+ plugins.push(json());
101
+ }
102
+ else if (key === 'typescript') {
103
+ plugins.push(typescript());
104
+ }
105
+ else if (key === 'plugins') {
106
+ plugins.push(alias());
107
+ }
96
108
  }
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
- }
109
+ // rollup 配置
110
+ const Options = global.lvyConfig.build?.rollupOptions ?? {};
111
+ // rollup 配置
112
+ const rollupOptions = {
113
+ input: inputs,
114
+ plugins: plugins,
115
+ onwarn: onwarn,
116
+ ...Options
117
+ };
118
+ // build
119
+ const bundle = await rollup(rollupOptions);
120
+ // 写入输出文件
121
+ await bundle.write({
122
+ dir: output,
123
+ format: 'es',
124
+ sourcemap: false,
125
+ preserveModules: true
126
+ });
127
+ };
117
128
  /**
118
129
  *
119
130
  * @param script
120
131
  */
121
132
  async function buildAndRun(input, output) {
122
- const inputFiles = getFiles(join(process.cwd(), input))
123
- await buildJS(inputFiles, output)
133
+ const inputFiles = getFiles(join(process.cwd(), input));
134
+ await buildJS(inputFiles, output);
124
135
  }
125
136
 
126
- export { buildAndRun, buildJS }
137
+ export { buildAndRun, buildJS };
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,48 +1,50 @@
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 './loader/store.js';
3
+ export { defineConfig } from './loader/store.js';
4
4
 
5
5
  /**
6
6
  * @param input
7
7
  */
8
8
  const onDev = async () => {
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]
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
+ }
18
20
  }
19
- }
20
21
  }
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
- }
22
+ // 执行loader
23
+ await import('./main.js');
24
+ // 执行 useApp
25
+ for (const plugin of global.lvyConfig.plugins) {
26
+ if (plugin?.useApp)
27
+ await plugin.useApp();
28
+ }
29
+ };
29
30
  /**
30
31
  *
31
32
  * @param input
32
33
  * @param ouput
33
34
  */
34
35
  const onBuild = () => {
35
- buildAndRun('src', 'lib')
36
- }
36
+ buildAndRun('src', 'lib');
37
+ };
37
38
  const main = async () => {
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()
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();
47
49
 
48
- export { initConfig }
50
+ export { initConfig };
@@ -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('/*', '');
@@ -0,0 +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 './plugins.js';
10
+
11
+ type Options = {
12
+ /**
13
+ * 配置调整机及其回调插件
14
+ */
15
+ plugins?: {
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
+ }[];
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
+ /**
91
+ *
92
+ */
93
+ declare global {
94
+ var lvyConfig: Options;
95
+ }
96
+ /**
97
+ *
98
+ */
99
+ declare const initConfig: () => Promise<void>;
100
+ /**
101
+ * @param param0
102
+ * @returns
103
+ */
104
+ declare const defineConfig: (optoins?: Options) => Options;
105
+
106
+ export { type Options, defineConfig, initConfig };
@@ -0,0 +1,32 @@
1
+ import { existsSync } from 'fs';
2
+ import { join } from 'path';
3
+
4
+ /**
5
+ *
6
+ */
7
+ const initConfig = async () => {
8
+ if (!global.lvyConfig)
9
+ global.lvyConfig = {};
10
+ const files = [
11
+ 'lvy.config.ts',
12
+ 'lvy.config.js',
13
+ 'lvy.config.mjs',
14
+ 'lvy.config.cjs',
15
+ 'lvy.config.tsx'
16
+ ];
17
+ let configDir = '';
18
+ for (const file of files) {
19
+ if (existsSync(file)) {
20
+ configDir = file;
21
+ break;
22
+ }
23
+ }
24
+ if (configDir !== '') {
25
+ const v = await import(`file://${join(process.cwd(), configDir)}`);
26
+ if (v?.default) {
27
+ global.lvyConfig = v.default;
28
+ }
29
+ }
30
+ };
31
+
32
+ export { initConfig };
@@ -0,0 +1,15 @@
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 };
@@ -1,5 +1,5 @@
1
- import { ESBuild } from './esbuild.js';
2
- import { initConfig } from '../store.js';
1
+ import { ESBuild } from './loader/esbuild.js';
2
+ import { initConfig } from './loader/store.js';
3
3
 
4
4
  await initConfig();
5
5
  const platform = ['linux', 'android', 'darwin'];
package/lib/main.js ADDED
@@ -0,0 +1,3 @@
1
+ import { register } from 'node:module'
2
+
3
+ register('./loader.js', import.meta.url)
@@ -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
+ export { RollupStylesCSSImportOptions, rollupStylesCSSImport } from './loader-css.js';
2
+ export { RollupAssetsOptions, rollupAssets } from './loader-files.js';
@@ -1,14 +1,12 @@
1
- import { InputPluginOption } from 'rollup'
1
+ import { InputPluginOption } from 'rollup';
2
2
 
3
3
  type RollupStylesCSSImportOptions = {
4
- include?: RegExp
5
- }
4
+ include?: RegExp;
5
+ };
6
6
  /**
7
7
  *
8
8
  * @returns
9
9
  */
10
- declare const rollupStylesCSSImport: ({
11
- include
12
- }?: RollupStylesCSSImportOptions) => InputPluginOption
10
+ declare const rollupStylesCSSImport: ({ include }?: RollupStylesCSSImportOptions) => InputPluginOption;
13
11
 
14
- export { type RollupStylesCSSImportOptions, rollupStylesCSSImport }
12
+ 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
- filter?: RegExp
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lvyjs",
3
- "version": "0.1.2",
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/index.js",
46
- "types": "./lib/loader/index.d.ts"
45
+ "import": "./lib/loader.js",
46
+ "types": "./lib/loader.d.ts"
47
47
  },
48
48
  "./register": {
49
- "import": "./lib/loader/main.js",
50
- "types": "./lib/loader/main.d.ts"
49
+ "import": "./lib/main.js",
50
+ "types": "./lib/main.d.ts"
51
51
  },
52
52
  "./env": {
53
53
  "types": "./env.d.ts"
@@ -1,8 +0,0 @@
1
- /**
2
- * 获取指定目录下的所有 ts、js、jsx、tsx 文件
3
- * @param dir 目录路径
4
- * @returns 文件路径数组
5
- */
6
- declare const getFiles: (dir: string) => string[]
7
-
8
- export { getFiles }
@@ -1,17 +0,0 @@
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 }
@@ -1,8 +0,0 @@
1
- /**
2
- *
3
- * @param input
4
- * @returns
5
- */
6
- declare const ESBuild: (input: string) => Promise<string>;
7
-
8
- export { ESBuild };
@@ -1,3 +0,0 @@
1
- import { register } from 'node:module';
2
-
3
- register('./index.js', import.meta.url);
package/lib/store.d.ts DELETED
@@ -1,106 +0,0 @@
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
-
11
- type Options = {
12
- /**
13
- * 配置调整机及其回调插件
14
- */
15
- plugins?: {
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
- }[]
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
- /**
91
- *
92
- */
93
- declare global {
94
- var lvyConfig: Options
95
- }
96
- /**
97
- *
98
- */
99
- declare const initConfig: () => Promise<void>
100
- /**
101
- * @param param0
102
- * @returns
103
- */
104
- declare const defineConfig: (optoins?: Options) => Options
105
-
106
- export { type Options, defineConfig, initConfig }
package/lib/store.js DELETED
@@ -1,36 +0,0 @@
1
- import { existsSync } from 'fs'
2
- import { join } from 'path'
3
-
4
- /**
5
- *
6
- */
7
- const initConfig = async () => {
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
21
- }
22
- }
23
- if (configDir !== '') {
24
- const v = await import(`file://${join(process.cwd(), configDir)}`)
25
- if (v?.default) {
26
- global.lvyConfig = v.default
27
- }
28
- }
29
- }
30
- /**
31
- * @param param0
32
- * @returns
33
- */
34
- const defineConfig = optoins => optoins
35
-
36
- export { defineConfig, initConfig }
File without changes