@cocojs/cli 0.1.0-beta.20 → 0.1.0-beta.22
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 +3 -0
- package/dist/index.js +8 -38
- package/dist/webpack-process/index.js +46 -138
- package/package.json +3 -17
- package/runtime-config/tsconfig.json +0 -6
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# coconut-framework [](https://github.com/cocojs-org/coconut-framework/blob/main/LICENSE)
|
|
2
|
+
|
|
3
|
+
`@cocojs/cli`属于[coconut-framework](https://github.com/cocojs-org/coconut-framework)代码仓,更多内容见[cocojs.dev](https://cocojs.dev)。
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,7 @@ var child_process = require('child_process');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var process$1 = require('node:process');
|
|
6
6
|
var path$1 = require('node:path');
|
|
7
|
-
var
|
|
8
|
-
var typescript = require('@rollup/plugin-typescript');
|
|
9
|
-
var babel = require('@rollup/plugin-babel');
|
|
10
|
-
var cocojs = require('@cocojs/rollup-plugin-mvc');
|
|
7
|
+
var bundleRollup = require('@cocojs/bundle-rollup');
|
|
11
8
|
var fs = require('node:fs');
|
|
12
9
|
|
|
13
10
|
function _arrayLikeToArray(r, a) {
|
|
@@ -520,7 +517,7 @@ function _getRollupConfig() {
|
|
|
520
517
|
}
|
|
521
518
|
var build = /*#__PURE__*/function () {
|
|
522
519
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
523
|
-
var config
|
|
520
|
+
var config;
|
|
524
521
|
return _regenerator().w(function (_context) {
|
|
525
522
|
while (1) switch (_context.n) {
|
|
526
523
|
case 0:
|
|
@@ -529,41 +526,14 @@ var build = /*#__PURE__*/function () {
|
|
|
529
526
|
case 1:
|
|
530
527
|
config = _context.v;
|
|
531
528
|
_context.n = 2;
|
|
532
|
-
return
|
|
529
|
+
return bundleRollup.bundle({
|
|
533
530
|
input: path$1.join(process$1.cwd(), './src/index.ts'),
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
declarationDir: './dist/types',
|
|
540
|
-
jsx: 'preserve',
|
|
541
|
-
resolveJsonModule: true,
|
|
542
|
-
plugins: [{
|
|
543
|
-
transform: '@cocojs/type-extractor',
|
|
544
|
-
transformProgram: true
|
|
545
|
-
}]
|
|
546
|
-
}
|
|
547
|
-
}), babel({
|
|
548
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
549
|
-
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), {
|
|
550
|
-
version: '2023-11'
|
|
551
|
-
}], [require.resolve('@babel/plugin-transform-react-jsx', {
|
|
552
|
-
paths: [path$1.resolve(__dirname, '..', '../node_modules')]
|
|
553
|
-
}), {
|
|
554
|
-
runtime: 'automatic',
|
|
555
|
-
importSource: '@cocojs/mvc'
|
|
556
|
-
}]]
|
|
557
|
-
})]
|
|
558
|
-
});
|
|
531
|
+
output: {
|
|
532
|
+
file: path$1.join(process$1.cwd(), './dist/index.esm.js'),
|
|
533
|
+
format: 'es'
|
|
534
|
+
}
|
|
535
|
+
}, config[ValidProp.cocojs]);
|
|
559
536
|
case 2:
|
|
560
|
-
result = _context.v;
|
|
561
|
-
_context.n = 3;
|
|
562
|
-
return result.write({
|
|
563
|
-
file: path$1.join(process$1.cwd(), './dist/index.esm.js'),
|
|
564
|
-
format: 'es'
|
|
565
|
-
});
|
|
566
|
-
case 3:
|
|
567
537
|
return _context.a(2);
|
|
568
538
|
}
|
|
569
539
|
}, _callee);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var process$1 = require('node:process');
|
|
4
|
-
var
|
|
5
|
-
var WebpackDevServer = require('webpack-dev-server');
|
|
4
|
+
var bundleWebpack = require('@cocojs/bundle-webpack');
|
|
6
5
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
7
6
|
var path = require('node:path');
|
|
8
7
|
var fs = require('node:fs');
|
|
9
|
-
var webpackMerge = require('webpack-merge');
|
|
10
8
|
|
|
11
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
12
10
|
try {
|
|
@@ -55,47 +53,6 @@ function _defineProperty(e, r, t) {
|
|
|
55
53
|
writable: true
|
|
56
54
|
}) : e[r] = t, e;
|
|
57
55
|
}
|
|
58
|
-
function ownKeys(e, r) {
|
|
59
|
-
var t = Object.keys(e);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
62
|
-
r && (o = o.filter(function (r) {
|
|
63
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
64
|
-
})), t.push.apply(t, o);
|
|
65
|
-
}
|
|
66
|
-
return t;
|
|
67
|
-
}
|
|
68
|
-
function _objectSpread2(e) {
|
|
69
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
70
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
71
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
72
|
-
_defineProperty(e, r, t[r]);
|
|
73
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
74
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return e;
|
|
78
|
-
}
|
|
79
|
-
function _objectWithoutProperties(e, t) {
|
|
80
|
-
if (null == e) return {};
|
|
81
|
-
var o,
|
|
82
|
-
r,
|
|
83
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
84
|
-
if (Object.getOwnPropertySymbols) {
|
|
85
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
86
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
87
|
-
}
|
|
88
|
-
return i;
|
|
89
|
-
}
|
|
90
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
91
|
-
if (null == r) return {};
|
|
92
|
-
var t = {};
|
|
93
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
94
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
95
|
-
t[n] = r[n];
|
|
96
|
-
}
|
|
97
|
-
return t;
|
|
98
|
-
}
|
|
99
56
|
function _regenerator() {
|
|
100
57
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
101
58
|
var e,
|
|
@@ -282,32 +239,6 @@ function _readWebpack() {
|
|
|
282
239
|
var buildInConfig = {
|
|
283
240
|
mode: 'production',
|
|
284
241
|
entry: path.join(process.cwd(), './src/.coco/index.tsx'),
|
|
285
|
-
module: {
|
|
286
|
-
rules: [{
|
|
287
|
-
test: /\.tsx?$/,
|
|
288
|
-
use: [{
|
|
289
|
-
loader: require.resolve('babel-loader'),
|
|
290
|
-
options: {
|
|
291
|
-
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), {
|
|
292
|
-
version: '2023-11'
|
|
293
|
-
}], [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
294
|
-
runtime: 'automatic',
|
|
295
|
-
importSource: '@cocojs/mvc'
|
|
296
|
-
}]]
|
|
297
|
-
}
|
|
298
|
-
}, {
|
|
299
|
-
loader: require.resolve('ts-loader'),
|
|
300
|
-
options: {
|
|
301
|
-
context: process.cwd(),
|
|
302
|
-
// TODO: 如果开启类型检查的话,编译过程会比较慢,待优化,试试看:fork-ts-checker-webpack-plugin
|
|
303
|
-
transpileOnly: true
|
|
304
|
-
}
|
|
305
|
-
}, {
|
|
306
|
-
loader: require.resolve('@cocojs/webpack-loader-mvc')
|
|
307
|
-
}],
|
|
308
|
-
exclude: /node_modules/
|
|
309
|
-
}]
|
|
310
|
-
},
|
|
311
242
|
resolveLoader: {
|
|
312
243
|
modules: [path.resolve(__dirname, '../../node_modules'), 'node_modules']
|
|
313
244
|
},
|
|
@@ -355,61 +286,37 @@ function _getWebpackConfig() {
|
|
|
355
286
|
return readWebpack(cmd);
|
|
356
287
|
case 2:
|
|
357
288
|
envConfig = _context2.v;
|
|
358
|
-
return _context2.a(2,
|
|
289
|
+
return _context2.a(2, [buildInConfig, baseConfig, envConfig]);
|
|
359
290
|
}
|
|
360
291
|
}, _callee2);
|
|
361
292
|
}));
|
|
362
293
|
return _getWebpackConfig.apply(this, arguments);
|
|
363
294
|
}
|
|
364
295
|
|
|
365
|
-
var _excluded = ["devServer"];
|
|
366
296
|
var WebpackBuilder = /*#__PURE__*/function () {
|
|
367
297
|
function WebpackBuilder() {
|
|
368
298
|
_classCallCheck(this, WebpackBuilder);
|
|
369
|
-
|
|
299
|
+
// server: WebpackDevServer;
|
|
300
|
+
_defineProperty(this, "stopDev", void 0);
|
|
370
301
|
}
|
|
371
302
|
return _createClass(WebpackBuilder, [{
|
|
372
303
|
key: "build",
|
|
373
304
|
value: function () {
|
|
374
|
-
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
375
|
-
|
|
376
|
-
|
|
305
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
306
|
+
var config;
|
|
307
|
+
return _regenerator().w(function (_context) {
|
|
308
|
+
while (1) switch (_context.n) {
|
|
377
309
|
case 0:
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
case 1:
|
|
387
|
-
config = _context.v;
|
|
388
|
-
compiler = Webpack(config);
|
|
389
|
-
compiler.run(function (err, stats) {
|
|
390
|
-
console.log(stats.toString({
|
|
391
|
-
chunks: false,
|
|
392
|
-
// 使构建过程更静默无输出
|
|
393
|
-
colors: true // 在控制台展示颜色
|
|
394
|
-
}));
|
|
395
|
-
if (stats.hasErrors()) {
|
|
396
|
-
reject(err);
|
|
397
|
-
} else {
|
|
398
|
-
resolve();
|
|
399
|
-
}
|
|
400
|
-
compiler.close(function (err) {});
|
|
401
|
-
});
|
|
402
|
-
case 2:
|
|
403
|
-
return _context.a(2);
|
|
404
|
-
}
|
|
405
|
-
}, _callee);
|
|
406
|
-
}));
|
|
407
|
-
return function (_x, _x2) {
|
|
408
|
-
return _ref.apply(this, arguments);
|
|
409
|
-
};
|
|
410
|
-
}()));
|
|
310
|
+
_context.n = 1;
|
|
311
|
+
return getWebpackConfig('build');
|
|
312
|
+
case 1:
|
|
313
|
+
config = _context.v;
|
|
314
|
+
_context.n = 2;
|
|
315
|
+
return bundleWebpack.bundle(config);
|
|
316
|
+
case 2:
|
|
317
|
+
return _context.a(2);
|
|
411
318
|
}
|
|
412
|
-
},
|
|
319
|
+
}, _callee);
|
|
413
320
|
}));
|
|
414
321
|
function build() {
|
|
415
322
|
return _build.apply(this, arguments);
|
|
@@ -419,28 +326,27 @@ var WebpackBuilder = /*#__PURE__*/function () {
|
|
|
419
326
|
}, {
|
|
420
327
|
key: "startServer",
|
|
421
328
|
value: function () {
|
|
422
|
-
var _startServer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
423
|
-
var
|
|
424
|
-
return _regenerator().w(function (
|
|
425
|
-
while (1) switch (
|
|
329
|
+
var _startServer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
330
|
+
var config;
|
|
331
|
+
return _regenerator().w(function (_context2) {
|
|
332
|
+
while (1) switch (_context2.n) {
|
|
426
333
|
case 0:
|
|
427
|
-
|
|
428
|
-
|
|
334
|
+
if (!this.stopDev) {
|
|
335
|
+
_context2.n = 1;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
console.warn('已经启动了一个 dev 服务了。');
|
|
339
|
+
return _context2.a(2);
|
|
429
340
|
case 1:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
config = _objectWithoutProperties(_yield$getWebpackConf, _excluded);
|
|
433
|
-
compiler = Webpack(config);
|
|
434
|
-
devServerOptions = _objectSpread2(_objectSpread2({}, devServer), {}, {
|
|
435
|
-
open: true
|
|
436
|
-
});
|
|
437
|
-
this.server = new WebpackDevServer(devServerOptions, compiler);
|
|
438
|
-
_context3.n = 2;
|
|
439
|
-
return this.server.start();
|
|
341
|
+
_context2.n = 2;
|
|
342
|
+
return getWebpackConfig('dev');
|
|
440
343
|
case 2:
|
|
441
|
-
|
|
344
|
+
config = _context2.v;
|
|
345
|
+
this.stopDev = bundleWebpack.startDev(config);
|
|
346
|
+
case 3:
|
|
347
|
+
return _context2.a(2);
|
|
442
348
|
}
|
|
443
|
-
},
|
|
349
|
+
}, _callee2, this);
|
|
444
350
|
}));
|
|
445
351
|
function startServer() {
|
|
446
352
|
return _startServer.apply(this, arguments);
|
|
@@ -450,22 +356,24 @@ var WebpackBuilder = /*#__PURE__*/function () {
|
|
|
450
356
|
}, {
|
|
451
357
|
key: "stopServer",
|
|
452
358
|
value: function () {
|
|
453
|
-
var _stopServer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
454
|
-
return _regenerator().w(function (
|
|
455
|
-
while (1) switch (
|
|
359
|
+
var _stopServer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
360
|
+
return _regenerator().w(function (_context3) {
|
|
361
|
+
while (1) switch (_context3.n) {
|
|
456
362
|
case 0:
|
|
457
|
-
if (!this.
|
|
458
|
-
|
|
363
|
+
if (!this.stopDev) {
|
|
364
|
+
_context3.n = 2;
|
|
459
365
|
break;
|
|
460
366
|
}
|
|
461
|
-
|
|
462
|
-
return this.
|
|
367
|
+
_context3.n = 1;
|
|
368
|
+
return this.stopDev();
|
|
463
369
|
case 1:
|
|
464
|
-
this.
|
|
370
|
+
this.stopDev = null;
|
|
371
|
+
_context3.n = 2;
|
|
372
|
+
break;
|
|
465
373
|
case 2:
|
|
466
|
-
return
|
|
374
|
+
return _context3.a(2);
|
|
467
375
|
}
|
|
468
|
-
},
|
|
376
|
+
}, _callee3, this);
|
|
469
377
|
}));
|
|
470
378
|
function stopServer() {
|
|
471
379
|
return _stopServer.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocojs/cli",
|
|
3
3
|
"description": "命令行工具,支持开发和构建功能",
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.22",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -27,25 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/core": "^7.26.7",
|
|
31
|
-
"@babel/generator": "^7.26.5",
|
|
32
|
-
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
33
|
-
"@babel/plugin-transform-react-jsx": "^7.25.9",
|
|
34
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
35
|
-
"@rollup/plugin-typescript": "^12.1.2",
|
|
36
|
-
"babel-loader": "^10.0.0",
|
|
37
30
|
"chokidar": "^4.0.3",
|
|
38
31
|
"fs-extra": "^11.2.0",
|
|
39
32
|
"html-webpack-plugin": "^5.6.3",
|
|
40
|
-
"rollup": "
|
|
41
|
-
"
|
|
42
|
-
"webpack": "^5.98.0",
|
|
43
|
-
"webpack-cli": "^6.0.1",
|
|
44
|
-
"webpack-dev-server": "^5.2.0",
|
|
45
|
-
"webpack-merge": "^6.0.1",
|
|
46
|
-
"@cocojs/rollup-plugin-mvc": "0.0.1-alpha.7",
|
|
47
|
-
"@cocojs/type-extractor": "0.0.16",
|
|
48
|
-
"@cocojs/webpack-loader-mvc": "0.0.1-alpha.7"
|
|
33
|
+
"@cocojs/bundle-rollup": "0.0.1-beta.9",
|
|
34
|
+
"@cocojs/bundle-webpack": "0.0.1-beta.9"
|
|
49
35
|
},
|
|
50
36
|
"devDependencies": {
|
|
51
37
|
"@types/node": "^22.15.18"
|