lvyjs 0.2.24 → 0.2.25

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.
Files changed (2) hide show
  1. package/bin/index.js +5 -22
  2. package/package.json +6 -2
package/bin/index.js CHANGED
@@ -3,29 +3,18 @@
3
3
  import { fork } from 'child_process'
4
4
  import { join, dirname, relative } from 'path'
5
5
  import { fileURLToPath } from 'node:url'
6
- import { createRequire } from 'node:module'
7
6
  const args = [...process.argv.slice(2)]
8
7
  const currentFilePath = fileURLToPath(import.meta.url)
9
8
  const currentDirPath = dirname(currentFilePath)
10
9
  const pkgFilr = join(currentDirPath, '../package.json')
11
10
  const jsFile = join(currentDirPath, '../lib/index.js')
12
- const loaderFile = join(currentDirPath, '../lib/main.js')
13
11
  const jsdir = relative(process.cwd(), jsFile)
14
- const require = createRequire(import.meta.url)
15
- // const tsxDir = require.resolve('tsx/cli')
16
12
  // 构建时,使用 rollup
17
13
  if (args.includes('build')) {
18
14
  const argsx = args.filter(arg => arg !== 'build')
19
15
  const msg = fork(jsdir, ['--lvy-build', ...argsx], {
20
16
  stdio: 'inherit',
21
- // 自己挂 execArgv
22
- execArgv: [
23
- ...process.execArgv,
24
- '--require',
25
- require.resolve('tsx/preflight'),
26
- '--import',
27
- require.resolve('tsx')
28
- ],
17
+ execArgv: [...process.execArgv, '--require', 'tsx/preflight', '--import', 'tsx'],
29
18
  env: Object.assign({}, process.env, {
30
19
  PKG_DIR: pkgFilr
31
20
  }),
@@ -38,22 +27,16 @@ if (args.includes('build')) {
38
27
  // 运行时,使用 tsx
39
28
  } else if (args.includes('dev')) {
40
29
  const argsx = args.filter(arg => arg !== 'dev')
41
- const argv = [jsdir, '--lvy-dev']
42
- if (!args.includes('--no-watch')) {
43
- argv.unshift('--clear-screen=false')
44
- argv.unshift('watch')
45
- }
46
- const msg = fork(jsdir, [...argv, ...argsx], {
30
+ const msg = fork(jsdir, ['--lvy-dev', ...argsx], {
47
31
  stdio: 'inherit',
48
- // 自己挂 execArgv
49
32
  execArgv: [
50
33
  ...process.execArgv,
51
34
  '--require',
52
- require.resolve('tsx/preflight'),
35
+ 'tsx/preflight',
53
36
  '--import',
54
- require.resolve('tsx'),
37
+ 'tsx',
55
38
  '--import',
56
- loaderFile
39
+ 'lvyjs/register'
57
40
  ],
58
41
  env: Object.assign({}, process.env, {
59
42
  PKG_DIR: pkgFilr
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "lvyjs",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "description": "tsx compile script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
9
  "scripts": {
10
- "build": "node bundle.js"
10
+ "build": "node bundle.js",
11
+ "start": "node lib/index.js",
12
+ "dev": "tsx src/index.ts",
13
+ "dev:watch": "tsx watch src/index.ts"
11
14
  },
12
15
  "dependencies": {
13
16
  "@rollup/plugin-alias": "^5.1.0",
@@ -16,6 +19,7 @@
16
19
  "@rollup/plugin-typescript": "^11.1.6",
17
20
  "@rollup/pluginutils": "^5.1.3",
18
21
  "autoprefixer": "^10.4.20",
22
+ "chokidar": "^3.6.0",
19
23
  "postcss": "^8.4.47",
20
24
  "postcss-import": "^16.1.0",
21
25
  "postcss-url": "^10.1.3",