@wiajs/core 1.1.30 → 1.1.31
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/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/core.min.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/package.json +1 -1
- package/util/wiapack.js +16 -19
package/dist/core.cjs
CHANGED
package/dist/core.js
CHANGED
package/dist/core.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.1.
|
|
2
|
+
* wia core v1.1.31
|
|
3
3
|
* (c) 2015-2025 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
/*!
|
|
7
|
-
* wia core v1.1.
|
|
7
|
+
* wia core v1.1.31
|
|
8
8
|
* (c) 2015-2025 Sibyl Yu and contributors
|
|
9
9
|
* Released under the MIT License.
|
|
10
10
|
*/
|
package/dist/core.mjs
CHANGED
package/dist/jsx-runtime.js
CHANGED
package/package.json
CHANGED
package/util/wiapack.js
CHANGED
|
@@ -15,8 +15,6 @@ import ld from 'lodash'
|
|
|
15
15
|
// const {minify, minify_sync} = require('terser')
|
|
16
16
|
import {parseSync, Compiler, minify} from '@swc/core' // acorn 替换为 swc
|
|
17
17
|
|
|
18
|
-
import cfg from './config.js'
|
|
19
|
-
|
|
20
18
|
const gzip = util.promisify(zlib.gzip)
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -30,6 +28,7 @@ const gzip = util.promisify(zlib.gzip)
|
|
|
30
28
|
* @prop {string[]} [load] - 启动时需加载的模块,启动器需要,一般加载wia公用模块
|
|
31
29
|
* @prop {boolean} [press] - 压缩代码
|
|
32
30
|
* @prop {boolean} [gzip] - gzip打包
|
|
31
|
+
* @prop {*} [cfg] - 打包配置文件
|
|
33
32
|
*/
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -43,6 +42,7 @@ const gzip = util.promisify(zlib.gzip)
|
|
|
43
42
|
* @prop {string} out
|
|
44
43
|
* @prop {boolean} press - 压缩代码
|
|
45
44
|
* @prop {boolean} gzip - gzip打包
|
|
45
|
+
* @prop {*} cfg - 打包配置文件
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
const def = {
|
|
@@ -50,10 +50,11 @@ const def = {
|
|
|
50
50
|
name: '',
|
|
51
51
|
ver: '1.0.0',
|
|
52
52
|
cos: 'https://cos.wia.pub', // 资源主机
|
|
53
|
-
dir:
|
|
53
|
+
dir: '',
|
|
54
54
|
out: 'dist', // 输出路径
|
|
55
55
|
press: true,
|
|
56
56
|
gzip: true,
|
|
57
|
+
cfg: {},
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export default class WiaPack {
|
|
@@ -69,7 +70,10 @@ export default class WiaPack {
|
|
|
69
70
|
constructor(opts) {
|
|
70
71
|
/** @type {Opt} */
|
|
71
72
|
const opt = {...def, ...opts}
|
|
73
|
+
const {cfg} = opt
|
|
74
|
+
opt.dir = cfg.code.dir
|
|
72
75
|
this.opt = opt
|
|
76
|
+
this.cfg = cfg
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
@@ -107,7 +111,7 @@ export default class WiaPack {
|
|
|
107
111
|
async process(uf, pf) {
|
|
108
112
|
const R = []
|
|
109
113
|
const _ = this
|
|
110
|
-
const {opt} = _
|
|
114
|
+
const {opt, cfg} = _
|
|
111
115
|
const {owner, name, ver, dir, out} = opt
|
|
112
116
|
|
|
113
117
|
console.log(`${owner}/${name} process ...`)
|
|
@@ -277,7 +281,7 @@ export default class WiaPack {
|
|
|
277
281
|
async procFile(u, rf, index, wia, page) {
|
|
278
282
|
let R = ''
|
|
279
283
|
const _ = this
|
|
280
|
-
const {opt} = _
|
|
284
|
+
const {opt, cfg} = _
|
|
281
285
|
|
|
282
286
|
try {
|
|
283
287
|
const js = {}
|
|
@@ -383,8 +387,10 @@ export default class WiaPack {
|
|
|
383
387
|
async procPgfile(u, rf, index, wia, page, load) {
|
|
384
388
|
let R = ''
|
|
385
389
|
|
|
390
|
+
const _ = this
|
|
391
|
+
|
|
386
392
|
try {
|
|
387
|
-
const {owner, name: app} =
|
|
393
|
+
const {cfg, owner, name: app} = _
|
|
388
394
|
// 页面引用模块,排除自己
|
|
389
395
|
const rg = new RegExp(cfg.code.wia.join('|'))
|
|
390
396
|
const ljs = u.pf.js
|
|
@@ -518,9 +524,7 @@ export default class WiaPack {
|
|
|
518
524
|
const buf = await gzip(wf)
|
|
519
525
|
await fs.ensureDir(path.dirname(f))
|
|
520
526
|
fs.writeFile(f, buf)
|
|
521
|
-
console.log(
|
|
522
|
-
`Build ${name} gzipped(${(wf.length / 1024).toFixed(2)}KB -> ${(buf.length / 1024).toFixed(2)}KB)`
|
|
523
|
-
)
|
|
527
|
+
console.log(`Build ${name} gzipped(${(wf.length / 1024).toFixed(2)}KB -> ${(buf.length / 1024).toFixed(2)}KB)`)
|
|
524
528
|
} catch (e) {
|
|
525
529
|
console.error(`pack exp:${e.message}`)
|
|
526
530
|
}
|
|
@@ -780,10 +784,7 @@ export default class WiaPack {
|
|
|
780
784
|
code = `${head}${body}}`
|
|
781
785
|
}
|
|
782
786
|
|
|
783
|
-
console.log(
|
|
784
|
-
{name, offset, span: v.span, start: code.slice(0, 50), tail: code.slice(-50)},
|
|
785
|
-
'getModule'
|
|
786
|
-
)
|
|
787
|
+
console.log({name, offset, span: v.span, start: code.slice(0, 50), tail: code.slice(-50)}, 'getModule')
|
|
787
788
|
|
|
788
789
|
// 路径替换,以最后一个 node_modules 路径为准
|
|
789
790
|
pos = name.lastIndexOf('/node_modules/')
|
|
@@ -792,16 +793,12 @@ export default class WiaPack {
|
|
|
792
793
|
// ../../node_modules/.pnpm/@wiajs+core@1.1.28/node_modules/@wiajs/core/dist/core.mjs
|
|
793
794
|
/** @type {string} */
|
|
794
795
|
const pre = name.slice(0, pos)
|
|
795
|
-
if (name.endsWith('.less') && pre.includes('/node_modules/less-loader/'))
|
|
796
|
-
name = `~~/${name.slice(pos + 14)}`
|
|
796
|
+
if (name.endsWith('.less') && pre.includes('/node_modules/less-loader/')) name = `~~/${name.slice(pos + 14)}`
|
|
797
797
|
else name = `~/${name.slice(pos + 14)}`
|
|
798
798
|
} else if (/^\.\/src\//.test(name)) {
|
|
799
799
|
name = name.replace(/^\.\/src\//, `${opt.owner}/${opt.name}/`)
|
|
800
800
|
} else if (/^\.\/wia\.config\.js/.test(name)) {
|
|
801
|
-
name = name.replace(
|
|
802
|
-
/^\.\/wia\.config\.js/,
|
|
803
|
-
`${opt.owner}/${opt.name}/wia.config.js`
|
|
804
|
-
)
|
|
801
|
+
name = name.replace(/^\.\/wia\.config\.js/, `${opt.owner}/${opt.name}/wia.config.js`)
|
|
805
802
|
}
|
|
806
803
|
|
|
807
804
|
// name = name.replace(/[.]{1,2}\/[./]*\/node_modules\//gi, '~/')
|